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/__pycache__/clidriver.cpython-38.pyc
U

<�^3i�@s
ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddl
mZddl
mZddlmZdd	lmZmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#ddl"m$Z$ddl"m%Z%ddl&m'Z'ddl&m(Z(ddl&m)Z)ddl&m*Z*ddl&m+Z+ddl,m-Z-ddl.m/Z/ddl.m0Z0ddl1m2Z2ddl1m3Z3e�4d �Z5d!Z6e�Z7d"�8d#�d$d%�Z9d&d'�Z:d(d)�Z;Gd*d+�d+e<�Z=Gd,d-�d-e�Z>Gd.d/�d/e<�Z?Gd0d1�d1e<�Z@dS)2�N)�__version__)�HierarchicalEmitter)�
xform_name)�copy_kwargs�OrderedDict)�NoCredentialsError)�
NoRegionError)�get_global_history_recorder)�EnvironmentVariablesr)�get_stderr_text_writer)�
get_formatter)�load_plugins)�
CLICommand)�six)�
MainArgParser)�ServiceArgParser��ArgTableArgParser)�USAGE)�ProviderHelpCommand)�ServiceHelpCommand)�OperationHelpCommand)�CustomArgument)�ListArgument)�BooleanArgument)�CLIArgument)�UnknownArgumentError)�unpack_argument)�AliasLoader)�AliasCommandInjector)� emit_top_level_args_parsed_event)�write_exceptionzawscli.clidriverzE%(asctime)s - %(threadName)s - %(name)s - %(levelname)s - %(message)s�ZidnacCs t�}|��}t�d|d�|S)NZCLI_RC�CLI)�create_clidriver�main�HISTORY_RECORDER�record)�driverZrc�r)�2/usr/lib/python3/dist-packages/awscli/clidriver.pyr%Csr%cCs>tj�t�}t|�t|j�di�|�d�d�t	|d�}|S)NZplugins�
event_emitter)Zevent_hooks��session)
�botocorer-ZSessionr
�_set_user_agent_for_sessionr
Zfull_config�get�
get_component�	CLIDriver)r-r(r)r)r*r$Js�
r$cCsd|_t|_dt|_dS)Nzaws-clizbotocore/%s)Zuser_agent_namerZuser_agent_version�botocore_versionZuser_agent_extrar,r)r)r*r/Ssr/c@s�eZdZd dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
d!dd�Zdd�Zdd�Zdd�ZdS)"r2NcCsF|dkr"tj�t�|_t|j�n||_d|_d|_d|_t�|_	dS�N)
r.r-Zget_sessionr
r/�	_cli_data�_command_table�_argument_tabler�alias_loader��selfr-r)r)r*�__init__[szCLIDriver.__init__cCs|jdkr|j�d�|_|jS)NZcli)r5r-�get_data�r:r)r)r*�
_get_cli_datafs
zCLIDriver._get_cli_datacCs|jdkr|��|_|jSr4)r6�_build_command_tabler=r)r)r*�_get_command_tablens

zCLIDriver._get_command_tablecCs|jdkr|��|_|jSr4)r7�_build_argument_tabler=r)r)r*�_get_argument_tabless

zCLIDriver._get_argument_tablecCs&|�|j�}|jjd||j|d�|S)z�
        Create the main parser to handle the global arguments.

        :rtype: ``argparser.ArgumentParser``
        :return: The parser object

        zbuilding-command-table.main��
command_tabler-Zcommand_object)�_build_builtin_commandsr-�emit�r:rDr)r)r*r?xs�zCLIDriver._build_command_tablecCs0t�}|��}|D]}t||j|d�||<q|S)N)�cli_namer-�service_name)rZget_available_services�ServiceCommandr-)r:r-Zcommands�servicesrIr)r)r*rE�s�z!CLIDriver._build_builtin_commandscCs(|�|�}t|j|j�}|�||�dSr4)�_create_parserrr-r8Zinject_aliases)r:rD�parserZinjectorr)r)r*�_add_aliases�s
�zCLIDriver._add_aliasescCsZt�}|��}|�dd�}|D]&}t||�}|�||�}|�|�q|jjd|d�|S)NZoptionszbuilding-top-level-params)�argument_table)rr>r0r�_create_cli_argument�add_to_arg_tabler-rF)r:rO�cli_dataZ
cli_argumentsZoption�
option_params�cli_argumentr)r)r*rA�s�zCLIDriver._build_argument_tablecCsDt||�dd�|�d�|�d�|�d�|�d�|�d�|�d�d	�S)
N�helpr"�dest�default�action�required�choices�type)Z	help_textrVrWrXrYrZZ
cli_type_name)rr0)r:Zoption_namerSr)r)r*rP�s
�zCLIDriver._create_cli_argumentc
Cs<|��}t|j|��|��|�dd�|�dd�|�dd��S)N�descriptionZsynopsisZ
help_usage)r>rr-r@rBr0)r:rRr)r)r*�create_help_command�s


�zCLIDriver.create_help_commandcCs<|��|d<|��}t||j��|�dd�|��dd�}|S)NrUr\Zaws)�prog)r]r>rr-�
user_agentr0rB)r:rDrRrMr)r)r*rL�s
�zCLIDriver._create_parserc
Cs�|dkrtjdd�}|��}|�|�}|�||�|�|�\}}zH|�|�|�|�t�	d|j
��d�t�	d|d�||j||�WSt
k
r�}z6tj�dt�tj�t|��tj�d�WY�dSd}~XYn�tk
�r}zd	|}|�|�WY�dSd}~XYn�tk
�rR}zd
|}|�|�WY�dSd}~XYnztk
�r|tj�d�dtjYStk
�r�}z0tjdd
d�t�d�t|t�d�WY�dSd}~XYnXdS)z�

        :param args: List of arguments, with the 'aws' removed.  For example,
            the command "aws s3 list-objects --bucket foo" will have an
            args list of ``['s3', 'list-objects', '--bucket', 'foo']``.

        N�ZCLI_VERSIONr#Z
CLI_ARGUMENTSz
usage: %s
�
�zA%s You can also configure your region by running "aws configure".z=%s. You can configure credentials by running "aws configure".�zException caught in main()T��exc_infozExiting with rc 255)Zoutfile)�sys�argvr@rLrN�parse_known_args�_handle_top_level_args�_emit_session_eventr&r'r-r_�commandr�stderr�writer�strr�_show_errorr�KeyboardInterrupt�stdout�signal�SIGINT�	Exception�LOG�debugr!r)r:�argsrDrM�parsed_args�	remaining�e�msgr)r)r*r%�sR


��
�

zCLIDriver.maincCs|jjd|j|d�dS)Nzsession-initialized)r-rx)r-rF)r:rxr)r)r*rj�s
�zCLIDriver._emit_session_eventcCs*tj|dd�tj�|�tj�d�dS)NTrdra)rurvrfrlrm)r:r{r)r)r*ro�szCLIDriver._show_errorcCs�t|j|�|jr"|j�d|j�|jr8|j�d|j�|jr�|jjdtjt	d�|jjdtjt	d�|jjdtjt	d�|jjdtjt	d�t
�d|j���t
�d	tj
d
d��n|jjdtjd�dS)N�profile�regionr.)�
format_string�awscliZ
s3transferZurllib3zCLI version: %szArguments entered to CLI: %sr`)Zlogger_nameZ	log_level)r r-r|Zset_config_variabler}rvZset_stream_logger�logging�DEBUG�
LOG_FORMATrur_rfrgZERROR)r:rwr)r)r*ris.�����z CLIDriver._handle_top_level_args)N)N)�__name__�
__module__�__qualname__r;r>r@rBr?rErNrArPr]rLr%rjrorir)r)r)r*r2Ys
	

4
r2c@s�eZdZdZddd�Zedd��Zejdd��Zedd	��Zed
d��Z	e	jdd��Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)rJz�A service command for the CLI.

    For example, ``aws ec2 ...`` we'd create a ServiceCommand
    object that represents the ec2 service.

    NcCs:||_||_d|_|dkr"||_n||_|g|_d|_dSr4)�_namer-r6�
_service_name�_lineage�_service_model)r:rHr-rIr)r)r*r;(szServiceCommand.__init__cCs|jSr4�r�r=r)r)r*�name>szServiceCommand.namecCs
||_dSr4r��r:�valuer)r)r*r�BscCs|��Sr4)�_get_service_modelr=r)r)r*�
service_modelFszServiceCommand.service_modelcCs|jSr4�r�r=r)r)r*�lineageJszServiceCommand.lineagecCs
||_dSr4r�r�r)r)r*r�NscCs|jdkr|��|_|jSr4)r6�_create_command_tabler=r)r)r*r@Rs

z!ServiceCommand._get_command_tablecCs:|jdkr4|j�d��|jd�}|jj|j|d�|_|jS)NZapi_versions)�api_version)r�r-�get_config_variabler0r�Zget_service_model)r:r�r)r)r*r�Ws
��z!ServiceCommand._get_service_modelcCs.|��}|�|�\}}|��}||j||�Sr4)rLrhr@Z	operation)r:rw�parsed_globalsZservice_parserrxryrDr)r)r*�__call___szServiceCommand.__call__cCsxt�}|��}|jD]8}t|d�}|�|�}t||j|j|t|j�d�||<q|jj	d|j||j|d�|�
|�|S)N�-)r��parent_namer-�operation_model�operation_callerzbuilding-command-table.%srC)rr�Zoperation_namesrr��ServiceOperationr�r-�CLIOperationCallerrF�_add_lineage)r:rDr��operation_namerHr�r)r)r*r�hs&


��
z$ServiceCommand._create_command_tablecCs$|D]}||}|j|g|_qdSr4�r�)r:rDrkZcommand_objr)r)r*r�|szServiceCommand._add_lineagecCs,|��}t|j|��|dd�|j�|jd�S)N�.)r-�objrD�	arg_table�event_classr�)r@rr-r��join�
lineage_namesr�rGr)r)r*r]�s
�z"ServiceCommand.create_help_commandcCs"|��}|��|d<t||jd�S)NrU)Zoperations_tablerI)r@r]rr�rGr)r)r*rL�s�zServiceCommand._create_parser)N)r�r�r��__doc__r;�propertyr��setterr�r�r@r�r�r�r�r]rLr)r)r)r*rJs&





		rJc@s�eZdZdZeed�ZeZdd�Z	e
dd��Zejdd��Ze
dd	��Z
e
jd
d	��Z
e
dd��Ze
d
d��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!S)"r�z�A single operation of a service.

    This class represents a single operation for a service, for
    example ``ec2.DescribeInstances``.

    )�listZbooleancCs<d|_||_||_||_|g|_||_||_|jr8d|_dS)aT

        :type name: str
        :param name: The name of the operation/subcommand.

        :type parent_name: str
        :param parent_name: The name of the parent command.

        :type operation_model: ``botocore.model.OperationModel``
        :param operation_object: The operation model
            associated with this subcommand.

        :type operation_caller: ``CLIOperationCaller``
        :param operation_caller: An object that can properly call the
            operation.

        :type session: ``botocore.session.Session``
        :param session: The session object.

        NT)	�
_arg_tabler��_parent_name�_operation_callerr��_operation_model�_sessionZ
deprecatedZ
_UNDOCUMENTED)r:r�r�r�r�r-r)r)r*r;�szServiceOperation.__init__cCs|jSr4r�r=r)r)r*r��szServiceOperation.namecCs
||_dSr4r�r�r)r)r*r��scCs|jSr4r�r=r)r)r*r��szServiceOperation.lineagecCs
||_dSr4r�r�r)r)r*r��scCsdd�|jD�S)NcSsg|]
}|j�qSr))r�)�.0�cmdr)r)r*�
<listcomp>�sz2ServiceOperation.lineage_names.<locals>.<listcomp>r�r=r)r)r*r��szServiceOperation.lineage_namescCs|jdkr|��|_|jSr4)r��_create_argument_tabler=r)r)r*r��s

zServiceOperation.arg_tablec
Csd|j|jf}|j||j||jd�|�|j�}|�|�|�|�\}}|jdkrf|�	�}|||�S|jrx|�
|j�|r�tdd�|���d|j|jf}|j|||d�|�
||j�}d|j|jf}|j||||d	�}	|	dk	r�t|	t�r�|	�n|	Sn|j�|jjj|jj||�SdS)
Nz+before-building-argument-table-parser.%s.%s)rOrwr-rUzUnknown options: %sz, zoperation-args-parsed.%s.%s)rxr�zcalling-command.%s.%s)�call_parametersrxr�)r�r��_emitr�r��_create_operation_parser�	_add_helprhrUr]�appendrr��_build_call_parameters�_emit_first_non_none_response�
isinstancertr��invoker�r�rIr�)
r:rwr�ZeventZoperation_parserrxryZop_helpr��overrider)r)r*r��s^
��


������

�zServiceOperation.__call__cCs"t|j|j|j|jd�|j�d�S)Nr�)r�r�r�r�)rr�r�r�r�r�r�r=r)r)r*r]s
�z$ServiceOperation.create_help_commandcCs|jddd�dS)NrU�?)�nargs)�add_argument)r:rMr)r)r*r�szServiceOperation._add_helpcCsLi}t|�}|��D]2}|j}||kr||}|�||�}|�||�q|Sr4)�vars�values�py_name�_unpack_argZ
add_to_params)r:rwr�Zservice_paramsrx�
arg_objectr�r�r)r)r*r�!sz'ServiceOperation._build_call_parameterscCs,|j}|jjj}t|jd�}t|||||�S)Nr�)r�r�r�Zendpoint_prefixrr�r)r:rTr�r-rIr�r)r)r*r�0s
�zServiceOperation._unpack_argc
	Cs�t�}|jj}g}i}|dk	r*|j}|j}|��D]l\}}t|d�}|j�|j	|j
�}|j�dd�}	||kop|	}
|j�
d�}||||
|j||d�}|�|�q2t�|�|jd|j|jf|j|j||d�|S)Nr�ZidempotencyTokenFr+)r�Zargument_model�is_requiredr�Zserialized_namer+zbuilding-argument-table.%s.%s)r�r-rkrO)rr��input_shapeZrequired_members�members�itemsr�	ARG_TYPESr0Z	type_name�DEFAULT_ARG_CLASSZmetadatar�r1rQrurvr�r�r�)
r:rOr�Zrequired_argumentsZarg_dictZarg_nameZ	arg_shapeZcli_arg_nameZ	arg_classZis_tokenr�r+r�r)r)r*r�:sD

��

��z'ServiceOperation._create_argument_tablecKs|jj|f|�Sr4)r�rF�r:r��kwargsr)r)r*r�ZszServiceOperation._emitcKs|jj|f|�Sr4)r�Zemit_first_non_none_responser�r)r)r*r�]s
��z.ServiceOperation._emit_first_non_none_responsecCst|�}|Sr4r)r:r�rMr)r)r*r�asz)ServiceOperation._create_operation_parserN)r�r�r�r�rrr�rr�r;r�r�r�r�r�r�r�r]r�r�r�r�r�r�r�r)r)r)r*r��s6�"





6
 r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r�z.Call an AWS operation and format the response.cCs
||_dSr4)r�r9r)r)r*r;jszCLIOperationCaller.__init__cCs<|jj||j|j|jd�}|�||||�}|�|||�dS)a�Invoke an operation and format the response.

        :type service_name: str
        :param service_name: The name of the service.  Note this is the service name,
            not the endpoint prefix (e.g. ``ses`` not ``email``).

        :type operation_name: str
        :param operation_name: The operation name of the service.  The casing
            of the operation name should match the exact casing used by the service,
            e.g. ``DescribeInstances``, not ``describe-instances`` or
            ``describe_instances``.

        :type parameters: dict
        :param parameters: The parameters for the operation call.  Again, these values
            have the same casing used by the service.

        :type parsed_globals: Namespace
        :param parsed_globals: The parsed globals from the command line.

        :return: None, the result is displayed through a formatter, but no
            value is returned.

        )Zregion_name�endpoint_urlZverifyr)r�Z
create_clientr}r�Z
verify_ssl�_make_client_call�_display_response)r:rIr��
parametersr��client�responser)r)r*r�ms��zCLIOperationCaller.invokecCsHt|�}|�|�r0|jr0|�|�}|jf|�}nt|t|��f|�}|Sr4)rZcan_paginateZpaginateZ
get_paginator�getattr)r:r�r�r�r�Zpy_operation_nameZ	paginatorr�r)r)r*r��s
�z$CLIOperationCaller._make_client_callcCs2|j}|dkr|j�d�}t||�}|||�dS)N�output)r�r�r�r)r:Zcommand_namer�r�r�Z	formatterr)r)r*r��s

z$CLIOperationCaller._display_responseN)r�r�r�r�r;r�r�r�r)r)r)r*r�fs
!r�)Arfrrr�Zbotocore.sessionr.rr3Zbotocore.hooksrrZbotocore.compatrrZbotocore.exceptionsrrZbotocore.historyr	rr
Z
awscli.compatrZawscli.formatterrZ
awscli.pluginr
Zawscli.commandsrrZawscli.argparserrrrrZawscli.helprrrZawscli.argumentsrrrrrZawscli.argprocessrZawscli.aliasrrZawscli.utilsr r!Z	getLoggerrur�r&�encoder%r$r/�objectr2rJr�r�r)r)r)r*�<module>
s^
�

	GsU