%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�2eg���dZddlZddlZddlZddlZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlZ
ddl
mZddl
mZddl
mZddl
mZddl
mZddl
mZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZiaiadagZ d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'Gd�de(�Z)d�Z*d�Z+d d�Z,Gd�de(�Z-Gd�de(�Z.y)!zq
Provides a common interface to all backends and certain sevices
intended to be used by the backends themselves.
�N)�config)�dup_temp)�file_naming)�log)�path)�util)�BackendException)�ConflictingScheme)�FatalBackendException)�InvalidBackendURL)�TemporaryLoadException)�UnsupportedBackendScheme)�exception_tracebackc��tjjd}|jd�sJtjj��t	tj|��}|D]^}|jd�rK|dd}d|��}	t|�d}tjtd
�||fztj��_�`y#t$r&dttj�d	���}Y�dwxYw)z�
    Import files in the duplicity/backends directory where
    the filename ends in 'backend.py' and ignore the rest.

    @rtype: void
    @return: void
    rzduplicity/backendsz
backend.pyN���zduplicity.backends.�	SucceededzFailed: �zImport of %s %s)�	duplicity�backends�__path__�endswith�sorted�os�listdir�
__import__�	Exception�str�sys�exc_infor�Log�_�INFO)r�files�fn�imp�ress     �3/usr/lib/python3/dist-packages/duplicity/backend.py�import_backendsr(Gs������&�&�q�)�D��4�=�=�-�.�K�	�0B�0B�0K�0K�K�.��2�:�:�d�#�$�E����
�;�;�|�$��C�R��B�'��t�,�C�
:��3��!��
�G�G�A�'�(�C��:�5�s�x�x�@�����
:� ��S�\�\�^�A�%6�!7� 8�9��
:�s�
C�,D�?Dc�h�t|�sJd��|tvrtd|�d���|t|<y)a�
    Register a given backend factory responsible for URL:s with the
    given scheme.

    The backend must be a callable which, when called with a URL as
    the single parameter, returns an object implementing the backend
    protocol (i.e., a subclass of Backend).

    Typically the callable will be the Backend subclass itself.

    This function is not thread-safe and is intended to be called
    during module importation or start-up.
    � backend factory must be callablezthe scheme �) already has a backend associated with itN)�callable�	_backendsr
��scheme�backend_factorys  r'�register_backendr1as?�� �O�$�H�&H�H�$�
����+�f�X�5^� _�`�`�'�I�f��c�h�t|�sJd��|tvrtd|�d���|t|<y)a�
    Register a given backend factory responsible for URL:s with the
    given scheme prefix.

    The backend must be a callable which, when called with a URL as
    the single parameter, returns an object implementing the backend
    protocol (i.e., a subclass of Backend).

    Typically the callable will be the Backend subclass itself.

    This function is not thread-safe and is intended to be called
    during module importation or start-up.
    r*zthe prefix r+N)r,�_backend_prefixesr
r.s  r'�register_backend_prefixr5ysA�� �O�$�H�&H�H�$�
�"�"��+�f�X�5^� _�`�`� /��f�r2c�^�tjdtj|��d�d|�S)zI
    strip the prefix from a string e.g. par2+ftp://... -> ftp://...
    z(?i)^z\+�)�re�sub�escape)�
url_string�
prefix_schemes  r'�strip_prefixr=�s*���6�6�E�"�)�)�M�2�3�3�7��j�I�Ir2c�4�t|�}|jryy)zD
    @return Whether the given string looks like a backend URL.
    TF)�	ParsedUrlr/)r;�pus  r'�is_backend_urlrA�s��
�:�	�B�
�y�y��r2c���t|�syt|�}|jsJd��d}tD]6}|j	|�d��s�t|}tt||��}n|�0|jtvrt|��t|j}	||�S#t$r6ttd�ttj�d�z��wxYw)z�
    Find the right backend class instance for the given URL, or return None
    if the given string looks like a local path rather than a URL.

    Raise InvalidBackendURL if the URL is not a valid URL.
    Nz3should be a backend url according to is_backend_url�+z Could not initialize backend: %sr)rAr?r/r4�
startswithr=r-r�ImportErrorr	r!rrr)r;r@�factory�prefixs    r'�get_backend_objectrH�s����*�%��
�:�	�B�
�9�9�K�K�K�9��G�#���� � �F�8�1��.�'��/�G��<�
�F�;�<�B��	���
�9�9�I�%�*�:�6�6���	�	�*�G�_��r�{����_��q�!C�D�s�3�<�<�>�Z[�K\�G]�]�^�^�_�s�B'�'?C&c�6�t|�}|rt|�}|S)z�
    Instantiate a backend suitable for the given URL, or return None
    if the given string looks like a local path rather than a URL.

    Raise InvalidBackendURL if the URL is not a valid URL.
    )rH�BackendWrapper)r;�objs  r'�get_backendrL�s ���Z�
(�C�
��S�!���Jr2c�"�eZdZdZd�Zd�Zd�Zy)r?aw
    Parse the given URL as a duplicity backend URL.

    Returns the data of a parsed URL with the same names as that of
    the standard urlparse.urlparse() except that all values have been
    resolved rather than deferred.  There are no get_* members.  This
    makes sure that the URL parsing errors are detected early.

    Raise InvalidBackendURL on invalid URL's
    c���||_ttj_	tjj	|�}	|j|_	|j|_	|j|_	|jr.tjj|j�|_		|j|_|jr/tjj|j�|_nd|_	|j|_|jr/tjj|j�|_nd|_	|j|_
	|j|_|jr/tjj|j�|_nd|_i|_d|_	|j"|_|jtvr�|jr/d|j�|j��|_	d|_d|_
nJ|jj)d�s/|jj)d�rd|j��|_	|jsy|jtvr|jst
d|����|jtvr7|jj)d�st
d|j�d|����yy#t
$rt
d|����wxYw#t
$rt
d|����wxYw#t
$rt
d|����wxYw#t
$rt
d|����wxYw#t
$rt
d|����wxYw#t
$rt
d|����wxYw#t
$rt
d|����wxYw#t
$rt
d|����wxYw#t
$r�|jd	vrnyd
|jvr t%j&d|j�sKt
d|�d
d
|jv�dt%j&d|j��d|j����Y���wxYw)NzSyntax error in: zSyntax error (scheme) in: zSyntax error (netloc) in: zSyntax error (path) in: zSyntax error (username) in: zSyntax error (password) in: zSyntax error (hostname) in: zSyntax error (query) in: )�rclone�rsyncz::[^:]*$zSyntax error (port) in: z Az Bz::[^:]+$z Cz//r7�/zGMissing hostname in a backend URL which requires an explicit hostname: z5missing // - relative paths not supported for scheme z: )r;�uses_netloc�urllib�parse�urlparserrr/�netlocr�unquote�username�password�hostname�query�parse_qs�
query_args�portr8�searchrD)�selfr;r@s   r'�__init__zParsedUrl.__init__�s��$���$/���� �	F����&�&�z�2�B�	O��)�)�D�K�	O��)�)�D�K�	M����D�I��y�y�"�L�L�0�0����;��	�	Q��K�K�D�M��=�=�"�L�L�0�0����=�D�M� �D�M�	Q��K�K�D�M��=�=�"�L�L�0�0����?�D�M� �D�M�	Q��K�K�D�M�	N����D�J��:�:�$�l�l�3�3�D�J�J�?�D�O��D�J� �D�O���	�
	����D�I��;�;�k�)��{�{� ����
�d�i�i�[�9��	� ��� $��
��Y�Y�)�)�$�/�D�I�I�4H�4H��4M� �����,��	��{�{���;�;�+�%�d�m�m�#�]�^h�]i�j��
�
�;�;�k�)�$�)�)�2F�2F�t�2L�#�K�D�K�K�=�XZ�[e�Zf�g��
�3M�)��s�	F�#�&7�
�|�$D�E�E�	F��
�	O�#�&@���$M�N�N�	O��
�	O�#�&@���$M�N�N�	O���	M�#�&>�z�l�$K�L�L�	M��
�	Q�#�&B�:�,�$O�P�P�	Q���	Q�#�&B�:�,�$O�P�P�	Q���	Q�#�&B�:�,�$O�P�P�	Q��
�	N�#�&?�
�|�$L�M�M�	N���	��{�{�j�(������,����:�t���1W�'�.�z�l�"�W����=S�<T�U��	�	�*�d�k�k�:�;�2�d�k�k�]�L����	�ss�K9�L�L/�&AM
�2M%�N�N�,N6�O�9L�L,�/M�
M"�%M=�N�N3�6O�BQ&�%Q&c��|jS�N)r;�r`s r'�geturlzParsedUrl.geturlMs�����r2c�@�tjj|�Src)r�backend�strip_auth_from_urlrds r'�
strip_authzParsedUrl.strip_authPs��� � �4�4�T�:�:r2N)�__name__�
__module__�__qualname__�__doc__rareri�r2r'r?r?�s��	�j�X�;r2r?c�P�tjdd|j��}|S)zCReturn a URL from a urlparse object without a username or password.z^([^:/]+://)(.*@)?(.*)z\1\3)r8r9re)�
parsed_url�	clean_urls  r'rhrhTs&�����/��*�:K�:K�:M�N�I��r2c��t|t�r3|jtjj
k7r|jSt
|d�r.|j||�xstjj
St
|d�r�|jtjk(rtjjS|jtjk(rtjjS|jtjk(rtjjStjj
S)N�_error_code�errno)�
isinstancer	�coder�	ErrorCode�
backend_error�hasattrrsrt�EACCES�backend_permission_denied�ENOENT�backend_not_found�ENOSPC�backend_no_space)rg�	operation�es   r'�_get_code_from_exceptionr�[s����!�%�&�1�6�6�S�]�]�5P�5P�+P��v�v�
�	��-�	(��"�"�9�a�0�O�C�M�M�4O�4O�O�	��G�	��7�7�e�l�l�"��=�=�:�:�:�
�W�W����
$��=�=�2�2�2�
�W�W����
$��=�=�1�1�1��=�=�&�&�&r2c������fd�}|S)Nc�������fd�}|S)Nc���tjj�
d�\}}tdtjdz�D]
}	�|g|���cSy#t
$r}|a|s	|cYd}~cS|�d}~wt$�r}|a|s	|cYd}~cStjtd�t�z�|tjk(}t|j�
|�}|tjjk(rd}|r��r�d�}dj!�
g|D�	cgc]}	|	s�t#|	t$�s�||	��� ncc}	wc}	z�}
tj&td�||j(j*t-j.|�fz||
��nVtj0td	��j*||j(j*t-j.|�fz�|s�t#|t2�r't5j6d
tj8z�n#t5j6tj8�t;|jd�r|jj=�Yd}~��6d}~wwxYw)N)TNrzBacktrace of previous error: %sTc��t|tj�rtj|j
�Stj|�Src)rur�ROPathrr:�uc_name)�fs r'�
make_filenamezFretry.<locals>.outer_retry.<locals>.inner_retry.<locals>.make_filename�s1��#-�a����#=�+/�;�;�q�y�y�+A�$A�+/�;�;�q�>�$9r2� z#Giving up after %s attempts. %s: %s)rv�extraz#Attempt of %s Nr. %s failed. %s: %s��_retry_cleanup)r�are_errors_fatal�get�range�num_retriesr�_last_exceptionrr�Debugr!rr�rgrwr}�joinrur�
FatalError�	__class__rjr�uexc�Warnr
�time�sleep�backend_retry_delayryr�)r`�args�errors_fatal�errors_default�nr��at_endrvr��xr��fatalr$r�s           ���r'�inner_retryz/retry.<locals>.outer_retry.<locals>.inner_retryos���+1�+B�+B�+F�+F�y�R^�+_�(�L�.��1�f�0�0�1�4�5�4
>��3>��d�?�T�?�*�4
>��-� �&'�O�'�-�-� ��� �)>�&'�O�'�-�-��	�	�!�$E�"F�I\�I^�"^�_�!"�f�&8�&8�!8��7����i�QR�S���3�=�=�#B�#B�B�&*�F�!�e�:�%(�H�H�!*���.l�A�RS�Xb�cd�fi�Xj�}�Q�/?�.l��.l� l�%�E� �N�N� !�"G� H�A�q�{�{�Oc�Oc�ei�en�en�op�eq�Kr� r�%)�&+�� �H�H� !�"G� H�#%�;�;��1�;�;�3G�3G����ST��"V�!W�� &�)�!�-C�D� $�
�
�1�v�/I�/I�+I� J� $�
�
�6�+E�+E� F�&�t�|�|�5E�F� $��� ;� ;� =���S)>�sV�A�	I=�A+�!I=�)A+�+
I=�8I8�=I=�B
I8�D3�D3�(
D3�2EI8�8I=rn)r$r�r�r�s` ��r'�outer_retryzretry.<locals>.outer_retryns���7	>�r�r2rn)r�r�r�s`` r'�retryr�ks���:�x�r2c�:�eZdZdZd�Z	dZd�Zd�Zd�Z	iZ	d�Z
y)	�BackendzU
    See README in backends directory for information on how to write a backend.
    c��||_yrc)rp)r`rps  r'razBackend.__init__�s	��$��r2Tc�v�|jjr|jjS	tjd}|S#t$rl|j
rZt
jd|jj�d|jj�d��}|tjd<Y|Sd}Y|SwxYw)a

        Return a password for authentication purposes. The password
        will be obtained from the backend URL, the environment, by
        asking the user, or by some other method. When applicable, the
        result will be cached for future invocations.
        �FTP_PASSWORDzPassword for '�@z': N)	rprYr�environ�KeyError�use_getpass�getpassrXrZ)r`rYs  r'�get_passwordzBackend.get_password�s����?�?�#�#��?�?�+�+�+�	 ��z�z�.�1�H����
�	 ����"�?�?�^�D�O�O�<T�<T�;U�UV�W[�Wf�Wf�Wo�Wo�Vp�ps�+t�u��-5��
�
�>�*��� ����
	 �s�A�A,B8�2B8�7B8c�`�|jjrtjdd|�S|S)aD
        Remove password from commandline by substituting the password
        found in the URL, if any, with a generic place-holder.

        This is intended for display purposes only, and it is not
        guaranteed that the results are correct (i.e., more than just
        the ':password@' may be substituted.
        z(:([^\s:/@]+)@([^\s@]+))z	:*****@\3)rprYr8r9)r`�commandlines  r'�munge_passwordzBackend.munge_password�s+���?�?�#�#��6�6�5�|�[�Q�Q��r2c��ddlm}m}tj|d�|d<||||d��}|j�\}}|j||fS)z�
        For internal use.
        Execute the given command line, interpreted as a shell command.
        Returns int Exitcode, string StdOut, string StdErr
        r)�Popen�PIPET)�stdout�stderr�universal_newlines)�
subprocessr�r�r�which�communicate�
returncode)r`r�r�r��pr�r�s       r'�__subprocess_popenzBackend.__subprocess_popen�sO��	
�
�*�*�T�!�W�%��Q���$�t�D�T�J����������|�|�V�V�+�+r2c
���ddl}t|ttf�rdj	|�}|}n|}|j|�}|j
|�}tjtd�|z�|j|�\}}}|dk7r&	|j|d}|j|�	y|||fS#ttf$rtd|||�d|�d�fz��wxYw)z�
        Execute the given command line with error check.
        Returns int Exitcode, string StdOut, string StdErr

        Raise a BackendException on failure.
        rNr�zReading results of '%s')rr7r7z0Error running '%s': returned %d, with output:
%s�
)�shlexru�list�tupler��splitr�r�Infor!�_Backend__subprocess_popen�popen_breaks�indexr��
ValueErrorr	)	r`r�r��logstrr��resultr�r��ignoress	         r'�subprocess_popenzBackend.subprocess_popen�s��	��k�D�%�=�1��X�X�k�*�F��D� �F��;�;�{�+�D��$�$�V�,������,�-��6�7�!%�!8�!8��!>������Q�;�
��+�+�D��G�4���
�
�f�%�>� �
�v�v�%�%��	�j�)�
�&�G�6�SY�^d�]e�eg�hn�go�oq�[r�Js�s���
�s�$B9�9'C N)rjrkrlrmrar�r�r�r�r�r�rnr2r'r�r��s6���%�T��K��(�,�"P��L�&r2r�c�N�eZdZdZd�Zd�Zedd��dd��Zed	d��dd
��Zedd��d��Z	ed
d��d��Z
d�Zd�Zd�Z
edd��d��Zedd��d��Zd�Zedd��d��Zedd��d��Zd�Zdd�Zdd�Zy)rJz^
    Represents a generic duplicity backend, capable of storing and
    retrieving files.
    c��||_yrc)rg)r`rgs  r'razBackendWrapper.__init__s	����r2c���t|jd�rQtjt	d�tj|�z�|jj||�yt��)N�_putz
Writing %s)	ryrgrr�r!r�fsdecoder��NotImplementedError�r`�source_path�remote_filenames   r'�__do_putzBackendWrapper.__do_putsK���4�<�<��(��H�H�Q�|�_�r�{�{�?�'C�C�D��L�L���k�?�;�%�'�'r2�putT)r�Nc�L�|s|j�}|j||�y)z�
        Transfer source_path (Path object) to remote_filename (string)

        If remote_filename is None, get the filename from the last
        path component of pathname.
        N)�get_filename�_BackendWrapper__do_putr�s   r'r�zBackendWrapper.put s#���)�6�6�8�O��
�
�k�?�3r2�movec��|s|j�}t|jd�r/|jj||�dur|j	�y|j||�|j
�y)z�
        Move source_path (Path object) to remote_filename (string)

        Same as put(), but unlinks source_path in the process.  This allows the
        local backend to do this more efficiently using rename.
        �_moveFN)r�ryrgr��setdatar��deleter�s   r'r�zBackendWrapper.move,se���)�6�6�8�O��4�<�<��)��|�|�!�!�+��?�u�L��#�#�%���
�
�k�?�3����r2r�c��t|jd�r^|jj||�|j�|j	�s!tt
d�|jz��yt��)z0Retrieve remote_filename and place in local_path�_getz0File %s not found locally after get from backendN)	ryrgr�r��existsr	r!r�r�)r`r��
local_paths   r'r�zBackendWrapper.get=sk���4�<�<��(��L�L���o�z�:���� ��$�$�&�&�q�)^�'_�bl�bt�bt�'t�u�u�'�&�'�'r2r�c��d�}t|jd�r.|jj�D�cgc]
}||���c}St��cc}w)zL
        Return list of filenames (byte strings) present in backend
        c�P�t|t�rtj|�S|S)z+Convert a (maybe unicode) filename to bytes)rurr�fsencode)�filenames r'�tobytesz$BackendWrapper.list.<locals>.tobytesNs"���(�C�(��{�{�8�,�,��r2�_list)ryrgr�r�)r`r�r�s   r'r�zBackendWrapper.listHsI��	 ��4�<�<��)�)-���(:�(:�(<�=�1�G�A�J�=�=�%�'�'��>s�Ac�f�t|jd�r|jj|�Sy)�s
        Manages remote access before downloading files
        (unseal data in cold storage for instance)
        �pre_process_downloadN)ryrgr�)r`r�s  r'r�z#BackendWrapper.pre_process_download_s-��
�4�<�<�!7�8��<�<�4�4�_�E�E�9r2c�f�t|jd�r|jj|�Sy)r��pre_process_download_batchN)ryrgr�)r`�remote_filenamess  r'r�z)BackendWrapper.pre_process_download_batchgs.��
�4�<�<�!=�>��<�<�:�:�;K�L�L�?r2c���t|t�rJ�t|jd�r|j	|�yt|jd�r|D]}|j|��yt
��)zN
        Delete each filename in filename_list, in order if possible.
        �_delete_list�_deleteN)ru�bytesryrg�_do_delete_list�
_do_deleter�)r`�
filename_listr�s   r'r�zBackendWrapper.deleteosd���m�U�3�3�3��4�<�<��0�� � ��/�
�T�\�\�9�
-�)�
*������)�
*�&�'�'r2r�Fc�Z�|r)|dd}|jj|�|dd}|r�(yy)N�d)rgr�)r`r��sublists   r'r�zBackendWrapper._do_delete_list|s4���#�D�S�)�G��L�L�%�%�g�.�)�#�$�/�M�r2c�:�|jj|�yrc)rgr�)r`r�s  r'r�zBackendWrapper._do_delete�s�������X�&r2c�&�i}t|jd�r|j|�}|�4i}n1t|jd�r|D]}|j|�||<�|D],}||vs||�i||<dD]}||j	|d���.|S)zF
        Return metadata about each filename in filename_list
        �_query_listN�_query)�size)ryrg�_do_query_list�	_do_query�
setdefault)r`r��infor��metadatas     r'�
query_infozBackendWrapper.query_info�s������4�<�<��/��&�&�}�5�D��|���
�T�\�\�8�
,�)�
:��!%����!9��X��
:�
&�	:�H��t�#�t�H�~�'=�!#��X��$�
:���X��)�)�(�D�9�
:�	:��r2r[c�D�|jj|�}|�i}|Src)rgr�)r`r�rs   r'rzBackendWrapper._do_query_list�s%���|�|�'�'�
�6���<��D��r2c���	|jj|�S#t$rD}t|jd|�}|tj
jk(r	ddicYd}~S|�d}~wwxYw)Nr[r���)rgrrr�rrwr})r`r�r�rvs    r'rzBackendWrapper._do_query�s_��	��<�<�&�&�x�0�0���	�+�D�L�L�'�1�E�D��s�}�}�6�6�6���|�#����	�s ��	A*�7A%�A*�#A%�%A*c�f�t|jd�r|jj�yy)z�
        Close the backend, releasing any resources held and
        invalidating any file objects obtained from the backend.
        �_closeN)ryrgrrds r'�closezBackendWrapper.close�s'��
�4�<�<��*��L�L���!�+r2c���|stj|�}|sJd��tj|�}|j	||�|j�|j
d�S)z�
        Return fileobject opened for reading of filename on backend

        The file will be downloaded first into a temp file.  When the
        returned fileobj is closed, the temp file will be deleted.
        zFilename not correctly parsed�rb)rrTr�new_tempduppathr�r��filtered_open_with_delete)r`r��parseresults�tdps    r'�get_fileobj_readzBackendWrapper.get_fileobj_read�s]���&�,�,�X�6�L��@�!@�@�<��&�&�|�4������3�����
��,�,�T�2�2r2c�n�|j||�}|j�}|j�rJ�|S)zL
        Retrieve a file from backend, process it, return contents.
        )r�readr
)r`r�r�fin�bufs     r'�get_datazBackendWrapper.get_data�s4���#�#�H�l�;���h�h�j���9�9�;����
r2rc)rjrkrlrmrar�r�r�r�r�r�r�r�r�r�r�rrrr
rrrnr2r'rJrJs���
�(��5���	4��	4��6������ �5���(��(��6���(��(�,F�M�(��8�5�!�0�"�0��8�5�!�'�"�'��.�7�%� ��!���7�%� ��!��"�
3�r2rJ)T)/rmrtr�rr8�socketrr��urllib.errorrS�urllib.parse�urllib.request�duplicity.backendsrrrrrrr�duplicity.errorsr	r
rrr
r�duplicity.utilrr-r4r�rRr(r1r5r=rArHrL�objectr?rhr�r�r�rJrnr2r'�<module>r"s���,�

��	�	�
�
��������!����-�.�2�.�3�5�.��	��������4(�00�0J�
� _�F
�|;��|;�~�
'� ?�D`&�f�`&�FH�V�Hr2

Zerion Mini Shell 1.0