HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/awscli/customizations/s3/__pycache__/results.cpython-38.pyc
U

<�^h�@s<ddlmZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddl	mZddlm
Z
ddlmZmZdd	lmZdd
lmZddlmZddlmZdd
lmZe�e�Zeddddg�Zdefdd�Zeddg�Zeddddg�Zed�Zeddg�Z ed�Z!eddg�Z"ede"d�Z#ed d!d"g�Z$ed#d$g�Z%Gd%d&�d&e&�Z'Gd'd(�d(e�Z(Gd)d*�d*e(�Z)Gd+d,�d,e)�Z*Gd-d.�d.e(�Z+Gd/d0�d0e+�Z,Gd1d2�d2e(�Z-Gd3d4�d4e(�Z.Gd5d6�d6e&�Z/Gd7d8�d8e/�Z0Gd9d:�d:e/�Z1Gd;d<�d<e1�Z2Gd=d>�d>e1�Z3Gd?d@�d@ej4�Z5GdAdB�dBe&�Z6dS)C�)�divisionN)�
namedtuple)�defaultdict)�CancelledError)�
FatalError)�BaseSubscriber)�queue�ensure_text_type��
relative_path)�human_readable_size)�	uni_print)�
WarningResult)�OnDoneFilteredSubscriber�
BaseResult�
transfer_type�src�destcCs,t|j�}|r||7}t|t||�|fi�S�N)�list�_fields�typer)�nameZextra_fields�base_clsZfields�r�B/usr/lib/python3/dist-packages/awscli/customizations/s3/results.py�_create_new_result_cls's
r�QueuedResult�total_transfer_size�ProgressResult�bytes_transferred�	timestamp�
SuccessResult�
FailureResult�	exception�DryRunResult�ErrorResult�CtrlCResult)r�
CommandResultZnum_tasks_failedZnum_tasks_warned�FinalTotalSubmissionsResult�total_submissionsc@seZdZdS)�ShutdownThreadRequestN)�__name__�
__module__�__qualname__rrrrr+Ksr+c@sReZdZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�BaseResultSubscriberNcCs&||_i|_||_|dkr"|j|_dS)z�Subscriber to send result notifications during transfer process

        :param result_queue: The queue to place results to be processed later
            on.
        N)�
_result_queue�_result_kwargs_cache�_transfer_type�
TRANSFER_TYPE)�self�result_queuerrrr�__init__Rs
zBaseResultSubscriber.__init__cKs2|�|�|j|jj}tf|�}|j�|�dSr)�_add_to_result_kwargs_cacher1�meta�transfer_idrr0�put)r4�future�kwargs�
result_kwargsZ
queued_resultrrr�	on_queued^s

zBaseResultSubscriber.on_queuedcKs6|j|jj}tf|t��d�|��}|j�|�dS)N)r r!)r1r8r9r�timer0r:)r4r;r r<r=Zprogress_resultrrr�on_progressds��z BaseResultSubscriber.on_progresscCs |�|�}|j�tf|��dSr)�%_on_done_pop_from_result_kwargs_cacher0r:r"�r4r;r=rrr�_on_successks
z BaseResultSubscriber._on_successcCsX|�|�}t|t�r:t}t|t�r&t}|j�||d��n|j�tfd|i|���dS)N�r$r$)	rA�
isinstancerr'rr&r0r:r#)r4r;�er=Zerror_result_clsrrr�_on_failureos


z BaseResultSubscriber._on_failurecCs4|�|�\}}|j|||jjd�}||j|jj<dS)N)rrrr)�
_get_src_destr2r8�sizer1r9)r4r;rrr=rrrr7ys�z0BaseResultSubscriber._add_to_result_kwargs_cachecCs|j�|jj�}|�d�|S)Nr)r1�popr8r9rBrrrrA�s
z:BaseResultSubscriber._on_done_pop_from_result_kwargs_cachecCstd��dS)Nz_get_src_dest()��NotImplementedError)r4r;rrrrH�sz"BaseResultSubscriber._get_src_dest)N)r,r-r.r3r6r>r@rCrGr7rArHrrrrr/Os


r/c@s eZdZdZdd�Zdd�ZdS)�UploadResultSubscriberZuploadcCs0|jj}|�|j�}d|jd|j}||fS�N�s3://�/)r8�	call_args�_get_src�fileobj�bucket�key�r4r;rQrrrrrrH�sz$UploadResultSubscriber._get_src_destcCst|�Srr
�r4rSrrrrR�szUploadResultSubscriber._get_srcN)r,r-r.r3rHrRrrrrrM�srMc@seZdZdd�ZdS)�UploadStreamResultSubscribercCsdS�N�-rrWrrrrR�sz%UploadStreamResultSubscriber._get_srcN)r,r-r.rRrrrrrX�srXc@s eZdZdZdd�Zdd�ZdS)�DownloadResultSubscriberZdownloadcCs0|jj}d|jd|j}|�|j�}||fSrN)r8rQrTrU�	_get_destrSrVrrrrH�sz&DownloadResultSubscriber._get_src_destcCst|�Srr
rWrrrr\�sz"DownloadResultSubscriber._get_destN)r,r-r.r3rHr\rrrrr[�sr[c@seZdZdd�ZdS)�DownloadStreamResultSubscribercCsdSrYrrWrrrr\�sz(DownloadStreamResultSubscriber._get_destN)r,r-r.r\rrrrr]�sr]c@seZdZdZdd�ZdS)�CopyResultSubscriber�copycCsB|jj}|j}d|dd|d}d|jd|j}||fS)NrOZBucketrPZKey)r8rQ�copy_sourcerTrU)r4r;rQr`rrrrrrH�s
z"CopyResultSubscriber._get_src_destN�r,r-r.r3rHrrrrr^�sr^c@seZdZdZdd�ZdS)�DeleteResultSubscriber�deletecCs$|jj}d|jd|j}|dfSrN)r8rQrTrU)r4r;rQrrrrrH�sz$DeleteResultSubscriber._get_src_destNrarrrrrb�srbc@seZdZdZdd�ZdS)�BaseResultHandlerz6Base handler class to be called in the ResultProcessorcCstd��dS)Nz
__call__()rK�r4�resultrrr�__call__�szBaseResultHandler.__call__N)r,r-r.�__doc__rgrrrrrd�srdc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�ResultRecorderz@Records and track transfer statistics based on results receievedcCs�d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
tt�|_
i|_t|jt|jt|jt|jt|jt|jt|jt|ji|_dS�Nr)r �bytes_failed_to_transfer�files_transferred�files_failed�files_warned�errors�expected_bytes_transferred�expected_files_transferred� final_expected_files_transferred�
start_time�bytes_transfer_speedr�int�_ongoing_progress�_ongoing_total_sizesr�_record_queued_resultr�_record_progress_resultr"�_record_success_resultr#�_record_failure_resultr�_record_warning_resultr&�_record_error_resultr'r)�_record_final_expected_files�_result_handler_map�r4rrrr6�s<
�zResultRecorder.__init__cCs|j|jkSr)rrrqr�rrr�expected_totals_are_final�s��z(ResultRecorder.expected_totals_are_finalcCs|j�t|�|j�|d�dS)z0Record the result of an individual Result object�rfN)r�getr�_record_nooprerrrrg�s�zResultRecorder.__call__cCsTt|t�stdt|���g}|j|j|jfD]}|dk	r.|�t|��q.d�	|�S)NzdAny result using _get_ongoing_dict_key must subclass from BaseResult. Provided result is of type: %s�:)
rEr�
ValueErrorrrrr�appendr	�join)r4rfZ	key_partsZresult_propertyrrr�_get_ongoing_dict_key�s
��z$ResultRecorder._get_ongoing_dict_keycCs.|�|�}|j�|d�}|j�|d�}||fSrj)r�rvrJrw)r4rf�ongoing_key�total_progress�total_file_sizerrr�_pop_result_from_ongoing_dicts�s
z-ResultRecorder._pop_result_from_ongoing_dictscKsdSrr�r4r<rrrr�szResultRecorder._record_noopcKsN|jdkrt��|_|j}||j|�|�<|r<|j|7_|jd7_dS�N�)rsr?rrwr�rprq)r4rfr<rrrrrx	s

��z$ResultRecorder._record_queued_resultcKsZ|j}|�|�|j|�|�|7<|j|7_|j|jkrV|j|j|j|_dSr)r �(_update_ongoing_transfer_size_if_unknownrvr�r!rsrt)r4rfr<r rrrrys
��
�z&ResultRecorder._record_progress_resultcCsh|�|�}|j|dkrd|j}|jdk	rT||j|<|j|}||}|j|7_n|j|j7_dSr)r�rwrrvrpr )r4rfr�rZongoing_progressZunaccounted_bytesrrrr�&s



z7ResultRecorder._update_ongoing_transfer_size_if_unknowncKs|�|�|jd7_dSr�)r�rl�r4rfr<rrrrz@s
z%ResultRecorder._record_success_resultcKsL|�|�\}}|dk	r,||}|j|7_|jd7_|jd7_dSr�)r�rkrmrl)r4rfr<r�r�Z
progress_leftrrrr{Ds�z%ResultRecorder._record_failure_resultcKs|jd7_dSr�)rnr�rrrr|Qsz%ResultRecorder._record_warning_resultcKs|jd7_dSr�)ror�rrrr}Tsz#ResultRecorder._record_error_resultcKs|j|_dSr)r*rrr�rrrr~Wsz+ResultRecorder._record_final_expected_filesN)r,r-r.rhr6r�rgr�r�r�rxryr�rzr{r|r}r~rrrrri�s
ric@s�eZdZdZdZdZdeZdeZdZdeZ	dZ
d	Zd
ZdZ
dZd
Zd8dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd9d.d/�Zd0d1�Z d2d3�Z!d4d5�Z"d6d7�Z#dS):�
ResultPrinterz#{remaining_files} file(s) remainingz~{expected_total}z (calculating...)zOCompleted {bytes_completed}/{expected_bytes_completed} ({transfer_speed}) with z)Completed {files_completed} file(s) with z${transfer_type}: {transfer_location}z	(dryrun) z7{transfer_type} failed: {transfer_location} {exception}z	{message}zfatal error: {exception}zcancelled: ctrl-c receivedz{src} to {dest}z{src}NcCsv||_||_|jdkrtj|_||_|jdkr6tj|_d|_t|jt	|j
t|jt
|jt|jt|jt|jt|ji|_dS)a�Prints status of ongoing transfer

        :type result_recorder: ResultRecorder
        :param result_recorder: The associated result recorder

        :type out_file: file-like obj
        :param out_file: Location to write progress and success statements.
            By default, the location is sys.stdout.

        :type error_file: file-like obj
        :param error_file: Location to write warnings and errors.
            By default, the location is sys.stderr.
        Nr)�_result_recorder�	_out_file�sys�stdout�_error_file�stderr�_progress_lengthr�_print_progressr"�_print_successr#�_print_failurer�_print_warningr&�_print_errorr'�
_print_ctrl_cr%�_print_dry_runr)�-_clear_progress_if_no_more_expected_transfersr)r4�result_recorderZout_fileZ
error_filerrrr6zs2

�zResultPrinter.__init__cCs|j�t|�|j�|d�dS)z<Print the progress of the ongoing transfer based on a resultr�N)rr�r�_print_nooprerrrrg�s�zResultPrinter.__call__cKsdSrrr�rrrr��szResultPrinter._print_noopcKs0|jj|j|�|�d�}|�|�}|�|�dS�N)r�transfer_location)�DRY_RUN_FORMAT�formatr�_get_transfer_location�_adjust_statement_padding�_print_to_out_file)r4rfr<�	statementrrrr��s�
zResultPrinter._print_dry_runcKs8|jj|j|�|�d�}|�|�}|�|�|��dSr�)�SUCCESS_FORMATr�rr�r�r��_redisplay_progress)r4rfr<Zsuccess_statementrrrr��s�

zResultPrinter._print_successcKs<|jj|j|�|�|jd�}|�|�}|�|�|��dS)N)rr�r$)�FAILURE_FORMATr�rr�r$r��_print_to_error_filer�)r4rfr<Zfailure_statementrrrr��s�

zResultPrinter._print_failurecKs0|jj|jd�}|�|�}|�|�|��dS)N)�message)�WARNING_FORMATr�r�r�r�r�)r4rfr<Zwarning_statementrrrr��s

zResultPrinter._print_warningcKs|�|jj|jd��dS)NrD)�_flush_error_statement�ERROR_FORMATr�r$r�rrrr��s�zResultPrinter._print_errorcKs|�|j�dSr)r��
CTRL_C_MSGr�rrrr��szResultPrinter._print_ctrl_ccCs|�|�}|�|�dSr)r�r�)r4Zerror_statementrrrr��s
z$ResultPrinter._flush_error_statementcCs.|jdkr|jj|jd�S|jj|j|jd�S)N)r)rr)r�SRC_TRANSFER_LOCATION_FORMATr�r�!SRC_DEST_TRANSFER_LOCATION_FORMATrerrrr��s
�z$ResultPrinter._get_transfer_locationcCsd|_|��dSrj)r��_add_progress_if_neededr�rrrr��sz!ResultPrinter._redisplay_progresscCs|��r|��dSr)�_has_remaining_progressr�r�rrrr��sz%ResultPrinter._add_progress_if_neededcKs�|�t|jj|jj��}|jjdkrrt|jj|jj�}|�t|jj��}t|jj	�d}|j
j||||d�}n|jj|jj|d�}|j�
�s�||j7}|j|dd�}t|�d|_|�|�dS)Nrz/s)�bytes_completed�expected_bytes_completed�transfer_speed�remaining_files)Zfiles_completedr��
)�ending_charr�)�_get_expected_total�strr�rqrlrprr rkrt�BYTE_PROGRESS_FORMATr��FILE_PROGRESS_FORMATr��_STILL_CALCULATING_TOTALSr��lenr�r�)r4r<r�r�r�r�Zprogress_statementrrrr��sN���������	�

�zResultPrinter._print_progresscCs|j��s|jj|d�S|S)N)�expected_total)r�r��_ESTIMATED_EXPECTED_TOTALr�)r4r�rrrr�s

�z!ResultPrinter._get_expected_total�
cCs|�|jd�}||S)N� )�ljustr�)r4Zprint_statementr�rrrr�sz'ResultPrinter._adjust_statement_paddingcCs&|j��sdS|jj}|jj}||kS)NT)r�r�rlrq)r4ZactualZexpectedrrrr�s

z%ResultPrinter._has_remaining_progresscCst||j�dSr)r
r��r4r�rrrr�"sz ResultPrinter._print_to_out_filecCst||j�dSr)r
r�r�rrrr�%sz"ResultPrinter._print_to_error_filecKs$|jr |��s t|�d�|j�dS)N�)r�r�r
r�r�r�rrrr�(sz;ResultPrinter._clear_progress_if_no_more_expected_transfers)NN)r�)$r,r-r.Z_FILES_REMAININGr�r�r�r�r�r�r�r�r�r�r�r�r6rgr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�[sR�������
"	
/
r�c@seZdZdZdd�ZdS)�NoProgressResultPrinterz,A result printer that doesn't print progresscKsdSrrr�rrrr�/sz'NoProgressResultPrinter._print_progressN)r,r-r.rhr�rrrrr�-sr�c@s eZdZdZdd�Zdd�ZdS)�OnlyShowErrorsResultPrinterz,A result printer that only prints out errorscKsdSrrr�rrrr�5sz+OnlyShowErrorsResultPrinter._print_progresscKsdSrrr�rrrr�8sz*OnlyShowErrorsResultPrinter._print_successN)r,r-r.rhr�r�rrrrr�3sr�c@s&eZdZddd�Zdd�Zdd�ZdS)	�ResultProcessorNcCs2tj�|�||_||_|jdkr(g|_d|_dS)aQThread to process results from result queue

        This includes recording statistics and printing transfer status

        :param result_queue: The result queue to process results from
        :param result_handlers: A list of callables that take a result in as
            a parameter to process the result for that handler.
        NT)�	threading�Threadr6r0�_result_handlers�_result_handlers_enabled)r4r5Zresult_handlersrrrr6=s	
zResultProcessor.__init__cCsfzH|j�d�}t|t�r&t�d�Wqb|jr6|�|�t|t�rFd|_Wqt	j
k
r^YqXqdS)NTzSShutdown request received in result processing thread, shutting down result thread.F)r0r�rEr+�LOGGER�debugr��_process_resultr&rZEmptyrerrr�runMs
�


zResultProcessor.runcCsT|jD]H}z||�Wqtk
rL}ztjd|||dd�W5d}~XYqXqdS)Nz.Error processing result %s with handler %s: %sT��exc_info)r��	Exceptionr�r�)r4rfZresult_handlerrFrrrr�bs
�zResultProcessor._process_result)N)r,r-r.r6r�r�rrrrr�<s
r�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�CommandResultRecordercCs||_||_||_dS)a�Records the result for an entire command

        It will fully process all results in a result queue and determine
        a CommandResult representing the entire command.

        :type result_queue: queue.Queue
        :param result_queue: The result queue in which results are placed on
            and processed from

        :type result_recorder: ResultRecorder
        :param result_recorder: The result recorder to track the various
            results sent through the result queue

        :type result_processor: ResultProcessor
        :param result_processor: The result processor to process results
            placed on the queue
        N)r5r��_result_processor)r4r5r�Zresult_processorrrrr6mszCommandResultRecorder.__init__cCs|j��dSr)r��startr�rrrr��szCommandResultRecorder.startcCs|j�t��|j��dSr)r5r:r+r�r�r�rrr�shutdown�szCommandResultRecorder.shutdowncCst|jj|jj|jj�S)z�Get the CommandResult representing the result of a command

        :rtype: CommandResult
        :returns: The CommandResult representing the total result from running
            a particular command
        )r(r�rmrornr�rrr�get_command_result�s�z(CommandResultRecorder.get_command_resultcCs|j�t|��dSr)r5r:r))r4Ztotalrrr�notify_total_submissions�sz.CommandResultRecorder.notify_total_submissionscCs|��|Sr)r�r�rrr�	__enter__�szCommandResultRecorder.__enter__cGs>|r2tjd|dd�|j�t|d��|��dS|��dS)Nz-Exception caught during command execution: %sTr�rD)r�r�r5r:r&r�)r4�exc_type�	exc_value�argsrrr�__exit__�s�zCommandResultRecorder.__exit__N)
r,r-r.r6r�r�r�r�r�r�rrrrr�lsr�)7Z
__future__rZloggingr�r�r?�collectionsrrZs3transfer.exceptionsrrZs3transfer.subscribersrZ
awscli.compatrr	Zawscli.customizations.s3.utilsrrZawscli.customizations.utilsr
rrZ	getLoggerr,r�rrrrr"r#r%r&r'r(r)�objectr+r/rMrXr[r]r^rbrdrir�r�r�r�r�r�rrrr�<module>
sn

����=

	S	0