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__/_boto_multi.cpython-310.pyc
o

��`�&�@sddlmZddlmZe��ddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlmZddlmZddlTdd	lmZd
dlmZd
dlmZd
ZejdvrtddlmZe�dej�nddlZGdd�dej�Z Gdd�de�Zdd�Z!dS)�)�division)�standard_library)�rangeN)�config)�log)�progress)�*)�FileChunkIO�)�BotoBackend)�get_connectionz2.1.1)�darwin�linux2)�dummyzAMultiprocessing is not supported on %s, will use threads instead.cs(eZdZdZ�fdd�Zdd�Z�ZS)�ConsumerThreadz�
    A background thread that collects all written bytes from all
    the pool workers, and reports it to the progress module.
    Wakes up every second to check for termination
    cs0tt|���d|_d|_i|_||_||_dS)NTF)�superr�__init__�daemon�finishr�queue�total)�selfrr��	__class__��@/usr/lib/python3/dist-packages/duplicity/backends/_boto_multi.pyr>s
zConsumerThread.__init__c
Cs�d}|js@z|j�|d�}|d|j|d<d}Wn!tjy:}zt�t|j���|j�d}WYd}~nd}~ww|jrdSdS)NTr
rF)	rr�getr�Empty�report_transfer�sum�valuesr)r�wait�args�errr�runFs���zConsumerThread.run)�__name__�
__module__�__qualname__�__doc__rr$�
__classcell__rrrrr8src@s2eZdZdZdd�Zdd�Zdd�Zdd	d
�ZdS)ra�
    Backend for Amazon's Simple Storage System, (aka Amazon S3), though
    the use of the boto module, (http://code.google.com/p/boto/).

    To make use of this backend you must set aws_access_key_id
    and aws_secret_access_key in your ~/.boto or /etc/boto.cfg
    with your Amazon Web Services key id and secret respectively.
    Alternatively you can export the environment variables
    AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
    cCs6t�||�zddl}Wnty�w|��dS)Nr)�BotoSingleBackendr�boto�ImportError�_setup_pool)r�
parsed_urlr+rrrr_s�zBotoBackend.__init__cCsftj}|stjdd�}t|dd�r#t�d�|j��|j�	�d|_t�d|�t
j|d�|_dS)NF)�logical�_poolz8A process pool already exists. Destroying previous pool.z;Setting multipart boto backend process pool to %d processes)�	processes)r�s3_multipart_max_procs�psutil�	cpu_count�getattrr�Debugr0�	terminate�join�multiprocessing�Pool)r�number_of_procsrrrr-gs


zBotoBackend._setup_poolcCs,t�|�t�d�|j��|j��dS)NzClosing pool)r*�_closerr6r0r7r8)rrrrr<vs


zBotoBackend._closeNcCs�ddl}tj}|tjkrt�dtj|f�tj}tj�|�}||kr&d}n||}||r2|d7}t�	d||f�|j
j|j|tj
d�}d}	tjr\t��}
|
��}	t|	|�}|��g}t|�D]#}
|�|j�}|j|j||j|j||
|tj|	g
}|�|j�t|��qbt�	dt |��|r�z)|dj!tj"d�|d�#�r�|d�$�r�|d=nt�	d�|�%�Wntj&�Wntj&y�t�	d	t |��|�%�Ynw|s�t�	d
�tjr�d|_'|�(�t |�dks�t |�)��|kr�|�*�t+d��|�,�S)
Nrz+Minimum chunk size is %d, but %d specified.r
zUploading %d bytes in %d chunks)�encrypt_keyz2Waiting for the pool to finish processing %s tasks)�timeoutz6Part upload not successful, aborting multipart upload.z^%s tasks did not finish by the specified timeout,aborting multipart upload and resetting pool.z.Done waiting for the pool to finish processingTz!Multipart upload failed. Aborted.)-r+r�s3_multipart_chunk_size�s3_multipart_minimum_chunk_sizer�Warn�os�path�getsizer6�bucket�initiate_multipart_upload�key�
s3_use_sserr9�Manager�Queuer�startr�storage_uri�boto_uri_str�schemer.�bucket_name�id�num_retries�appendr0�apply_async�multipart_upload_worker�lenr!�s3_multipart_max_timeout�ready�
successfulr-�TimeoutErrorrr8�
get_all_parts�
cancel_upload�BackendException�complete_upload)r�filenamerG�headersr+�
chunk_size�bytes�chunks�mpr�manager�consumer�tasks�nrL�paramsrrr�upload|sr
�
�
����
zBotoBackend.upload)N)r%r&r'r(rr-r<rirrrrrSsrc


s4��fdd�����������	�
f
dd���|�S)z�
    Worker method for uploading a file chunk to S3 using multipart upload.
    Note that the file chunk is read into memory, so it's important to keep
    this number reasonably small.
    cs<t��j}t�d|||f��dur���|g�dSdS)Nz%s: Uploaded %s/%s bytes)r9�current_process�namerr6�put)�uploadedr�worker_name)�offsetrrr�_upload_callback�s

�z1multipart_upload_worker.<locals>._upload_callbackc

s�t��j}t�d|�df�z�t���	�}|���}|��D]o}|j�kr�t	�d���d��T}t
�
�}z|j|�d�tdd�d�d�Wnt
jyc}zt�|j�WYd}~nd}~wwt
�
�}t�d	j|�d�tdt||��d
��Wd�n1s�wYnq |��d}d}~Wn9ty�}	z-t��|r�t�d|�d|df��|d�WYd}	~	St�d|�df�|	�d}	~	wwt�d
|�df�dS)Nz%s: Uploading chunk %dr
�r)rora��i)�cb�num_cbz>{name}: Uploaded chunk {chunk} at roughly {speed} bytes/second)rk�chunk�speedz8%s: Upload of chunk %d failed. Retrying %d more times...z*%s: Upload of chunk %d failed. Aborting...z%s: Upload of chunk %d complete)r9rjrkrr6r�lookup�list_multipart_uploadsrPr	�time�upload_part_from_file�max�socket�gaierrorrA�strerror�format�abs�close�	Exception�	traceback�	print_exc)
rQrn�connrErc�fdrK�ex�endr#)
�_uploadrprOrar^�multipart_idror.rNrLrrr��s\



����
�������	z(multipart_upload_worker.<locals>._uploadr)
rNr.rLrOr�r^rorarQrr)r�rprOrar^r�ror.rrNrLrrT�s'rT)"�
__future__r�futurer�install_aliases�builtinsrrBr3rr}�sys�	threadingrzr��	duplicityrrr�duplicity.errors�duplicity.filechunkior	�_boto_singlerr*r�BOTO_MIN_VERSION�platformr9rr6�ThreadrrTrrrr�<module>s6
r