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: //lib/python3/dist-packages/awscli/customizations/s3/__pycache__/s3handler.cpython-310.pyc
o

.&�a[�@s:ddlZddlZddlmZddlmZmZmZmZm	Z	m
Z
ddlmZddl
mZddl
mZddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZddl
mZddl
mZddl
mZddl
mZddl
mZddl
mZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddlm&Z&ddlm'Z'ddl(m)Z)e�*e+�Z,Gd d!�d!e-�Z.Gd"d#�d#e-�Z/Gd$d%�d%e-�Z0Gd&d'�d'e0�Z1Gd(d)�d)e0�Z2Gd*d+�d+e0�Z3Gd,d-�d-e1�Z4Gd.d/�d/e2�Z5Gd0d1�d1e0�Z6Gd2d3�d3e0�Z7dS)4�N)�TransferManager)�human_readable_size�MAX_UPLOAD_SIZE�find_bucket_key�
relative_path�create_warning�NonSeekableStream)�*create_transfer_config_from_runtime_config)�UploadResultSubscriber)�DownloadResultSubscriber)�CopyResultSubscriber)�UploadStreamResultSubscriber)�DownloadStreamResultSubscriber)�DeleteResultSubscriber)�QueuedResult)�
SuccessResult)�
FailureResult)�DryRunResult)�ResultRecorder)�
ResultPrinter)�OnlyShowErrorsResultPrinter)�NoProgressResultPrinter)�ResultProcessor)�CommandResultRecorder)�RequestParamsMapper��StdoutBytesWriter)�ProvideSizeSubscriber)�"ProvideUploadContentTypeSubscriber)� ProvideCopyContentTypeSubscriber)�!ProvideLastModifiedTimeSubscriber)�DirectoryCreatorSubscriber)�DeleteSourceFileSubscriber)�DeleteSourceObjectSubscriber)� DeleteCopySourceObjectSubscriber)�get_binary_stdinc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�S3TransferHandlerFactory�cCs||_||_dS)aFactory for S3TransferHandlers

        :type cli_params: dict
        :param cli_params: The parameters provide to the CLI command

        :type runtime_config: RuntimeConfig
        :param runtime_config: The runtime config for the CLI command
            being run
        N)�_cli_params�_runtime_config)�self�
cli_params�runtime_config�r-�D/usr/lib/python3/dist-packages/awscli/customizations/s3/s3handler.py�__init__:s

z!S3TransferHandlerFactory.__init__c	Csrt|j�}|j|_|j|_t||�}t�d|j|j	�t
�}|g}|�||�t||�}t
|||�}t||j|�S)agCreates a S3TransferHandler instance

        :type client: botocore.client.Client
        :param client: The client to power the S3TransferHandler

        :type result_queue: queue.Queue
        :param result_queue: The result queue to be used to process results
            for the S3TransferHandler

        :returns: A S3TransferHandler instance
        z7Using a multipart threshold of %s and a part size of %s)r	r)�MAX_IN_MEMORY_CHUNKS�max_in_memory_upload_chunks�max_in_memory_download_chunksr�LOGGER�debug�multipart_threshold�multipart_chunksizer�_add_result_printerrr�S3TransferHandlerr()	r*�client�result_queue�transfer_config�transfer_manager�result_recorder�result_processor_handlers�result_processor�command_result_recorderr-r-r.�__call__Gs0��
����z!S3TransferHandlerFactory.__call__cCsh|j�d�rdS|j�d�rt|�}n|j�d�rt|�}n|j�d�s)t|�}nt|�}|�|�dS)N�quiet�only_show_errors�	is_stream�progress)r(�getrrr�append)r*r=r>�result_printerr-r-r.r7ks


z,S3TransferHandlerFactory._add_result_printerN)�__name__�
__module__�__qualname__r0r/rAr7r-r-r-r.r&7s

$r&c@seZdZdd�Zdd�ZdS)r8cCsP||_||_|j|jj|f}t|�t|�t|�t|�t|�t|�t	|�g|_
dS)aBackend for performing S3 transfers

        :type transfer_manager: s3transfer.manager.TransferManager
        :param transfer_manager: Transfer manager to use for transfers

        :type cli_params: dict
        :param cli_params: The parameters passed to the CLI command in the
            form of a dictionary

        :type result_command_recorder: ResultCommandRecorder
        :param result_command_recorder: The result command recorder to be
            used to get the final result of the transfer
        N)�_transfer_manager�_result_command_recorderr:�UploadStreamRequestSubmitter�DownloadStreamRequestSubmitter�UploadRequestSubmitter�DownloadRequestSubmitter�CopyRequestSubmitter�DeleteRequestSubmitter�LocalDeleteRequestSubmitter�_submitters)r*r<r+�result_command_recorder�submitter_argsr-r-r.r/zs
�
�zS3TransferHandler.__init__c	Cs�|j�>|j�+d}|D]}|jD]}|�|�r#|�|�r!|d7}nqq|j�|�Wd�n1s5wYWd�n1sDwY|j��S)a�Process iterable of FileInfos for transfer

        :type fileinfos: iterable of FileInfos
        param fileinfos: Set of FileInfos to submit to underlying transfer
            request submitters to make transfer API calls to S3

        :rtype: CommandResult
        :returns: The result of the command that specifies the number of
            failures and warnings encountered.
        r�N)rMrLrU�
can_submit�submit�notify_total_submissions�get_command_result)r*�	fileinfos�total_submissions�fileinfo�	submitterr-r-r.�call�s$


������
zS3TransferHandler.callN)rIrJrKr/rar-r-r-r.r8ys%r8c@s�eZdZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS) �BaseTransferRequestSubmitterNcCs||_||_||_dS)a\Submits transfer requests to the TransferManager

        Given a FileInfo object and provided CLI parameters, it will add the
        necessary extra arguments and subscribers in making a call to the
        TransferManager.

        :type transfer_manager: s3transfer.manager.TransferManager
        :param transfer_manager: The underlying transfer manager

        :type result_queue: queue.Queue
        :param result_queue: The result queue to use

        :type cli_params: dict
        :param cli_params: The associated CLI parameters passed in to the
            command as a dictionary.
        N)rL�
_result_queuer()r*r<r:r+r-r-r.r/�s
z%BaseTransferRequestSubmitter.__init__cCs|�|�}|s|�|�SdS)a�Submits a transfer request based on the FileInfo provided

        There is no guarantee that the transfer request will be made on
        behalf of the fileinfo as a fileinfo may be skipped based on
        circumstances in which the transfer is not possible.

        :type fileinfo: awscli.customizations.s3.fileinfo.FileInfo
        :param fileinfo: The FileInfo to be used to submit a transfer
            request to the underlying transfer manager.

        :rtype: s3transfer.futures.TransferFuture
        :returns: A TransferFuture representing the transfer if it the
            transfer was submitted. If it was not submitted nothing
            is returned.
        N)�_warn_and_signal_if_skip�
_do_submit)r*r_�should_skipr-r-r.rZ�s

�z#BaseTransferRequestSubmitter.submitcC�td��)a�Checks whether it can submit a particular FileInfo

        :type fileinfo: awscli.customizations.s3.fileinfo.FileInfo
        :param fileinfo: The FileInfo to check if the transfer request
            submitter can handle.

        :returns: True if it can use the provided FileInfo to make a transfer
            request to the underlying transfer manager. False, otherwise.
        zcan_submit()��NotImplementedError�r*r_r-r-r.rY�s
z'BaseTransferRequestSubmitter.can_submitcCs�i}|jr|�||j�g}|�||�|jr2d|ji}|j�dd�r'd|d<|�|jdi|���|j�d�s?|�|||�S|�|�dS)Nr:�is_moveF�move�
transfer_type�dryrunr-)	�REQUEST_MAPPER_METHODr(�_add_additional_subscribers�RESULT_SUBSCRIBER_CLASSrcrFrG�_submit_transfer_request�_submit_dryrun)r*r_�
extra_args�subscribers�
result_kwargsr-r-r.re�s
�z'BaseTransferRequestSubmitter._do_submitcCs@|j}|j�dd�rd}|�|�\}}|j�t|||d��dS)NrkFrl�rm�src�dest)�operation_namer(rF�_format_src_destrc�putr)r*r_rmrxryr-r-r.rss�z+BaseTransferRequestSubmitter._submit_dryruncC�dS�Nr-�r*rur_r-r-r.rp�z8BaseTransferRequestSubmitter._add_additional_subscriberscCrg)Nz_submit_transfer_request()rh)r*r_rtrur-r-r.rr�z5BaseTransferRequestSubmitter._submit_transfer_requestcCs |��D]	}||�r
dSqdS)NT)�_get_warning_handlers)r*r_�warning_handlerr-r-r.rds
��z5BaseTransferRequestSubmitter._warn_and_signal_if_skipcCsgSr~r-�r*r-r-r.r�sz2BaseTransferRequestSubmitter._get_warning_handlerscCs|j�d�o|j�d�S)N�guess_mime_type�content_type)r(rFr�r-r-r.�_should_inject_content_type$s�z8BaseTransferRequestSubmitter._should_inject_content_typecCsf|j�d�s1|��s1t�d|j|jf�|j�d�s/td|jd|j|jf�}|j�	|�dSdS)N�force_glacier_transferz@Encountered glacier object s3://%s. Not performing %s on object.�ignore_glacier_warnings�s3://z�Object is of storage class GLACIER. Unable to perform %s operations on GLACIER objects. You must restore the object to be able to perform the operation. See aws s3 %s help for additional parameter options to ignore or force these transfers.TF)
r(rF�is_glacier_compatibler3r4rxrzrrcr|)r*r_�warningr-r-r.�
_warn_glacier*s"
��
��
z*BaseTransferRequestSubmitter._warn_glaciercCsDdtjj}tj�|j��|�}|r t|jd�}|j�|�dSdS)Nz..z#File references a parent directory.TF)	�os�path�sep�normpath�compare_key�
startswithrrcr|)r*r_�
parent_prefix�escapes_cwdr�r-r-r.�_warn_parent_reference?s��z3BaseTransferRequestSubmitter._warn_parent_referencecCrg)zAReturns formatted versions of a fileinfos source and destination.r{rhrjr-r-r.r{Lsz-BaseTransferRequestSubmitter._format_src_destcCst|�Sr~)r�r*r�r-r-r.�_format_local_pathPr�z/BaseTransferRequestSubmitter._format_local_pathcCs|�d�r|Sd|S)Nr�)r�r�r-r-r.�_format_s3_pathSs
z,BaseTransferRequestSubmitter._format_s3_path)rIrJrKrorqr/rZrYrersrprrrdr�r�r�r�r{r�r�r-r-r-r.rb�s$	
rbc@sNeZdZejZeZdd�Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�ZdS)rPcC�
|jdkS)N�upload�rzrjr-r-r.rY]�
z!UploadRequestSubmitter.can_submitcCsF|�t|j��|��r|�t��|j�dd�r!|�t��dSdS�NrkF)rGr�sizer�rr(rFr"rr-r-r.rp`s�z2UploadRequestSubmitter._add_additional_subscriberscC�.t|j�\}}|�|�}|jj|||||d�S�N)�fileobj�bucket�keyrtru)rry�_get_fileinrLr�)r*r_rtrur�r��fileinr-r-r.rrg�
�z/UploadRequestSubmitter._submit_transfer_requestcC�|jSr~)rxrjr-r-r.r�o�z"UploadRequestSubmitter._get_fileincC�|jgSr~)�_warn_if_too_larger�r-r-r.r�rr�z,UploadRequestSubmitter._get_warning_handlerscCsTt|d�r&|jtkr(t|j�}d|tt�f}t||dd�}|j�|�dSdSdS)Nr�z&File %s exceeds s3 upload limit of %s.F)�	skip_file)	�getattrr�rrrxrrrcr|)r*r_�	file_path�warning_messager�r-r-r.r�us
����z)UploadRequestSubmitter._warn_if_too_largecC� |�|j�}|�|j�}||fSr~)r�rxr�ry�r*r_rxryr-r-r.r{�z'UploadRequestSubmitter._format_src_destN)rIrJrKr�map_put_object_paramsror
rqrYrprrr�r�r�r{r-r-r-r.rPYs
rPc@sFeZdZejZeZdd�Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
S)rQcCr�)N�downloadr�rjr-r-r.rY�r�z#DownloadRequestSubmitter.can_submitcCsV|�t|j��|�t��|�t|j|j��|j�dd�r)|�t	|j
��dSdSr�)rGrr�r!r �last_updatercr(rFr#�
source_clientrr-r-r.rp�s�
��z4DownloadRequestSubmitter._add_additional_subscriberscCr�r�)rrx�_get_fileoutrLr�)r*r_rtrur�r��fileoutr-r-r.rr�r�z1DownloadRequestSubmitter._submit_transfer_requestcCr�r~)ryrjr-r-r.r��r�z%DownloadRequestSubmitter._get_fileoutcCs|j|jgSr~)r�r�r�r-r-r.r��sz.DownloadRequestSubmitter._get_warning_handlerscCr�r~)r�rxr�ryr�r-r-r.r{�r�z)DownloadRequestSubmitter._format_src_destN)rIrJrKr�map_get_object_paramsrorrqrYrprrr�r�r{r-r-r-r.rQ�s	rQc@s>eZdZejZeZdd�Zdd�Z	dd�Z
dd�Zd	d
�ZdS)rRcCr�)N�copyr�rjr-r-r.rY�r�zCopyRequestSubmitter.can_submitcCsJ|�t|j��|��r|�t��|j�dd�r#|�t|j��dSdSr�)	rGrr�r�rr(rFr$r�rr-r-r.rp�s
��z0CopyRequestSubmitter._add_additional_subscribersc	Cs@t|j�\}}t|j�\}}||d�}|jj||||||jd�S)N)�Bucket�Key)r�r��copy_sourcertrur�)rryrxrLr�r�)	r*r_rtrur�r��
source_bucket�
source_keyr�r-r-r.rr�s
�z-CopyRequestSubmitter._submit_transfer_requestcCr�r~)r�r�r-r-r.r��r�z*CopyRequestSubmitter._get_warning_handlerscCs |�|j�}|�|j�}||fSr~)r�rxryr�r-r-r.r{�r�z%CopyRequestSubmitter._format_src_destN)
rIrJrKr�map_copy_object_paramsrorrqrYrprrr�r{r-r-r-r.rR�s
rRc@�0eZdZeZdd�Zdd�Zdd�Zdd�Zd	S)
rNcC�|jdko
|j�d�S)Nr�rD�rzr(rFrjr-r-r.rY��

�z'UploadStreamRequestSubmitter.can_submitcCs0|j�dd�}|dur|�tt|���dSdS)N�
expected_size)r(rFrGr�int)r*rur_r�r-r-r.rp�s�z8UploadStreamRequestSubmitter._add_additional_subscriberscCst�}t|�Sr~)r%r)r*r_�binary_stdinr-r-r.r��sz(UploadStreamRequestSubmitter._get_fileincC�dS�N�-r-r�r-r-r.r��r�z/UploadStreamRequestSubmitter._format_local_pathN)	rIrJrKr
rqrYrpr�r�r-r-r-r.rN�srNc@r�)
rOcCr�)Nr�rDr�rjr-r-r.rY�r�z)DownloadStreamRequestSubmitter.can_submitcCr}r~r-rr-r-r.rp�r�z:DownloadStreamRequestSubmitter._add_additional_subscriberscCst�Sr~rrjr-r-r.r��r�z+DownloadStreamRequestSubmitter._get_fileoutcCr�r�r-r�r-r-r.r��r�z1DownloadStreamRequestSubmitter._format_local_pathN)	rIrJrKrrqrYrpr�r�r-r-r-r.rO�srOc@s.eZdZejZeZdd�Zdd�Z	dd�Z
dS)rScC�|jdko	|jdkS)N�delete�s3�rz�src_typerjr-r-r.rY��
�z!DeleteRequestSubmitter.can_submitcCs"t|j�\}}|jj||||d�S)N)r�r�rtru)rrxrLr�)r*r_rtrur�r�r-r-r.rr�s
�z/DeleteRequestSubmitter._submit_transfer_requestcC�|�|j�dfSr~)r�rxrjr-r-r.r{�z'DeleteRequestSubmitter._format_src_destN)rIrJrKr�map_delete_object_paramsrorrqrYrrr{r-r-r-r.rS�srSc@s,eZdZdZdZdd�Zdd�Zdd�ZdS)rTNcCr�)Nr��localr�rjr-r-r.rY
r�z&LocalDeleteRequestSubmitter.can_submitc
Cs�|�|�\}}d||d�}zDz"|j�tdddi|���t�|j�|j�tdi|���WWdStyQ}z|j�t	dd|i|���WYd}~WdSd}~wwYdS)Nr�rw�total_transfer_sizer�	exceptionTr-)
r{rcr|rr��removerxr�	Exceptionr)r*r_rtrurxryrv�er-r-r.rrs,
�������z4LocalDeleteRequestSubmitter._submit_transfer_requestcCr�r~)r�rxrjr-r-r.r{-r�z,LocalDeleteRequestSubmitter._format_src_dest)rIrJrKrorqrYrrr{r-r-r-r.rTsrT)8�loggingr��s3transfer.managerr�awscli.customizations.s3.utilsrrrrrr�'awscli.customizations.s3.transferconfigr	� awscli.customizations.s3.resultsr
rrr
rrrrrrrrrrrrrrrrrr r!r"r#r$�
awscli.compatr%�	getLoggerrIr3�objectr&r8rbrPrQrRrNrOrSrTr-r-r-r.�<module>sX 
B?",$"