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

�

�2e�#���ddlZddlmZddlZddlmZddlmZddlmZddlmZddlmZddl	m
Z
mZGd�d	e�Z
Gd
�dejj�Zejj#de�y)
�N)�
quote_plus)�config)�log)�progress)�util)�BackendException�FatalBackendExceptionc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�B2ProgressListenerc��y�N���selfs �>/usr/lib/python3/dist-packages/duplicity/backends/b2backend.py�	__enter__zB2ProgressListener.__enter__*����c��||_yr
)�total_byte_count)rrs  r�set_total_bytesz"B2ProgressListener.set_total_bytes-s
�� 0��rc�D�tj||j�yr
)r�report_transferr)r�
byte_counts  r�bytes_completedz"B2ProgressListener.bytes_completed0s��� � ��T�-B�-B�Crc��yr
rrs r�closezB2ProgressListener.close3rrc��yr
r)r�exc_type�exc_val�exc_tbs    r�__exit__zB2ProgressListener.__exit__6rrN)�__name__�
__module__�__qualname__rrrrr"rrrrr)s��
�1�D�
�
rrc�:�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
�	B2Backendz4
    Backend for BackBlaze's B2 storage service
    c
��tjjj||�	ddlm}|j
d�}|D�cgc]
}t|���c}|_	ddl
m}ddl
m}ddl
m}||��|_d
|j8_|j<}	|j?�}
|j@jCdd�j
d�D�cgc]
}|dk7s�	|��c}|_"|jDr<|jDjGd�|_|jDjGd�}nt5d��djI|jDD�cgc]}|�d���	c}�|_ |j6jKd|	|
�	tMjNd|j@�d|�d|j6jPjS��d�tLjT�	|j6j[|�|_.tMjNdtLjT�ycc}w#t$r}gd�|_Yd}~���d}~wwxYw#t$r�	ddlm}ddlm}dd	lmaddlm}|jgd
�krddlmanK#t$r?	ddlm}ddlm}dd	lmaddlm}ddlman#t$r}t5d��d}~wwxYwYnwxYwY��rwxYwcc}wcc}w#tV$r^tMjNd|j@�d|�d|j6jPjY��d�tLjT�Y��gwxYw#|$re	tMjNdtLjT�|j6j_|d�|_.Yy#t$r}tad��d}~wwxYwwxYw)zA
        Authorize to B2 api and set up needed variables
        r)�__version__�.)rrrN)�B2Api)�InMemoryAccountInfo)�NonExistentBucket)�DownloadDestLocalFile���	r)�FileVersionInfoFactoryz5B2 backend requires B2 Python SDK (pip install b2sdk)�B2�@�/�zB2 requires a bucket name�
productionzB2 Backend (path= z
, bucket= z, recommended_part_size= �)z, minimum_part_size= zBucket foundzBucket not found, creating one�
allPrivatezBucket cannot be created)1�	duplicity�backend�Backend�__init__�b2sdkr)�split�int�v_num�	Exception�b2sdk.v2r+r,�b2sdk.v2.exceptionr-�ImportError�b2sdk.v1r.�b2sdk.v1.exception�b2sdk.v1.file_versionr2�	b2sdk.api�b2sdk.account_info�b2sdk.download_dest�b2sdk.exception�b2sdk.file_versionr�service�
parsed_url�hostname�username�get_password�path�replace�	url_parts�pop�join�authorize_accountr�Log�account_info�get_recommended_part_size�INFO�AttributeError�get_minimum_part_size�get_bucket_by_name�bucket�
create_bucketr	)
rrO�VERSION�v_split�x�er+r,r-�
account_id�account_key�bucket_name�url_parts
             rr=zB2Backend.__init__?s8��	���!�!�*�*�4��<�	#�4��m�m�C�(�G�*1�2�Q�#�a�&�2�D�J�#	d�&�4�
�D�0�2�3���#'���� ��(�(�
��'�'�)��%/�_�_�%<�%<�S�#�%F�%L�%L�S�%Q�]��UV�Z\�U\�!�]����>�>� �N�N�.�.�q�1�D�M��.�.�,�,�Q�/�K�"�#>�?�?��G�G�D�N�N�K���z��^�K�L��	����&�&�|�Z��M�	��G�G�$�T�Y�Y�K�z�+��G*�*.�,�,�*C�*C�*]�*]�*_�)`�`a�c����
�	H��,�,�9�9�+�F�D�K��G�G�N�C�H�H�-��O3���	#�"�D�J�J��	#���	d�
d�*�8����:�:�	�)�L���
d�d�/������#�d�*�+b�c�c��d���
d��	d��J^��L���	��G�G�$�T�Y�Y�K�z�+��G&�&*�l�l�&?�&?�&U�&U�&W�%X�XY�[����
�	��!�	H�
H����8�#�(�(�C�"�l�l�8�8��l�S�����
H�+�,F�G�G��
H��		H�s��H>�H9�H>�"I� 
K*�+K*�#K/�AK4�4AM�9H>�>	I�	I�I�	K'�(/J�K'�	K �"K�K �	K�
K�K�K �K'�K � K'�&K'�4A#M�M�O�$AN+�+	O�4N?�?O�Oc���tjd|jtj|�z�dtj|j
���tj�|jgd�krZ|jjt|jtj|�zd�t|j
��y|jjt|jtj|�zd��}	|j|j�y#t$r%}|j|j
�Yd}~yd}~wwxYw)z8
        Download remote_filename to local_path
        zGet: � -> )r0�rr5N)rrYrS�os�fsdecode�namer\rAr`�download_file_by_namerr.�save_to�uc_namerB)r�remote_filename�
local_path�dfres     r�_getzB2Backend._get�s���	����D�I�I����O� <�<�=�T�"�+�+�j�o�o�B^�A_�`��H�H�	
��:�:�
�"��K�K�-�-��4�9�9�r�{�{�?�'C�C�S�I�%�j�o�o�6�
�
���2�2�:�d�i�i�"�+�+�Ve�Jf�>f�hk�3l�m�B�
,��
�
�:�-�-�.���
,��
�
�:�?�?�+�+��
,�s�D5�5	E#�>E�E#c	��tjdtj|j��d|j
tj|�z��tj�|jjtj|j�t|j
tj|�zd�dt���y)z5
        Copy source_path to remote_filename
        zPut: rkr5zapplication/pgp-encrypted)�content_type�progress_listenerN)rrYrmrnrorSr\r`�upload_local_filerr)r�source_pathrss   r�_putzB2Backend._put�s���	����B�K�K�� 0� 0�1�2�$�t�y�y�2�;�;��C_�7_�6`�a��H�H�	
�	
���%�%��K�K��(�(�)��t�y�y�2�;�;��#?�?��E�4�0�2�		&�	
rc��|jj|j�D��cgc]'\}}|jt	|j�d��)c}}Scc}}w)z-
        List files on remote server
        N)r`�lsrS�	file_name�len)r�file_version_info�folder_names   r�_listzB2Backend._list�sP��59�K�K�N�N�4�9�9�4M�
�0�"�K�
�'�'��D�I�I��(8�9�
�	
��
s�,Ac��|jtj|�z}tjd|��tj
�tjr|jj|�y|jt|d��}|jj|j|j�y)z4
        Delete filename from remote server
        zDelete: r5N)rSrmrnrrYr\r�
b2_hide_filesr`�	hide_file�	file_infor�delete_file_version�id_r)r�filename�
full_filenamer�s    r�_deletezB2Backend._delete�s����	�	�B�K�K��$9�9�
����(�=�/�*�C�H�H�5�����K�K�!�!�-�0� $���z�-��/M� N���K�K�+�+�,=�,A�,A�CT�C^�C^�_rc�T�tjd|j�tj|���tj
�|j
t|jtj|�zd��}d|�"|j�t|j�iSdiS)z+
        Get size info of filename
        zQuery: r5�size���)
rrYrSrmrnr\r�rr�r@)rr�r�s   r�_queryzB2Backend._query�s���	���'�$�)�)��R�[�[��%:�$;�<�c�h�h�G� �N�N�:�d�i�i�"�+�+�h�BW�6W�Y\�+]�^��� �,�1B�1G�1G�1S��)�.�.�/�
�	
��
�	
rc�t�|jgd�k\r|jj|�S|jjjj|jj|d|j�}|dD]*}tj|�}|j|k(s�(|cStd��)Nr/r0�fileszFile not found)rAr`�get_file_info_by_name�api�session�list_file_namesr�rSr2�from_api_responserr)rr��response�entryr�s     rr�zB2Backend.file_info�s����:�:��"��;�;�4�4�X�>�>��{�{���.�.�>�>�t�{�{���PX�Z[�]a�]f�]f�g�H�!�'�*�
-��$:�$L�$L�U�$S�!�$�.�.�(�:�,�,�
-�#�#3�4�4rN)r#r$r%�__doc__r=rvr|r�r�r�r�rrrr'r':s.���YH�v,�,

�
�`�

�	5rr'�b2)rm�urllib.parser�duplicity.backendr:rrrr�duplicity.errorsrr	�objectrr;r<r'�register_backendrrr�<module>r�sc��4
�#��������
��
�"p5�	�!�!�)�)�p5�f
���"�"�4��3r

Zerion Mini Shell 1.0