HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/self/root/usr/lib/python3.6/site-packages/awscli/__pycache__/clidriver.cpython-36.pyc
3

�T_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.m0Z0ddl1m2Z2ddl1m3Z3ej4d �Z5d!Z6e�Z7d"j8d#�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�}|j�}tjd|d�|S)NZCLI_RC�CLI)�create_clidriver�main�HISTORY_RECORDER�record)�driverZrc�r(�/usr/lib/python3.6/clidriver.pyr$Csr$cCs>tjjt�}t|�t|jjdi�|jd�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_extra)r+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)"r0NcCsF|dkr"tjjt�|_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|jjd�|_|jS)NZcli)r2r+�get_data)r6r(r(r)�
_get_cli_datafs
zCLIDriver._get_cli_datacCs|jdkr|j�|_|jS)N)r3�_build_command_table)r6r(r(r)�_get_command_tablens

zCLIDriver._get_command_tablecCs|jdkr|j�|_|jS)N)r4�_build_argument_table)r6r(r(r)�_get_argument_tabless

zCLIDriver._get_argument_tablecCs&|j|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+�command_object)�_build_builtin_commandsr+�emit)r6r>r(r(r)r:xszCLIDriver._build_command_tablecCs4t�}|j�}x |D]}t||j|d�||<qW|S)N)�cli_namer+�service_name)rZget_available_services�ServiceCommandr+)r6r+ZcommandsZservicesrCr(r(r)r@�s
z!CLIDriver._build_builtin_commandscCs(|j|�}t|j|j�}|j||�dS)N)�_create_parserrr+r5Zinject_aliases)r6r>�parserZinjectorr(r(r)�_add_aliases�s
zCLIDriver._add_aliasescCs^t�}|j�}|jdd�}x.|D]&}t||�}|j||�}|j|�q W|jjd|d�|S)NZoptionszbuilding-top-level-params)�argument_table)rr9r.r�_create_cli_argument�add_to_arg_tabler+rA)r6rH�cli_dataZ
cli_argumentsZoption�
option_params�cli_argumentr(r(r)r<�s
zCLIDriver._build_argument_tablec
CsDt||jdd�|jd�|jd�|jd�|jd�|jd�|jd�d	�S)
N�helpr!�dest�default�action�required�choices�type)Z	help_textrOrPrQrRrSZ
cli_type_name)rr.)r6Zoption_namerLr(r(r)rI�szCLIDriver._create_cli_argumentc	Cs<|j�}t|j|j�|j�|jdd�|jdd�|jdd��S)N�descriptionZsynopsisZ
help_usage)r9rr+r;r=r.)r6rKr(r(r)�create_help_command�s

zCLIDriver.create_help_commandcCs<|j�|d<|j�}t||jj�|jdd�|j�dd�}|S)NrNrUZaws)�prog)rVr9rr+�
user_agentr.r=)r6r>rKrFr(r(r)rE�s

zCLIDriver._create_parsercCs�|dkrtjdd�}|j�}|j|�}|j||�|j|�\}}yF|j|�|j|�tj	d|j
j�d�tj	d|d�||j||�St
k
r�}z0tjjdt�tjjt|��tjjd�dSd}~Xn�tk
�r}zd	|}|j|�dSd}~Xn�tk
�r8}zd
|}|j|�dSd}~Xnntk
�r^tjjd�dtjStk
�r�}z*tjdd
d�tjd�t|t�d�dSd}~XnXdS)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;rErG�parse_known_args�_handle_top_level_args�_emit_session_eventr%r&r+rX�commandr�stderr�writer�strr�_show_errorr�KeyboardInterrupt�stdout�signal�SIGINT�	Exception�LOG�debugr r)r6�argsr>rF�parsed_args�	remaining�e�msgr(r(r)r$�sH






zCLIDriver.maincCs|jjd|j|d�dS)Nzsession-initialized)r+rp)r+rA)r6rpr(r(r)rb�szCLIDriver._emit_session_eventcCs*tj|dd�tjj|�tjjd�dS)NT)r]rZ)rmrnr^rdre)r6rsr(r(r)rg�szCLIDriver._show_errorcCs�t|j|�|jr"|jjd|j�|jr8|jjd|j�|jr�|jjdtjt	d�|jjdtjt	d�|jjdtjt	d�|jjdtjt	d�t
jd|jj��t
jd	tj
d
d��n|jjdtjd�dS)N�profile�regionr,)�
format_string�awscliZ
s3transferZurllib3zCLI version: %szArguments entered to CLI: %srY)Zlogger_nameZ	log_level)rr+rtZset_config_variablerurnZset_stream_logger�logging�DEBUG�
LOG_FORMATrmrXr^r_ZERROR)r6ror(r(r)ras$z CLIDriver._handle_top_level_args)N)N)�__name__�
__module__�__qualname__r7r9r;r=r:r@rGr<rIrVrEr$rbrgrar(r(r(r)r0Ys
	

4
r0c@s�eZdZdZddd�Zedd��Zejdd��Zedd	��Zed
d��Z	e	jdd��Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)rDz�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|_dS)N)�_namer+r3�
_service_name�_lineage�_service_model)r6rBr+rCr(r(r)r7(szServiceCommand.__init__cCs|jS)N)r~)r6r(r(r)�name>szServiceCommand.namecCs
||_dS)N)r~)r6�valuer(r(r)r�BscCs|j�S)N)�_get_service_model)r6r(r(r)�
service_modelFszServiceCommand.service_modelcCs|jS)N)r�)r6r(r(r)�lineageJszServiceCommand.lineagecCs
||_dS)N)r�)r6r�r(r(r)r�NscCs|jdkr|j�|_|jS)N)r3�_create_command_table)r6r(r(r)r;Rs

z!ServiceCommand._get_command_tablecCs:|jdkr4|jjd�j|jd�}|jj|j|d�|_|jS)NZapi_versions)�api_version)r�r+�get_config_variabler.rZget_service_model)r6r�r(r(r)r�Ws

z!ServiceCommand._get_service_modelcCs.|j�}|j|�\}}|j�}||j||�S)N)rEr`r;Z	operation)r6ro�parsed_globalsZservice_parserrprqr>r(r(r)�__call___szServiceCommand.__call__cCs|t�}|j�}xB|jD]8}t|d�}|j|�}t||j|j|t|j�d�||<qW|jj	d|j||j|d�|j
|�|S)N�-)r��parent_namer+�operation_model�operation_callerzbuilding-command-table.%s)r>r+r?)rr�Zoperation_namesrr��ServiceOperationr~r+�CLIOperationCallerrA�_add_lineage)r6r>r��operation_namerBr�r(r(r)r�hs"


z$ServiceCommand._create_command_tablecCs(x"|D]}||}|j|g|_qWdS)N)r�)r6r>rcZcommand_objr(r(r)r�|s
zServiceCommand._add_lineagecCs,|j�}t|j|j�|ddj|j�|jd�S)N�.)r+�objr>�	arg_table�event_classr�)r;rr+r��join�
lineage_namesr~)r6r>r(r(r)rV�s
z"ServiceCommand.create_help_commandcCs"|j�}|j�|d<t||jd�S)NrN)Zoperations_tablerC)r;rVrr~)r6r>r(r(r)rE�szServiceCommand._create_parser)N)r{r|r}�__doc__r7�propertyr��setterr�r�r;r�r�r�r�rVrEr(r(r(r)rDs
		rDc@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)r6r�r�r�r�r+r(r(r)r7�szServiceOperation.__init__cCs|jS)N)r~)r6r(r(r)r��szServiceOperation.namecCs
||_dS)N)r~)r6r�r(r(r)r��scCs|jS)N)r�)r6r(r(r)r��szServiceOperation.lineagecCs
||_dS)N)r�)r6r�r(r(r)r��scCsdd�|jD�S)NcSsg|]
}|j�qSr()r�)�.0�cmdr(r(r)�
<listcomp>�sz2ServiceOperation.lineage_names.<locals>.<listcomp>)r�)r6r(r(r)r��szServiceOperation.lineage_namescCs|jdkr|j�|_|jS)N)r��_create_argument_table)r6r(r(r)r��s

zServiceOperation.arg_tablec
Csd|j|jf}|j||j||jd�|j|j�}|j|�|j|�\}}|jdkrf|j	�}|||�S|jrx|j
|j�|r�tddj|���d|j|jf}|j|||d�|j
||j�}d|j|jf}|j||||d	�}	|	dk	r�t|	t�r�|	�n|	Sn|jj|jjj|jj||�SdS)
Nz+before-building-argument-table-parser.%s.%s)rHror+rNzUnknown options: %sz, zoperation-args-parsed.%s.%s)rpr�zcalling-command.%s.%s)�call_parametersrpr�)r�r~�_emitr�r��_create_operation_parser�	_add_helpr`rNrV�appendrr��_build_call_parameters�_emit_first_non_none_response�
isinstancerlr��invoker�r�rCr�)
r6ror�ZeventZoperation_parserrprqZop_helpr��overrider(r(r)r��sH







zServiceOperation.__call__cCs"t|j|j|j|jdj|j�d�S)Nr�)r�r�r�r�)rr�r�r�r~r�r�)r6r(r(r)rVs
z$ServiceOperation.create_help_commandcCs|jddd�dS)NrN�?)�nargs)�add_argument)r6rFr(r(r)r�szServiceOperation._add_helpcCsPi}t|�}x>|j�D]2}|j}||kr||}|j||�}|j||�qW|S)N)�vars�values�py_name�_unpack_argZ
add_to_params)r6ror�Zservice_paramsrp�
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)r6rMr�r+rCr�r(r(r)r�0s

zServiceOperation._unpack_argc
	Cs�t�}|jj}g}i}|dk	r*|j}|j}xx|j�D]l\}}t|d�}|jj|j	|j
�}|jjdd�}	||kor|	}
|jj
d�}||||
|j||d�}|j|�q4Wtj|�|jd|j|jf|j|j||d�|S)Nr�ZidempotencyTokenFr*)r�Zargument_model�is_requiredr�Zserialized_namer*zbuilding-argument-table.%s.%s)r�r+rcrH)rr��input_shapeZrequired_members�members�itemsr�	ARG_TYPESr.Z	type_name�DEFAULT_ARG_CLASSZmetadatar�r/rJrmrnr�r�r~)
r6rHr�Zrequired_argumentsZarg_dictZarg_nameZ	arg_shapeZcli_arg_nameZ	arg_classZis_tokenr�r*r�r(r(r)r�:s<



z'ServiceOperation._create_argument_tablecKs|jj|f|�S)N)r�rA)r6r��kwargsr(r(r)r�ZszServiceOperation._emitcKs|jj|f|�S)N)r�Zemit_first_non_none_response)r6r�r�r(r(r)r�]sz.ServiceOperation._emit_first_non_none_responsecCst|�}|S)N)r)r6r�rFr(r(r)r�asz)ServiceOperation._create_operation_parserN)r{r|r}r�rrr�rr�r7r�r�r�r�r�r�r�rVr�r�r�r�r�r�r�r(r(r(r)r��s("6
 r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r�z.Call an AWS operation and format the response.cCs
||_dS)N)r�)r6r+r(r(r)r7jszCLIOperationCaller.__init__cCs<|jj||j|j|jd�}|j||||�}|j|||�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_clientrur�Z
verify_ssl�_make_client_call�_display_response)r6rCr��
parametersr��client�responser(r(r)r�ms
zCLIOperationCaller.invokecCsHt|�}|j|�r0|jr0|j|�}|jf|�}nt|t|��f|�}|S)N)rZcan_paginateZpaginateZ
get_paginator�getattr)r6r�r�r�r�Zpy_operation_nameZ	paginatorr�r(r(r)r��s
z$CLIOperationCaller._make_client_callcCs2|j}|dkr|jjd�}t||�}|||�dS)N�output)r�r�r�r)r6Zcommand_namer�r�r�Z	formatterr(r(r)r��s

z$CLIOperationCaller._display_responseN)r{r|r}r�r7r�r�r�r(r(r(r)r�fs
!r�)Ar^rjrxZbotocore.sessionr,rr1Zbotocore.hooksrrZbotocore.compatrrZbotocore.exceptionsrrZbotocore.historyr	rwr
Z
awscli.compatrZawscli.formatterrZ
awscli.pluginr
Zawscli.commandsrrZawscli.argparserrrrrZawscli.helprrrZawscli.argumentsrrrrrZawscli.argprocessrZawscli.aliasrrZawscli.utilsrr Z	getLoggerrmrzr%�encoder$r#r-�objectr0rDr�r�r(r(r(r)�<module>
s\


	GsU