%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�2e�!����ddlZddlZddlZddlZddlmZGd�dejj�Z	ejjde	�ejjjdg�y)�N)�BackendExceptionc�`�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zdd�Z
d�Zd
�Zd�Zy)�
Megav2Backenda�Backend for MEGA.nz cloud storage, only one that works for accounts created since Nov. 2018
    See https://github.com/megous/megatools/issues/411 for more details

    This MEGA backend resorts to official tools (MEGAcmd) as available at https://mega.nz/cmd
    MEGAcmd works through a single binary called "mega-cmd", which talks to a backend server
    "mega-cmd-server", which keeps state (for example, persisting a session). Multiple "mega-*"
    shell wrappers (ie. "mega-ls") exist as the user interface to "mega-cmd" and MEGA API
    The full MEGAcmd User Guide can be found in the software's GitHub page below :
    https://github.com/meganz/MEGAcmd/blob/master/UserGuide.mdc��tjjj||�|j	d�|j	d�|j	d�|j	d�|j	d�|j	d�|j	d�|j	d�|j	d	�|j
|_|j��tjd
��d�|_
	t|jd�}i}|D]F}|jd�ddd�\}}t|j!��||j!�<�H|j#�|d|_|d|_n&|j(|_|j+�|_d|j,dd��|_|j1�d|j.g}	|j3|�y#t$r}td
|j�d���d}~wwxYw#t$r%}|j5|j.�Yd}~yd}~wwxYw)N�
mega-login�mega-logoutzmega-cmdzmega-cmd-server�mega-ls�
mega-mkdir�mega-get�mega-put�mega-rm�HOMEz
/.megav2rc�rzYNo password provided in URL and MEGA configuration file for duplicity does not exist as '�'�=��Username�Password�/�)�	duplicity�backend�Backend�__init__�_check_binary_exists�hostname�	_hostname�password�os�getenv�_megarc�open�	Exceptionr�	partition�str�strip�close�	_username�	_password�username�get_password�path�_folder�
mega_login�subprocess_popen�_makedir)	�self�
parsed_url�	conf_file�e�myvars�line�name�var�cmds	         �B/usr/lib/python3/dist-packages/duplicity/backends/megav2backend.pyrzMegav2Backend.__init__)s�����!�!�*�*�4��<�	
�!�!�,�/��!�!�-�0��!�!�*�-��!�!�"3�4��!�!�)�,��!�!�,�/��!�!�*�-��!�!�*�-��!�!�)�,�$�,�,������&� �i�i��/�0�
�;�D�L�
� ����s�3�	��F�!�
8�� �N�N�3�/��!��4�	��c�'*�3�9�9�;�'7��t�z�z�|�$�
8�
�O�O��#�J�/�D�N�#�J�/�D�N�(�0�0�D�N�!�.�.�0�D�N��:�?�?�1�2�.�/�0���	
�����$�,�,�'��	(��!�!�#�&��3�
�&�4�48�L�L�>��D����
��4�	(��M�M�$�,�,�'�'��	(�s0�?G5�#H�5	H�>H�H�	I
�(I�I
c�t�	tjd|g�y#t$r}td|�d���d}~wwxYw)zGChecks that a specified command exists in the running user command path�whichz	Command 'zw' not found, make sure 'MEGAcmd' tools (https://mega.nz/cmd) is properly installed and in the running user command pathN)�
subprocess�check_outputr#r)r1r9r4s   r:rz"Megav2Backend._check_binary_exists[sI��	��#�#�W�c�N�3���	�"��C�5�!M�N��
��	�s��	7�2�7c���|j�dd|g}	|j|�y#t$r5}t|�}d|vrt	d|�d���t	d|�d|�d���d}~wwxYw)	z5Creates a remote directory (recursively if necessary)r
z-pzFolder already existszFolder 'zp' could not be created on MEGA because it already exists. Use another path or remove the folder in MEGA manuallyz"' could not be created, reason : 'rN)r.r/r#r%r)r1r,r9r4�	error_strs     r:r0zMegav2Backend._makedirgs���	
�����T�4�(��
	`��!�!�#�&���	`��A��I�&�)�3�&��t�f�%M�N���
'��$��7Y�Z[�Y\�\]�'^�_�_��	`�s�)�	A'�0A"�"A'c���	|j|j��|j|j	�j�|j���y#t$rY�IwxYw)zwUploads file to the specified remote folder (tries to delete it first to make
        sure the new one can be uploaded))�
local_file�remote_fileN)�delete�decoder#�upload�
get_canonical)r1�source_path�remote_filenames   r:�_putzMegav2Backend._putxsd��	��K�K��.�.�0�1�	
���"�0�0�2�9�9�;�'�.�.�0�	�	
���	��	�s�A�	A+�*A+c�v�|j|j�|jj���y)z-Downloads file from the specified remote path)rCrBN)�downloadrEr7)r1rI�
local_paths   r:�_getzMegav2Backend._get�s*��	
�
�
�/�"8�"8�":�z���G]�G]�G_�
�`�c�&�|jd��S)z(Lists files in the specified remote pathT)�
files_only)�folder_contents)r1s r:�_listzMegav2Backend._list�s���#�#�t�#�4�4rOc�D�|j|j���y)z+Deletes file from the specified remote path)rCN)rDrE)r1�filenames  r:�_deletezMegav2Backend._delete�s��	
������ 1��2rOc�,�dg}|j|�y)z/Function called when backend is done being usedrN)r/)r1r9s  r:�_closezMegav2Backend._close�s���o�����c�"rOc�Z�	tjdd��y	#tj$rtd��t$rj}d|j
|jg}	tj|tj��n #t$r}td|�d���d	}~wwxYwYd	}~y	d	}~wwxYw)
z�Helper function to call from each method interacting with MEGA to make
        sure a session already exists or one is created to start withzmega-session�)�timeoutz<Timed out while trying to determine if a MEGA session existsr)�stderrz#Could not log in to MEGA, error : 'rN)r=r>�TimeoutExpiredrr#r(r)�DEVNULL)r1r4r9s   r:r.zMegav2Backend.mega_login�s���		S��#�#�N�B�?���(�(�	c�"�#a�b�b��	S��������@�C�
S��'�'��J�4F�4F�G���
S�&�)L�Q�C�q�'Q�R�R��
S��H��	S�s9��&B*�B%�%B�?B%�	B�	B�B�B%�%B*c�(�dd|jg}|j�tj|�}|j	�jd�}|r7|D�cgc],}t
jd|�s�|j�d��.}}|Scc}w)zHLists contents of a remote MEGA path, optionally ignoring subdirectoriesr	z-l�
z^-�)r-r.r=r>rE�split�re�search)r1rQr9�files�fs     r:rRzMegav2Backend.folder_contents�s~���$����-�������'�'��,������$�$�T�*���+0�G�a�B�I�I�d�A�4F�Q�W�W�Y�q�\�G�E�G����Hs�B�6Bc�n�d|j�d|��|g}|j�|j|�y)z(Downloads a file from a remote MEGA pathrrN�r-r.r/)r1rCrBr9s    r:rLzMegav2Backend.download�s7���d�l�l�^�1�[�M�:�J�G���������c�"rOc���d||j�d|��g}|j�	|j|�y	#t$r5}t	|�}d|vrtd|�d���td|�d|�d���d	}~wwxYw)
z$Uploads a file to a remote MEGA pathrrzReached storage quotaz1MEGA 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 : 'rN)r-r.r/r#r%r)r1rBrCr9r4r@s      r:rFzMegav2Backend.upload�s����:�$�,�,��q��
�'F�G������
	g��!�!�#�&���	g��A��I�&�)�3�&�G��}�UW�X���
'�)>�{�m�K`�ab�`c�cd�'e�f�f��	g�s�8�	A6�0A1�1A6c�n�dd|j�d|��g}|j�|j|�y)z&Deletes a file from a remote MEGA pathr
z-frNrh)r1rCr9s   r:rDzMegav2Backend.delete�s7���$�4�<�<�.��+�� ?�@���������c�"rON)F)�__name__�
__module__�__qualname__�__doc__rrr0rJrNrSrVrXr.rRrLrFrD�rOr:rrsN��B�0(�d
�`�"
�a�
5�
3�
#�S�"
�#�g�"#rOr�megav2)
rrcr=�duplicity.backendr�duplicity.errorsrrrr�register_backend�uses_netloc�extendrorOr:�<module>rvse��,
�	���-�y#�I�%�%�-�-�y#�x
���"�"�8�]�;�	�����$�$�h�Z�0rO

Zerion Mini Shell 1.0