HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/duplicity/backends/__pycache__/s3_boto3_backend.cpython-310.pyc
o

��@a�%�@s~ddlZddlmZddlmZddlmZmZddlmZddlmZGdd�dej	j
�ZGd	d
�d
e�Z
ej	�de�dS)�N)�config)�log)�FatalBackendException�BackendException)�util)�progressc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�S3Boto3Backenda�
    Backend for Amazon's Simple Storage System, (aka Amazon S3), though
    the use of the boto3 module. (See
    https://boto3.amazonaws.com/v1/documentation/api/latest/index.html
    for information on boto3.)

    Pursuant to Amazon's announced deprecation of path style S3 access,
    this backend only supports virtual host style bucket URIs.
    See the man page for full details.

    To make use of this backend, you must provide AWS credentials.
    This may be done in several ways: through the environment variables
    AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, by the
    ~/.aws/credentials file, by the ~/.aws/config file,
    or by using the boto2 style ~/.boto or /etc/boto.cfg files.
    cCs�tjj�||�dd�|j�d�D�}|r|�d�|_ntd��|r+dd�	|�|_
nd|_
||_tj�|�|_
d|_d|_t�|_dS)NcSsg|]}|dkr|�qS)��)�.0�xr
r
�E/usr/lib/python3/dist-packages/duplicity/backends/s3_boto3_backend.py�
<listcomp>Esz+S3Boto3Backend.__init__.<locals>.<listcomp>�/rzS3 requires a bucket name.z%s/r	)�	duplicity�backend�Backend�__init__�path�split�pop�bucket_namer�join�
key_prefix�
parsed_url�strip_auth_from_url�straight_url�s3�bucket�UploadProgressTracker�tracker)�selfr�url_path_partsr
r
r
r?szS3Boto3Backend.__init__c
Cs�ddl}ddl}ddlm}d|_|jdtjtjd�|_	z|j	j
jj|j
d�Wn%|jjyM}z|jdd}|dkrHtd	|j
tjjd
���d}~ww|j	�|j
�|_dS)Nr)�ClientErrorr)�region_name�endpoint_url)�Bucket�Error�Code�404zS3 bucket "%s" does not exist��code)�boto3�botocore�botocore.exceptionsr#r�resourcer�s3_region_name�s3_endpoint_urlr�meta�client�head_bucketr�
exceptions�responserr�	ErrorCode�backend_not_foundr&)r!r,r-r#�bce�
error_coder
r
r
�reset_connectionVs"
���zS3Boto3Backend.reset_connectionc	Cs,ddlm}|js
|��t�|�}|j|}tjrd}n"tj	r#d}ntj
r)d}ntjr3d|vr3d}ntjr=d|vr=d}nd	}d
|i}tj
rKd|d<n!tjrltjdur[td
tjjd��d|d<tj|d<tjrltj|d<|tjtjd�}|j}t�d|j||f�|j�|jj|�j|j|j||d�dS)Nr)�TransferConfig�REDUCED_REDUNDANCY�STANDARD_IA�
ONEZONE_IA�manifest�GLACIER�DEEP_ARCHIVE�STANDARD�StorageClass�AES256�ServerSideEncryptionzOS3 USE SSE KMS was requested, but key id not provided require (--s3-kms-key-id)r*zaws:kms�SSEKMSKeyId�GrantFullControl)�multipart_chunksize�multipart_thresholdzUploading %s/%s to %s Storage)�Callback�Config�	ExtraArgs)�boto3.s3.transferr<rr;r�fsdecoderr�
s3_use_rrs�	s3_use_ia�s3_use_onezone_ia�s3_use_glacier�s3_use_deep_archive�
s3_use_sse�s3_use_sse_kms�
s3_kms_key_idrrr7�s3_kms_no_id�s3_kms_grant�s3_multipart_chunk_sizer �Infor�Objectr�name�upload_file�uc_name�progress_cb)	r!�local_source_path�remote_filenamer<�key�
storage_class�
extra_args�transfer_configr r
r
r
�_putjsL



�

�
�zS3Boto3Backend._putcCs@|js|��t�|�}|j|}|j�|jj|��|j	�dS�N)
rr;rrOrr\rr]�
download_filer_)r!rb�
local_pathrcr
r
r
�_get�s


zS3Boto3Backend._getc	Csz|js|��g}|jjj|jd�D](}z|j�|jdd�}|�t	�
|��t�d|j
|f�Wqty:Yqw|S)N)�Prefixr	�zListed %s/%s)rr;r�objects�filterrrc�replace�appendr�fsencoder�Debugr�AttributeError)r!�
filename_list�obj�filenamer
r
r
�_list�s�zS3Boto3Backend._listcCs<|js|��t�|�}|j|}|j�|jj|���dSrh)	rr;rrOrr\rr]�delete)r!rbrcr
r
r
�_delete�s


zS3Boto3Backend._deletec
Cs�|js|��ddl}t�|�}|j|}d}z|j�|jj|�}|�	�|j
}Wd|iS|jjyN}z|j
dddkr@n�WYd}~d|iSd}~ww)Nr���r'r(r)�size)rr;r-rrOrr\rr]�load�content_lengthr5r#r6)r!rbr-rcr~�s3_objr9r
r
r
�_query�s&

�
���zS3Boto3Backend._queryN)�__name__�
__module__�__qualname__�__doc__rr;rgrkrxrzr�r
r
r
r
r-s3rc@seZdZdd�Zdd�ZdS)rcCs
d|_dS�Nr)�total_bytes)r!r
r
r
r�s
zUploadProgressTracker.__init__cCs |j|7_t�|jd�dSr�)r�r�report_transfer)r!�fresh_byte_countr
r
r
r`�sz!UploadProgressTracker.progress_cbN)r�r�r�rr`r
r
r
r
r�srzboto3+s3)�duplicity.backendrrr�duplicity.errorsrrrrrrr�objectr�register_backendr
r
r
r
�<module>s$