https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/duplicity/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/duplicity/__pycache__/backend.cpython-310.pyc
o

��La<j�@s�dZddlmZe��ddlmZddlmZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"Zia#ia$da%gZ&dd�Z'dd�Z(dd�Z)dd�Z*dd�Z+dd�Z,d d!�Z-Gd"d#�d#e�Z.d$d%�Z/d&d'�Z0d/d)d*�Z1Gd+d,�d,e�Z2Gd-d.�d.e�Z3dS)0zq
Provides a common interface to all backends and certain sevices
intended to be used by the backends themselves.
�)�standard_library)�str)�range)�objectN)�dup_temp)�file_naming)�config)�log)�path)�util)�exception_traceback)�BackendException)�FatalBackendException)�TemporaryLoadException)�ConflictingScheme)�InvalidBackendURL)�UnsupportedBackendSchemec	Cs�tjjd}|�d�sJtjj��t�|�}|��|D]<}|�d�rX|dd�}d|f}zt|�d}WntyIdt	t
��d	�}Ynwt�
td
�||ftj�qqdS)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.%s�	SucceededzFailed: �zImport of %s %s)�	duplicity�backends�__path__�endswith�os�listdir�sort�
__import__�	Exceptionr�sys�exc_infor	�Log�_�INFO)r
�files�fn�imp�res�r(�3/usr/lib/python3/dist-packages/duplicity/backend.py�import_backendsPs"


��r*cC�2t|�sJd��|tvrtd|f��|t|<dS)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 callablez6the scheme %s already has a backend associated with itN)�callable�	_backendsr��scheme�backend_factoryr(r(r)�register_backendk��r2cCr+)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,z6the prefix %s already has a backend associated with itN)r-�_backend_prefixesrr/r(r(r)�register_backend_prefix�r3r5cCst�dt�|�dd|�S)zI
    strip the prefix from a string e.g. par2+ftp://... -> ftp://...
    z(?i)^z\+�)�re�sub�escape)�
url_string�
prefix_schemer(r(r)�strip_prefix�sr<cCst|�}|jr	dSdS)zD
    @return Whether the given string looks like a backend URL.
    TF)�	ParsedUrlr0)r:�pur(r(r)�is_backend_url�sr?cCs�t|�sdSt|�}|jsJd��d}tD]}|�|d�r+t|}tt||��}nq|dur>|jtvr9t|��t|j}z||�WStyXt	t
d�tt�
�d���w)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)r?r=r0r4�
startswithr<r.r�ImportErrorr
r"rrr )r:r>�factory�prefixr(r(r)�get_backend_object�s(�


�rEcCs&tjrd|}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.
    zgio+)r�use_giorE�BackendWrapper)r:�objr(r(r)�get_backend�srIc@s(eZdZdZdd�Zdd�Zdd�ZdS)	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
    cCs�||_ttj_ztj�|�}Wn
tytd|��wz|j|_Wn
ty0td|��wz|j|_Wn
tyDtd|��wz|j	|_	|j	rUtj�
|j	�|_	Wn
tyctd|��wz|j|_Wn
tywtd|��w|jr�tj�
|j�|_nd|_z|j|_Wn
ty�td|��w|jr�tj�
|j�|_nd|_z|j
|_
Wn
ty�td|��wz|j|_Wn
ty�td|��w|jr�tj�|j�|_nd|_i|_d|_z|j|_Wn1t�y|jd	vr�n!d
|jv�r	t�d|j��std|d
|jvt�d
|j�|jf��Ynw|jtv�rM|j�r9d|j|j	|_	d|_d|_
n|j	�d��sM|j	�d��rMd|j	|_	|j�sSdS|jtv�rc|j
�sctd|��|jtv�ry|j	�d��s{td|j|f��dSdS)NzSyntax error in: %szSyntax error (scheme) in: %szSyntax error (netloc) in: %szSyntax error (path) in: %szSyntax error (username) in: %szSyntax error (password) in: %szSyntax error (hostname) in: %szSyntax error (query) in: %s)�rclone�rsyncz::[^:]*$z&Syntax error (port) in: %s A%s B%s C%sz::[^:]+$z//r6�/zIMissing hostname in a backend URL which requires an explicit hostname: %sz;missing // - relative paths not supported for scheme %s: %s)r:�uses_netloc�urllib�parse�urlparserrr0�netlocr
�unquote�username�password�hostname�query�parse_qs�
query_args�portr7�searchrA)�selfr:r>r(r(r)�__init__�s����������

����
���zParsedUrl.__init__cCs|jS�N)r:�r[r(r(r)�geturl\szParsedUrl.geturlcCstj�|�Sr])r�backend�strip_auth_from_urlr^r(r(r)�
strip_auth_szParsedUrl.strip_authN)�__name__�
__module__�__qualname__�__doc__r\r_rbr(r(r(r)r=�s

lr=cCst�dd|���}|S)zCReturn a URL from a urlparse object without a username or password.z^([^:/]+://)(.*@)?(.*)z\1\3)r7r8r_)�
parsed_url�	clean_urlr(r(r)racsracCs�t|t�r|jtjjkr|jSt|d�r|�||�ptjjSt|d�rA|jtj	kr-tjj
S|jtjkr7tjjS|jtj
krAtjjStjjS)N�_error_code�errno)�
isinstancer
�coder	�	ErrorCode�
backend_error�hasattrrirj�EACCES�backend_permission_denied�ENOENT�backend_not_found�ENOSPC�backend_no_space)r`�	operation�er(r(r)�_get_code_from_exceptionjs

rxTcs��fdd�}|S)Ncs���fdd�}|S)Nc	
s�tj��d�\}}tdtjd�D]�}z�|g|�R�WSty:}z|a|s4|WYd}~S|�d}~wty�}z�|a|sO|WYd}~St�	t
d�t��|tjk}t|j
�|�}|tjjkrmd}|r��r�dd��d��g�fdd	�|D��}tjt
d
�||jjt�|�f||d�nt�t
d��j||jjt�|�f�|s�t|t�r�t�d
tj�nt�tj�t|j
d�r�|j
��WYd}~qd}~wwdS)N)TNrzBacktrace of previous error: %sTcSs"t|tj�rt�|j�St�|�Sr])rkr
�ROPathrr9�uc_name)�fr(r(r)�
make_filename�s
zFretry.<locals>.outer_retry.<locals>.inner_retry.<locals>.make_filename� cs"g|]
}|rt|t�r�|��qSr()rkr��.0�x�r|r(r)�
<listcomp>�s
��zCretry.<locals>.outer_retry.<locals>.inner_retry.<locals>.<listcomp>z#Giving up after %s attempts. %s: %s)rl�extraz#Attempt of %s Nr. %s failed. %s: %s��_retry_cleanup)r�are_errors_fatal�getr�num_retriesr�_last_exceptionrr	�Debugr"rrxr`rmrs�join�
FatalError�	__class__rcr�uexc�Warnrkr�time�sleep�backend_retry_delayror�)	r[�args�errors_fatal�errors_default�nrw�at_endrlr�)�fatalr%rvr�r)�inner_retry~sV�
�

���
�

���z/retry.<locals>.outer_retry.<locals>.inner_retryr()r%r��r�rv)r%r)�outer_retry}s3zretry.<locals>.outer_retryr()rvr�r�r(r�r)�retryzs5r�c@sDeZdZdZdd�Z	dZdd�Zdd�Zd	d
�Z	iZ	dd�Z
d
S)�BackendzU
    See README in backends directory for information on how to write a backend.
    cC�
||_dSr])rg)r[rgr(r(r)r\��
zBackend.__init__TcCsj|jjr|jjSztjd}W|Sty4|jr/t�d|jj|jjf�}|tjd<Y|Sd}Y|Sw)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 '%s@%s': N)	rgrTr�environ�KeyError�use_getpass�getpassrSrU)r[rTr(r(r)�get_password�s����zBackend.get_passwordcCs|jjrt�dd|�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)rgrTr7r8)r[�commandliner(r(r)�munge_password�s	zBackend.munge_passwordcCsJddlm}m}t�|d�|d<||||dd�}|��\}}|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�r(r(r)�__subprocess_popen�s
zBackend.__subprocess_popenc		Cs�ddl}t|ttf�rd�|�}|}n|}|�|�}|�|�}t�t	d�|�|�
|�\}}}|dkr]z|j|d}|�|�	WdSt
tfy\td|||d|df��w|||fS)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')rr6r6z0Error running '%s': returned %d, with output:
%s�
)�shlexrk�list�tupler��splitr�r	�Infor"�_Backend__subprocess_popen�popen_breaks�indexr��
ValueErrorr
)	r[r�r��logstrr��resultr�r��ignoresr(r(r)�subprocess_popen�s*



��
zBackend.subprocess_popenN)rcrdrerfr\r�r�r�r�r�r�r(r(r(r)r��sr�c@seZdZdZdd�Zdd�Zeddd�d.d
d��Zeddd�d.d
d��Zeddd�dd��Z	eddd�dd��Z
dd�Zdd�Zdd�Z
eddd�dd��Zeddd�dd ��Zd!d"�Zed#dd�d$d%��Zed#dd�d&d'��Zd(d)�Zd.d*d+�Zd.d,d-�Zd	S)/rGz^
    Represents a generic duplicity backend, capable of storing and
    retrieving files.
    cCr�r])r`)r[r`r(r(r)r\r�zBackendWrapper.__init__cCs<t|jd�rt�td�t�|��|j�||�dSt��)N�_putz
Writing %s)	ror`r	r�r"r�fsdecoder��NotImplementedError�r[�source_path�remote_filenamer(r(r)�__do_putszBackendWrapper.__do_put�putT)r�NcCs|s|��}|�||�dS)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�r(r(r)r�$szBackendWrapper.put�movecCsN|s|��}t|jd�r|j�||�dur|��dS|�||�|��dS)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�ror`r��setdatar��deleter�r(r(r)r�0szBackendWrapper.mover�cCsFt|jd�r |j�||�|��|��sttd�|j��dSt��)z0Retrieve remote_filename and place in local_path�_getz0File %s not found locally after get from backendN)	ror`r�r��existsr
r"rzr�)r[r��
local_pathr(r(r)r�As��zBackendWrapper.getr�cs2dd��t|jd�r�fdd�|j��D�St��)zL
        Return list of filenames (byte strings) present in backend
        cSst|t�r
t�|�S|S)z+Convert a (maybe unicode) filename to bytes)rkrr�fsencode)�filenamer(r(r)�tobytesRs

z$BackendWrapper.list.<locals>.tobytes�_listcsg|]}�|��qSr(r(r~�r�r(r)r�_sz'BackendWrapper.list.<locals>.<listcomp>)ror`r�r�r^r(r�r)r�Ms
zBackendWrapper.listcC�t|jd�r|j�|�SdS)�s
        Manages remote access before downloading files
        (unseal data in cold storage for instance)
        �pre_process_downloadN)ror`r�)r[r�r(r(r)r�c��z#BackendWrapper.pre_process_downloadcCr�)r��pre_process_download_batchN)ror`r�)r[�remote_filenamesr(r(r)r�kr�z)BackendWrapper.pre_process_download_batchcCsRt|t�rJ�t|jd�r|�|�dSt|jd�r&|D]}|�|�qdSt��)zN
        Delete each filename in filename_list, in order if possible.
        �_delete_list�_deleteN)rk�bytesror`�_do_delete_list�
_do_deleter�)r[�
filename_listr�r(r(r)r�ss�zBackendWrapper.deleter�FcCs4|r|dd�}|j�|�|dd�}|sdSdS)N�d)r`r�)r[r��sublistr(r(r)r��s
�zBackendWrapper._do_delete_listcCs|j�|�dSr])r`r�)r[r�r(r(r)r��szBackendWrapper._do_deletecCs�i}t|jd�r|�|�}|duri}nt|jd�r&|D]	}|�|�||<q|D]}||vs4||dur8i||<dD]
}||�|d�q:q(|S)zF
        Return metadata about each filename in filename_list
        �_query_listN�_query)�size)ror`�_do_query_list�	_do_query�
setdefault)r[r��infor��metadatar(r(r)�
query_info�s 
��zBackendWrapper.query_inforVcCs|j�|�}|duri}|Sr])r`r�)r[r�r�r(r(r)r��szBackendWrapper._do_query_listc
CsZz|j�|�WSty,}zt|jd|�}|tjjkr&ddiWYd}~S|�d}~ww)NrVr����)r`r�rrxr	rmrs)r[r�rwrlr(r(r)r��s��zBackendWrapper._do_querycCst|jd�r
|j��dSdS)z�
        Close the backend, releasing any resources held and
        invalidating any file objects obtained from the backend.
        �_closeN)ror`r�r^r(r(r)�close�s�zBackendWrapper.closecCsB|s
t�|�}|s
Jd��t�|�}|�||�|��|�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)rrOr�new_tempduppathr�r��filtered_open_with_delete)r[r��parseresults�tdpr(r(r)�get_fileobj_read�s


zBackendWrapper.get_fileobj_readcCs$|�||�}|��}|��rJ�|S)zL
        Retrieve a file from backend, process it, return contents.
        )r��readr�)r[r�r��fin�bufr(r(r)�get_data�szBackendWrapper.get_datar])rcrdrerfr\r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r(r(r(r)rGs6















rG)T)4rf�futurer�install_aliases�builtinsrrrrjrrr�r7r��urllib.requestrN�urllib.parse�urllib.errorrrrrr	r
r�duplicity.utilr�duplicity.errorsr
rrrrr�duplicity.backendsr.r4r�rMr*r2r5r<r?rErIr=rarxr�r�rGr(r(r(r)�<module>s^

#~
;_

https://t.me/RX1948 - 2025