%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__/dpbxbackend.cpython-312.pyc

�

�2e`L��8�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
mZmZddl
m
Z
ddlmZddlmZddlZ
dZdZej*d�Zd	�Zdd
�ZGd�de
j2j4�Ze
j2j9d
e�y)�N)�log�config)�progress��BackendException)�ConnectionErroriiz \([0-9]+\)\.[^\.]+$c�B�tjd|�d��tj�}t	j
|��|j
d�|j�D](}tjd|j�����*|j�y)NzException [z]:)�filerz| )
r�Error�io�StringIO�	traceback�	print_exc�seek�	readlines�rstrip�close)�e�f�ss   �@/usr/lib/python3/dist-packages/duplicity/backends/dpbxbackend.py�
log_exceptionr=sr���I�I��A�3�b�!�"�
���
�A�
���Q���F�F�1�I�
�[�[�]�%���	�	�B�q�x�x�z�l�#�$�%��G�G�I�c��d�}|S)z6a decorator for handling authentication and exceptionsc�4���fd�}�j|_|S)Nc���	�|g|���S#t$r}t|�td|�d���d}~wt$rC}t|�t	j
d|�d�tjj��d}~wwxYw)Nzdpbx api error "�"zdpbx code error ")�ApiErrorrr�	Exceptionrr�	ErrorCode�backend_code_error)�self�argsrrs   �r�wrapperz*command.<locals>.decorate.<locals>.wrapperKsz���
���~��~�%���
@��a� �&�)9�!��A�'>�?�?���
��a� ��	�	�-�a�S��2�C�M�M�4T�4T�U���
�s��	A>�/�A>�>A9�9A>)�__doc__)rr$s` r�decoratezcommand.<locals>.decorateJs���		��)�)����r�)�login_requiredr&s  r�commandr)Gs��
��Orc���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
e�d	��Zd
�Z
d�Ze�d��Ze�d
��Ze�d��Ze�d��Ze�d��Zd�Zy)�DPBXBackendz-Connect to remote store using Dr*pB*x servicec�D�tjjj||�	ddlmaddlmamam	a	ddl
mamam
a
mamamamaddlmad|_d|_d|_|j5�y#t($r}t+dt-|�����d}~wwxYw)Nr)�Dropbox)�	AuthError�
BadInputErrorr)�UploadSessionCursor�
CommitInfo�	WriteMode�GetMetadataError�DeleteError�UploadSessionLookupError�ListFolderError)�DropboxOAuth2FlowNoRedirectztThis backend requires the dropbox package version 6.9.0
To install use "sudo pip install dropbox==6.9.0"
Exception: )�	duplicity�backend�Backend�__init__�dropboxr-�dropbox.exceptionsr.r/r�
dropbox.filesr0r1r2r3r4r5r6�
dropbox.oauthr7�ImportErrorr�str�api_account�
api_client�	auth_flow�login)r"�
parsed_urlrs   rr;zDPBXBackend.__init___s������!�!�*�*�4��<�	�'�
�
�

�
�
�
B� ����������
�
����	�"����F�8���
��	�s�(A:�:	B�B�Bc��	|jj�}tjd|���y#t$r}tjd�Yd}~yd}~wwxYw)NzUser authenticated as ,TzUser not authenticatedF)rC�users_get_current_accountr�Debugr)r"�accountrs   r�user_authenticatedzDPBXBackend.user_authenticated�sP��	��o�o�?�?�A�G��I�I�/��y�9�:����	��I�I�.�/���	�s�25�	A�A�Ac�B�tjjdd�S)N�DPBX_ACCESS_TOKEN)�os�environ�get�r"s r�load_access_tokenzDPBXBackend.load_access_token�s���z�z�~�~�1�4�8�8rc� �td|�d���)Nz$dpbx: Please set DPBX_ACCESS_TOKEN="z" environment variabler)r"�access_tokens  r�save_access_tokenzDPBXBackend.save_access_token�s���!E�l�^�Si�j�k�krc��tjd�dD]#}|tjvs�t	d|�d���tjd}tjd}t
jj�rt
jj�s.tjdtjj�t||�}tjd�|j�}t�td	�td
|���td�td�td	�t!d
�j#�}	tjd|�d��|j%|�}tjd�|j)|j*�y#t&$r}t	d|����d}~wwxYw)Nz#dpbx: trying to obtain access token)�DPBX_APP_KEY�DPBX_APP_SECRETzdpbx: z environment variable not setrWrXz5dpbx error: cannot interact, but need human attentionzdpbx,auth_flow.start()�H------------------------------------------------------------------------z
1. Go to: z22. Click "Allow" (you might have to log in first).z3. Copy the authorization code.z#Enter the authorization code here: zdpbx,auth_flow.finish(�)z%dpbx: Unable to obtain access token: z dpbx: Authentication successfull)r�InforNrOr�sys�stdout�isatty�stdin�
FatalErrorr �backend_command_errorr7rI�start�print�input�strip�finishrrUrT)	r"�env_var�app_key�
app_secretrD�
authorize_url�	auth_code�
authresultrs	         r�obtain_access_tokenzDPBXBackend.obtain_access_token�s������6�7�:�	X�G��b�j�j�(�&���y�8U�'V�W�W�	X��*�*�^�,���Z�Z� 1�2�
��z�z� � �"�#�)�)�*:�*:�*<��N�N�G��
�
�3�3�
�
0���D�	��	�	�*�+�!���)�
�
��
�h��
�
�=�/�*�+�
�B�C�
�/�0�
�h���?�@�F�F�H�	�	P��I�I�.�y�k��;�<�"�)�)�)�4�J�	���3�4����z�6�6�7���	P�"�%J�1�#�#N�O�O��	P�s�*F8�8	G�G�Gc�f�|j��|j�t|j��|_d|_	tjd�|jj�|_tjd|j���tjd|jjj���y#ttf$rM}tjd|���tjd�|j�td��d}~wwxYw)Nz'dpbx,users_get_current_account([token])zdpbx,zdpbx,exception: z>dpbx: Authentication failed. Trying to obtain new access tokenz3dpbx: Please update DPBX_ACCESS_TOKEN and try againz$dpbx: Successfully authenticated as )rRrmr-rCrBrrIrHr/r.r[r�name�display_name)r"rs  rrEzDPBXBackend.login�s����!�!�#�+��$�$�&�!�$�"8�"8�":�;������
	Z��I�I�?�@�#���H�H�J�D���I�I��d�.�.�/�0�1�	���7��8H�8H�8M�8M�8Z�8Z�7[�\�]���y�)�	Z��I�I�(���,�-��H�H�U�V��$�$�&�#�#X�Y�Y��	Z�s�AC�D0�#AD+�+D0c��t|t�r�|j}t|t�rI|j	�r9|j�j
�rtjjSyt|t�rV|j�rE|jj�}|j
�rtjjSyyyy)N)
�
isinstancer�errorr3�is_path�get_path�is_not_foundrr �backend_not_foundr4�is_path_lookup�get_path_lookup)r"�	operationr�err�lookups     r�_error_codezDPBXBackend._error_code�s����a��"��'�'�C��#�/�0�S�[�[�]��<�<�>�.�.�0��=�=�:�:�:�1��C��-�#�2D�2D�2F����0�0�2���&�&�(��=�=�:�:�:�)�3G�-�
#rc��tjj|jjjd��}dtjj||j��j���}tjj|j�}tjd|�|tkr|j||�}n|j!||�}|j"|k7rt%d|j"�d|�d���|j&|k7rt%d|j&�d|�d���y)N�/rzdpbx: result path mismatch: � (expected: rZzdpbx: result size mismatch: )�urllib�parse�unquoterF�path�lstriprN�join�decoder�getsizeror�report_transfer�DPBX_UPLOAD_CHUNK_SIZE�put_file_small�put_file_chunked�path_displayr�size)r"�source_path�remote_filename�
remote_dir�remote_path�	file_size�res_metadatas       r�_putzDPBXBackend._put�s���\�\�)�)�$�/�/�*>�*>�*E�*E�c�*J�K�
��"�'�'�,�,�z�?�3I�3I�3K�L�S�S�U�V�W���G�G�O�O�K�$4�$4�5�	�� � ��I�.��-�-��.�.�{�K�H�L��0�0��k�J�L��$�$��3�"�%A�,�B[�B[�A\�\h�it�hu�uv�#w�x�x����	�)�"�%A�,�BS�BS�AT�T`�aj�`k�kl�#m�n�n�*rc�&�|j�s|j�tjj	|j
�}|j
d�}	tjd|�dt|��d��|jj|j�|tjddd��}tjd|���tj ||�||j#�S#|j#�wxYw)	N�rbzdpbx,files_upload(z, [z bytes])FT��mode�
autorename�client_modified�mutezdpbx,files_upload(): )rKrErNr�r�ro�openrrI�intrC�files_upload�readr2�	overwriterr�r)r"r�r�r�rr�s      rr�zDPBXBackend.put_file_small�s����&�&�(��J�J�L��G�G�O�O�K�$4�$4�5�	����T�"��	��I�I�*�;�-�s�3�y�>�:J�(�S�T��?�?�7�7�������(�(� � $��
8��L�
�I�I�-�l�^�<�=��$�$�Y�	�:��
�G�G�I��A�G�G�I�s
�BC>�>Dc�	�|j�s|j�tjj	|j
�}|j
d�}	|jt�}tjdt|��dt|����|jj|�}tjd|���t|j |j#��}t%|t&j(ddd��}d}	t+j,|j#�|�d}
t}t.j0}d}
|
r|	�s�	|
�|
|_|j#�|j2k7r|j5|j2�|j|�}|j#�|k\}
|
st|�dk(r�|d}
t}t.j0}|
szt|�dk7sJ�tjd	t|��d
t|j2��d��|jj7||j |j2�nUtjdt|��d
t|j2��d��|jj9|||�}	|j#�|_tjd
t|j2��dt|����t+j,|j2|�|
s���|	s���|j#�|k7rtId��tjd|	���t+j,|j#�|�|	|jS�S#t:$r�}|j<}t?|t@�rn|jC�r^|jE�jF}tjdt|j2��d|�d��|
�tId��|}
Yd}~��؂d}~wtJ$r�}tjd|���|dz}|j�s|j�|dk(r�tjLd�tOjPd�tdz}d}
Yd}~��cd}~wwxYw#|jS�wxYw)Nr�z!dpbx,files_upload_session_start([z bytes]), total: z#dpbx,files_upload_session_start(): FTr�rz#dpbx,files_upload_sesssion_append([z bytes], offset=rZz#dpbx,files_upload_sesssion_finish([z
progress: z of z4dpbx,files_upload_session_append: incorrect offset: r�zdpbx: unable to chunk uploadz"dpbx,files_upload_session_append: �z'dpbx: sleeping a bit before chunk retry��zdpbx: something wrongz%dpbx,files_upload_sesssion_finish(): )*rKrErNr�r�ror�r�r�rrI�lenr�rC�files_upload_session_startr0�
session_id�tellr1r2r�rr�r�num_retries�offsetr�files_upload_session_append�files_upload_session_finishrrsrrr5�is_incorrect_offset�get_incorrect_offset�correct_offsetrrr[�time�sleepr)r"r�r�r�r�buf�
upload_sid�
upload_cursor�commit_infor��requested_offset�current_chunk_size�retry_number�is_eofrrs�
new_offsets                 rr�zDPBXBackend.put_file_chunkeds(���&�&�(��J�J�L��G�G�O�O�K�$4�$4�5�	����T�"��n	��&�&�/�0�C��I�I�9�#�c�(��CT�UX�Yb�Uc�Td�e�f����C�C�C�H�J��I�I�;�J�<�H�I�/�
�0E�0E�q�v�v�x�P�M�$���(�(� � $���K� �L��$�$�Q�V�V�X�y�9�#��!7��!�-�-�L��F�
�L�J�'�3�/?�
�,��v�v�x�=�#7�#7�7����}�3�3�4��&�&�!3�4�C��V�V�X��2�F�!�c�#�h�!�m� �(,�$�)?�&�#)�#5�#5�L�!�"�3�x�1�}�,�}��	�	�A�#�c�(��L&�&)�-�*>�*>�&?�%@��C�����C�C�C��Ia�Ia�cp�cw�cw�x��	�	�A�#�c�(��L&�&)�-�*>�*>�&?�%@��C��(,���'R�'R�SV�Xe�gr�'s��+,�6�6�8�M�(��I�I�
�3�}�/C�/C�+D�*E�T�#�i�.�IY�Z�[��,�,�]�-A�-A�9�M�E�L�Z�v�v�x�9�$�&�'>�?�?��I�I�=�l�^�L�M��$�$�Q�V�V�X�y�9��
�G�G�I��g ���G�G�E�!�%�)A�B�u�G`�G`�Gb�&+�%?�%?�%A�%P�%P�
��	�	�R�SV�Wd�Wk�Wk�Sl�Rm�n*�*4��Q�8��,�7�#3�3Q�"R�R�0:�,� ���&���I�I� B�1�#�F�G� �A�%�L��2�2�4��
�
��#�q�(��
�H�H�F�G��J�J�r�N�)?�!�)C�&�'+�$���%��:
�G�G�I�sl�C<R>�A5N�R>�EN�$R>�(R>�,AR>�	R;�!BP,�%R>�+P,�,R;�8A8R6�0R>�6R;�;R>�>Sc�R�|j�s|j�tjj	|j
jjd��}dtjj||j��j���}tjd|�d��|jj|�\}}tjd|�d|�d|���|j }d}t#j$d|�	|j'd�}|j)t*�D]7}	|j-|	�t#j$|j/�|��9	|r|j1�|j1�tjj3|j4�}
|
|k7r$t7dt9|
��d	t9|��d���|j;�y#|r|j1�|j1�wxYw)
Nrzdpbx,files_download(rZ�): z, r�wbzdpbx: wrong file size: r�)rKrEr�r�r�rFr�r�rNr�r�rrrIrC�files_downloadr�rr�r��iter_content�DPBX_DOWNLOAD_BUF_SIZE�writer�rr�rorr��setdata)r"r��
local_pathr�r�r��http_fdr��to_fd�c�
local_sizes           r�_getzDPBXBackend._get{s����&�&�(��J�J�L��\�\�)�)�$�/�/�*>�*>�*E�*E�c�*J�K�
��"�'�'�,�,�z�?�3I�3I�3K�L�S�S�U�V�W���	�	�(��
�Q�7�8� $��� >� >�{� K���g��	�	�(��
�S���b��	�R�S� �%�%�	���� � ��I�.�		��O�O�D�)�E��)�)�*@�A�
B�����A���(�(�����y�A�
B�
����
��M�M�O��W�W�_�_�Z�_�_�5�
���"�"�%<�S��_�<M�\�Z]�^g�Zh�Yi�ij�#k�l�l����������
��M�M�O�s
�A H�$H&c��|j�s|j�dtjj	|j
jjd��j���}tjd|�d��g}	|jj|�}tjd|�d|���	|j|jD�cgc]}|j��c}�|j sn&|jj#|j$�}�f	|j5|�|Scc}w#t&$r�}t)|j*t,�r_|j*j/�rE|j*j1�j3�rtjd|�d|�d��n�Yd}~��d}~wwxYw)Nrzdpbx.files_list_folder(rZz
dpbx.list(r�z): ignore missing folder ()rKrEr�r�r�rFr�r�rrrIrC�files_list_folder�extend�entriesro�has_more�files_list_folder_continue�cursorrrrrsr6rtrurv�check_renamed_files)r"r��res�resp�entryrs      r�_listzDPBXBackend._list�ss���&�&�(��J�J�L�����-�-�d�o�o�.B�.B�.I�.I�#�.N�O�V�V�X�Y�Z�
��	�	�+�J�<�q�9�:���
	��?�?�4�4�Z�@�D��I�I�
�:�,�c�$��8�9���
�
�D�L�L�A�5�E�J�J�A�B��}�}�����A�A�$�+�+�N��	��	
� � ��%��
��B���	��!�'�'�?�3������8I�a�g�g�N^�N^�N`�Nm�Nm�No��	�	�J�z�l�2L�Q�C�q�Q�R��S��	�s,�AE� E�3:E�E�	G�A:G�Gc��|j�s|j�tjj	|j
jjd��}dtjj||j��j���}tjd|�d��|jj|�y)Nrzdpbx.files_delete(rZ)rKrEr�r�r�rFr�r�rNr�r�rrrIrC�files_delete)r"�filenamer�r�s    r�_deletezDPBXBackend._delete�s����&�&�(��J�J�L��\�\�)�)�$�/�/�*>�*>�*E�*E�c�*J�K�
��"�'�'�,�,�z�8�?�?�3D�E�L�L�N�O�P���	�	�&�{�m�1�5�6����$�$�[�1rc�.�tjd�y)z0close backend session? no! just "flush" the dataz
dpbx.close():N)rrIrQs r�_closezDPBXBackend._close�s��	�	�	�/�"rc��|j�s|j�tjj	|j
jjd��}dtjj||j��j���}tjd|�d��|jj|�}tjd|�d|���d|j iS)Nrzdpbx.files_get_metadata(rZr�r�)rKrEr�r�r�rFr�r�rNr�r�rrrIrC�files_get_metadatar�)r"r�r�r��infos     r�_queryzDPBXBackend._query�s����&�&�(��J�J�L��\�\�)�)�$�/�/�*>�*>�*E�*E�c�*J�K�
��"�'�'�,�,�z�8�?�?�3D�E�L�L�N�O�P���	�	�,�[�M��;�<����1�1�+�>���	�	�,�[�M��T�F�C�D���	�	�"�"rc�@�|j�s|j�|D�cgc]}tj|���|��}}t	|�dk(rytjd�tjd�tjd�tjd�tjd�tjd�tjd�tjd�tjd	�tjd�tjd
�|D]}tjd|����tjd�tjd�tjd�ycc}w)
NrrYzGWarning! It looks like there are automatically renamed files on backendzAThey were probably created when using older version of duplicity.�zIPlease check your backup consistency. Most likely you will need to choosezMlargest file from duplicity-* (number).gpg and remove brackets from its name.z?These files are not managed by duplicity at all and will not bezremoved/rotated automatically.zAffected files:�	z.In any case it's better to create full backup.)rKrE�DPBX_AUTORENAMED_FILE_RE�searchr�r�Warn)r"�	file_list�x�bad_lists    rr�zDPBXBackend.check_renamed_files�s���&�&�(��J�J�L�(�[�!�,D�,K�,K�A�,N�,Z�A�[��[��x�=�A�����������Z�[����T�U���������\�]����`�a���������R�S����1�2���������"�#��	�A��H�H�r�!��X��	���������A�B�������%\s�F�FN)�__name__�
__module__�__qualname__r%r;rKrRrUrmrEr}r)r�r�r�r�r�r�r�r�r�r'rrr+r+\s���7�&�P�9�l�8�B^�.
;�
�Y�o��o�&�.t�l
�Y����@
�Y����8
�Y�2��2�
�Y�#��#�
�Y�	#��	#�rr+�dpbx)T)rrN�rer\r�r�urllib.errorr��urllib.parse�urllib.requestr8rrr�duplicity.errorsr�requests.exceptionsr�duplicity.backendr�r��compiler�rr)r9r:r+�register_backendr'rr�<module>r�s���:
�	�	�
��������-�/��*��$��%�2�:�:�&=�>����*R�)�#�#�+�+�R�j
���"�"�6�;�7r

Zerion Mini Shell 1.0