%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/duplicity/backends/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/duplicity/backends/__pycache__/megabackend.cpython-312.pyc

�

�2e�����ddlZddlZddlZddlmZGd�dejj�Zejjde�ejjjdg�y)�N)�BackendExceptionc�Z�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd
�Zd�Z
d�Zd
�Zy)�MegaBackendz,Connect to remote store using Mega.co.nz APIc��tjjj||�|j	d�|j	d�|j	d�|j	d�|j	d�|j
|_|j�tjd��d�|_
n-d|_
|j|_|j�|_d	|_|j�d
|j dd��|_|j%|j ddj'd
��y)N�megals�	megamkdir�megaget�megaput�megarm�HOMEz/.megarcFz/Root�/�)�	duplicity�backend�Backend�__init__�_check_binary_exists�hostname�	_hostname�password�os�getenv�_megarc�username�	_username�get_password�	_password�_root�path�_folder�_makedir_recursive�split)�self�
parsed_urls  �@/usr/lib/python3/dist-packages/duplicity/backends/megabackend.pyrzMegaBackend.__init__!s�����!�!�*�*�4��<�	
�!�!�(�+��!�!�+�.��!�!�)�,��!�!�)�,��!�!�(�+�$�,�,������&� �i�i��/�0��9�D�L� �D�L�'�0�0�D�N�!�.�.�0�D�N���
��*�*��Q�z���q�r�':�&;�<���	
���
����� 3� 9� 9�#� >�?�c�t�	tjd|g�y#t$r}td|�d���d}~wwxYw)z:checks that a specified command exists in the current path�whichz	command 'z.' not found, make sure megatools are installedN)�
subprocess�check_output�	Exceptionr)r#�cmd�es   r%rz MegaBackend._check_binary_exists<sA��	d��#�#�W�c�N�3���	d�"�Y�s�e�3a�#b�c�c��	d�s��	7�2�7c��|jrdd|j|g}ndd|jd|j|g}|j|�y)zcreates a remote directoryr�--config�-u�-pN)rrr�subprocess_popen)r#rr,s   r%�_makedirzMegaBackend._makedirEsE���<�<��
�D�L�L�$�?�C���d�n�n�d�D�N�N�D�Q�C����c�"r&c���tddj|����|j}|D]}|�d|��}	|j|��y#t$r
}Yd}~�-d}~wwxYw)zGcreates a remote directory (recursively the whole path), ingores errorszmkdir: r
N)�print�joinrr3r+)r#r�p�folderr-s     r%r!zMegaBackend._makedir_recursiveOsi��	�������'�(�)��J�J���	�F��#�Q�v�h��A�
��
�
�a� �	���
���
�s�A�	A�Ac��	|jtj|��|j	tj|j��tj|���y#t$rY�SwxYw)zDuploads file to Mega (deletes it first, to ensure it does not exist))�
local_file�remote_fileN)�deleter�fsdecoder+�upload�
get_canonical)r#�source_path�remote_filenames   r%�_putzMegaBackend._put]sa��	��K�K����O�4�5�	
���r�{�{�;�+D�+D�+F�G�UW�U`�U`�ap�Uq��r���	��	�s�$A.�.	A:�9A:c��|jtj|�tj|j���y)zdownloads file from Mega)r;r:N)�downloadrr=�name)r#rA�
local_paths   r%�_getzMegaBackend._getgs-��	
�
�
�"�+�+�o�">�2�;�;�Wa�Wf�Wf�Kg�
�hr&c�&�|jd��S)zlist files in the backup folderT)�
files_only)�folder_contents)r#s r%�_listzMegaBackend._listls���#�#�t�#�4�4r&c�N�|jtj|���y)zdeletes remote)r;N)r<rr=)r#�filenames  r%�_deletezMegaBackend._deleteqs��	
������H� 5��6r&c�:�td|j���|jrdd|j|jg}n&dd|jd|j|jg}tj|�}tj|j��jd�}|D�cgc]}|t|j�dzd��}}|r|D�cgc]	}d	|vs�|��}}|D�cgc]}tj|���c}Scc}wcc}wcc}w)
z>lists contents of a folder, optionally ignoring subdirectorieszmegals: rr/r0r1�
rNr
)
r5r rrrr)r*rr=�stripr"�len�fsencode)r#rIr,�files�fs     r%rJzMegaBackend.folder_contentsvs���	������'�(��<�<��Z����t�|�|�D�C��T�4�>�>�4�������V�C��'�'��,�����E�K�K�M�*�0�0��6��6;�;���3�t�|�|�$�q�(�*�+�;��;�� %�6�1��A��Q�6�E�6�(-�.�1����A��.�.��
<��7��.s�1"D�	D�%D�/Dc��td|���|jr#dd|jdd||j�d|��g}n.dd|jd|jdd||j�d|��g	}|j|�y)	Nz	megaget: r	r/�
--no-progress�--pathr
r0r1�r5rr rrr2)r#r;r:r,s    r%rDzMegaBackend.download�s���
�	�+��'�(��<�<����������<�<�.��+��/��C��������������<�<�.��+��/�
�C�	
���c�"r&c
��td|���|jr#dd|jdd|j�d|��|g}n.dd|jd|jdd|j�d|��|g	}	|j|�y#t$r5}t|�}d	|vrtd
|�d���td|�d
|�d���d}~wwxYw)Nz	megaput: r
r/rWrXr
r0r1�
EOVERQUOTAz1MEGA account over quota, could not write file : 'zC'. Upgrade your storage at https://mega.nz/pro or remove some data.zFailed writing file 'z' to MEGA , reason : '�')	r5rr rrr2r+�strr)r#r:r;r,r-�	error_strs      r%r>zMegaBackend.upload�s���
�	�+��'�(��<�<���������<�<�.��+��/���C�������������<�<�.��+��/��
�C�
	h��!�!�#�&���	h��A��I��y�(�&�G��}�UW�X���
'�)>�{�m�Ka�bc�ad�de�'f�g�g��	h�s�-A?�?	B=�0B8�8B=c���td|���|jr dd|j|j�d|��g}n+dd|jd|j|j�d|��g}|j|�y)Nzmegarm: rr/r
r0r1rY)r#r;r,s   r%r<zMegaBackend.delete�ss��
���
�&�'��<�<��Z����$�,�,��q��
�7V�W�C��T�4�>�>�4����D�L�L�>�YZ�[f�Zg�Ih�i�C����c�"r&N)F)�__name__�
__module__�__qualname__�__doc__rrr3r!rBrGrKrNrJrDr>r<�r&r%rrsG��6�@�6d�#��s�i�
5�
7�
/�,#�8$h�L#r&r�mega)rr)�duplicity.backendr�duplicity.errorsrrrr�register_backend�uses_netloc�extendrdr&r%�<module>rksb��.
���-�x#�)�#�#�+�+�x#�v
���"�"�6�;�7�	�����$�$�f�X�.r&

Zerion Mini Shell 1.0