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

�

�2ex����ddlZddlZddlZddlZddlmZddlZddlZ	ddl	m
Z
ddlmZGd�de	jj�Ze	jj!de�y)�N)�Path)�log)�BackendExceptionc�(�eZdZdZd�Zd�Zd�Zd�Zy)�SlateBackendz
    Backend for Slate
    c��tjjj||�t	j
d�dtjj�vrtd��tjd|_
dtjj�vrd|_nddk(rd|_nd|_tjdd	d
ii�}dd|j��d
�}tjd|||j��}|j std��|j#�j%d�d|_y)Nzloading slate backend...�
SLATE_API_KEYzeYou must set an environment variable SLATE_API_KEY
                as the value of your slate API key�SLATE_SSL_VERIFYT�0F�data�private�true�application/json�Basic �zContent-Type�
Authorization�https://slate.host/api/v1/get�r�headers�verify�&Slate backend requires a valid API key�/���)�	duplicity�backend�Backend�__init__r�Debug�os�environ�keysr�keyr�json�dumps�requests�post�ok�geturl�split�slate_id)�self�
parsed_urlrr�responses     �A/usr/lib/python3/dist-packages/duplicity/backends/slatebackend.pyrzSlateBackend.__init__'s�����!�!�*�*�4��<��	�	�,�-��"�*�*�/�/�"3�3�"�6��
�
�z�z�/�2�D�H��R�Z�Z�_�_�%6�6��D�K�!�S�(�#���"����z�z�6�I�v�#6�7�8��.�%�d�h�h�Z�0�
��
�=�=�+����;�;�	
���{�{�"�#K�L�L�"�)�)�+�1�1�#�6�r�:��
�c��tjdddii�}dd|j��d�}tjdt|j����tjd|jd	����ttj|��}ttj|j��}t|j�jd
�rLtjd�tjt|�t|j|���}tjd�d
d|j��i}|tt|�d�i}tjdt|j!�����t#j$d|j&��||��}tjd�|j(st+d|����tjd|j&���t|�j-d�rtj.t|��yy)Nrr
rrrrzsource_path.name: zremote_filename: �utf8�mktempzcopying temp file for uploadr-r�rbz-------------------FILECHECK: z&https://uploads.slate.host/api/public/)�url�filesrzresponse handledz6An error occurred whilst attempting to upload a file: z,File successfully uploaded to slate with id:zdifftar.gpg)r#r$r"rr�str�name�decoder�fsdecoder�
startswith�shutil�move�	with_name�openr!r%r&r*r'r�endswith�remove)	r+�source_path�remote_filenamerr�rem_filename�srcr5r-s	         r.�_putzSlateBackend._putKs����z�z�6�I�v�#6�7�8��.�%�d�h�h�Z�0�
��
	�	�	�&�s�;�+;�+;�'<�&=�>�?��	�	�%�o�&<�&<�V�&D�%E�F�G��2�;�;��7�8���2�;�;�{�/�/�0�1���s�x�x�=�#�#�H�-��I�I�4�5��+�+�c�#�h��C�M�M�,�,G�(H�I�C��	�	�*��"�f�T�X�X�J�$7�8���t�C��H�d�3�4���	�	�2�3�u�z�z�|�3D�2E�F�G��=�=�8�����H���
��
	�	�	�$�%��{�{�"�%[�\d�[e�#f�g�g��I�I�D�T�]�]�O�T�U��s�8���]�+��I�I�c�#�h��,r/c��tjd|j���tjdddii�}dd|j
��d�}t
jd|||j�	�}|jstd
��|j�d}g}|D]Z}|d|jk(r$|dd
}|D]}|j|d���9tjd|j����\|S)Nz
Slate ID: rr
rrrrrrr�slates�id�objectsr7zCould not find slate with id: )rrr*r#r$r"r%r&rr'r�append)	r+rrr-rG�	file_list�slater5�fs	         r.�_listzSlateBackend._listns���	�	�J�t�}�}�o�.�/��z�z�6�I�v�#6�7�8��.�%�d�h�h�Z�0�
���=�=�+����;�;�	
���{�{�"�#K�L�L������*���	��	L�E��T�{�d�m�m�+��f�
�i�0���0�A��$�$�Q�v�Y�/�0��	�	�:�4�=�=�/�J�K�
	L��r/c���d}tjdddii�}dd|j��d�}tjd|||j
�	�}|j�d
}|D]s}|d|jk(s�d}|dd
D]Q}	|	d|jd�k(r|	djd�d}
�Std|jd�zdz���u|std|j�d���	tjjd
��tj|j��t!j"d|
���y#t$$r}td��d}~wwxYw)NFrr
rrrrrrrGrHTrIr7r1r4rrz
The file 'z+' could not be found in the specified slatezA slate with id z does not existzhttp://ipfs.io/ipfs/zDownloaded file with cid: zCouldn't download file)r#r$r"r%r&rr*r8r)r�urllib�request�urlretrieverr9r7rr�	NameError)r+rB�
local_path�foundrrr-rGrL�obj�cid�es            r.�_getzSlateBackend._get�s������z�z�6�I�v�#6�7�8��.�%�d�h�h�Z�0�
��
�=�=�+����;�;�	
�������*���	�E��T�{�d�m�m�+��� ��=��3�	�C��6�{�o�&<�&<�V�&D�D�!�%�j�.�.�s�3�B�7���.�(�-�4�4�V�<�=�K�L���	�	��"�%5�d�m�m�_�O�#T�U�U�	=��N�N�&�&�)=�c�U�'C�R�[�[�Q[�Q`�Q`�Ea�b��I�I�2�3�%�8�9���	=�"�#;�<�<��	=�s�8AE�	E*�E%�%E*N)�__name__�
__module__�__qualname__�__doc__rrErNrY�r/r.rr"s���";�H! �F�>+=r/rrL)r#rr;�urllib.requestrP�pathlibrr%�duplicity.backendrr�duplicity.errorsrrrr�register_backendr^r/r.�<module>rdsU��*�	�
������-�V=�9�$�$�,�,�V=�r
���"�"�7�L�9r/

Zerion Mini Shell 1.0