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: //lib/python3.6/site-packages/awscli/customizations/codeartifact/__pycache__/login.cpython-36.pyc
3

�T_K9�@s�ddlZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZmZmZddlmZddlmZd	d
�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�N)�datetime)�tzutc)�
relativedelta)�parse_timestamp)�urlparse�RawConfigParser�StringIO)�utils)�BasicCommandcCs~g}d}xfdD]^}t||�}|dkr^|r2|jd�|jt|��|j|d	krX|dd�n|�|rdP|dk}qWd
j|�}|S)
NF�years�months�days�hours�minutesr�and�� )rrr
rr���)�getattr�append�str�join)�	remaining�valuesZprev_non_zero_attr�attr�value�message�r�/usr/lib/python3.6/login.py�get_relative_expiration_times



rc@sFeZdZddd�Zddd�Zdd�Zd	d
�Zddd�Zed
d��Z	dS)�	BaseLoginNcCs"||_||_||_||_||_dS)N)�
auth_token�
expiration�repository_endpoint�subprocess_utils�	namespace)�selfr!r"r#r$r%rrr�__init__&s
zBaseLogin.__init__FcCstd��dS)Nzlogin())�NotImplementedError)r&�dry_runrrr�login.szBaseLogin.logincCs@x:|D]2}tjjdj|��tjjtj�tjjtj�qWdS)Nr)�sys�stdout�writer�os�linesep)r&�tool�commands�commandrrr�_dry_run_commands1s
zBaseLogin._dry_run_commandscCsrt|jtjt���tdd�}t|�}tjjdj	||j
��tjjtj�tjjdj	||j��tjjtj�dS)N�)ZsecondszASuccessfully configured {} to use AWS CodeArtifact repository {} zLogin expires in {} at {})
rr"rZnowrrr+r,r-�formatr#r.r/)r&r0rZexpiration_messagerrr�_write_success_message7s

z BaseLogin._write_success_messagecCs�|r|j||�dSxj|D]b}y|jj||jj|jjd�Wqtk
rz}z"|jtjkrftd|��|�WYdd}~XqXqW|j|�dS)N)r,�stderrz-%s was not found. Please verify installation.)	r3r$Z
check_call�PIPE�OSError�errno�ENOENT�
ValueErrorr6)r&r0r1r)r2Zexrrr�
_run_commandsGs

zBaseLogin._run_commandscKstd��dS)Nzget_commands())r()�cls�endpointr!�kwargsrrr�get_commands\szBaseLogin.get_commands)N)F)F)
�__name__�
__module__�__qualname__r'r*r3r6r=�classmethodrArrrrr $s


r c@sFeZdZej�j�dkrdndZddd�Zedd��Z	ed	d
��Z
dS)
�NpmLoginZwindowsznpm.cmd�npmFcCs2|j|j�}|j|j|j|d�}|jd||�dS)N)�scoperG)�	get_scoper%rAr#r!r=)r&r)rHr1rrrr*gs
zNpmLogin.logincCsFtjd�}|dkr|S|jd�r&|}n
dj|�}|j|�sBtd��|S)Nz^(@[a-z0-9-~][a-z0-9-._~]*)�@z@{}zZInvalid scope name, scope must contain URL-safe characters, no leading dots or underscores)�re�compile�
startswithr5�matchr<)r>r%Zvalid_scope_namerHrrrrIps



zNpmLogin.get_scopec
Ks�g}|jd�}|rdj|�nd}|j|jdd||g�tj|�}dj|j|j�}|j|jdd|dg�dj|j|j�}	|j|jdd|	|g�|S)	NrHz{}:registry�registry�config�setz//{}{}:always-auth�truez//{}{}:_authToken)�getr5r�NPM_CMDr�urlsplit�netloc�path)
r>r?r!r@r1rHrO�repo_uriZalways_auth_configZauth_token_configrrrrA�s

zNpmLogin.get_commandsN)F)rBrCrD�platform�system�lowerrTr*rErIrArrrrrFas
	rFc@s&eZdZdZddd�Zedd��ZdS)	�PipLoginz1{scheme}://aws:{auth_token}@{netloc}{path}simple/FcCs"|j|j|j�}|jd||�dS)N�pip)rAr#r!r=)r&r)r1rrrr*�szPipLogin.logincKs4tj|�}|jj|j||j|jd�}dddd|ggS)N)�schemer!rVrWr]rPrQzglobal.index-url)rrU�PIP_INDEX_URL_FMTr5r^rVrW)r>r?r!r@rXZ
pip_index_urlrrrrA�s

zPipLogin.get_commandsN)F)rBrCrDr_r*rErArrrrr\�s
r\csDeZdZdZd�fdd�	Zedd��Zd
dd	�Zed
d��Z�Z	S)�
TwineLoginz�[distutils]
index-servers=
    pypi
    codeartifact

[codeartifact]
repository: {repository_endpoint}
username: aws
password: {auth_token}Ncs0|dkr|j�}||_tt|�j||||�dS)N)�get_pypi_rc_path�pypi_rc_path�superr`r')r&r!r"r#r$rb)�	__class__rrr'�s

zTwineLogin.__init__cKsPd|kstd��|d}|jj||d�}t�}tjj|��ry�|j|�|jdd�}dd�|j	d�D�}d	|kr�|j
d	�|jddddj|��d	|j
�kr�|jd	�|jd	d
|�|jd	dd�|jd	d
|�WnFtk
�r}	z(tjjd|�tjjtj�|	�WYdd}	~	XnXn|jt|��t�}
|j|
�|
j�}|
j�|S)Nrbzpypi_rc_path must be provided.)r#r!Z	distutilsz
index-serverscSs g|]}|j�dkr|j��qS)�)�strip)�.0Zserverrrr�
<listcomp>�sz+TwineLogin.get_commands.<locals>.<listcomp>�
�codeartifact�
repositoryZusernameZawsZpasswordz%s is in an invalid state.)�AssertionError�DEFAULT_PYPI_RC_FMTr5rr.rW�exists�readrS�splitrrQrZsectionsZadd_section�	Exceptionr+r,r-r/Zreadfpr�getvalue�close)r>r?r!r@rbZdefault_pypi_rcZpypi_rcZ
index_serversZservers�eZpypi_rc_stream�pypi_rc_strrrrrA�s>



zTwineLogin.get_commandsFc	Cs�|j|j|j|jd�}|r~tjjd�tjjtj�tjjd|j�tjjtj�tjjtj�tjj|�tjjtj�n,t	|jd��}|j|�WdQRX|j
d�dS)N)rbz.Dryrun mode is enabled, not writing to pypirc.z(%s would have been set to the following:zw+�twine)rAr#r!rbr+r,r-r.r/�openr6)r&r)ru�fprrrr*s 
zTwineLogin.logincCstjjtjjd�d�S)N�~z.pypirc)r.rWr�
expanduser)r>rrrra+szTwineLogin.get_pypi_rc_path)N)F)
rBrCrDrmr'rErAr*ra�
__classcell__rr)rdrr`�s
8
r`c@s�eZdZdZdedd�dedd�dedd�d�ZdZd	Z	d
de
ej��dd�d
ddd�dddd�dddd�ddddd�dddd�dddddd�gZdd�Z
d d!�Zd"d#�Zd$d%�Zd&S)'�CodeArtifactLoginz>Log in to the idiomatic tool for the requested package format.rGT)�package_format�	login_cls�namespace_supportZpypiF)rGr]rvr*z�Sets up the idiomatic tool for your package format to use your CodeArtifact repository. Your login information is valid for up to 12 hours after which you must login again.r0z1The tool you want to connect with your repository)�name�	help_text�choices�required�domainzYour CodeArtifact domain name)r�r�r�zdomain-ownerz5The AWS account ID that owns your CodeArtifact domainr%z0Associates a namespace with your repository toolzduration-secondsZintegerz9The time, in seconds, that the login information is valid)r�Z
cli_type_namer�r�rkz!Your CodeArtifact repository namezdry-run�
store_truez�Only print the commands that would be executed to connect your tool with your repository without making any changes to your configuration)r��actionr�r��defaultcCs4|j|d}|r*|jr*tdj|���n|jSdS)Nrz,Argument --namespace is not supported for {})�TOOL_MAPr%r<r5)r&r0�parsed_argsZnamespace_compatiblerrr�_get_namespace{s
z CodeArtifactLogin._get_namespacecCs4|j|j|d�}|jr |j|d<|jf|�}|dS)N)r�rkr5�domainOwnerZrepositoryEndpoint)r�rk�domain_ownerZget_repository_endpoint)r&�codeartifact_clientr�r}r@Z get_repository_endpoint_responserrr�_get_repository_endpoint�s
z*CodeArtifactLogin._get_repository_endpointcCs:d|ji}|jr|j|d<|jr*|j|d<|jf|�}|S)Nr�r�ZdurationSeconds)r�r�Zduration_secondsZget_authorization_token)r&r�r�r@Z get_authorization_token_responserrr�_get_authorization_token�s


z*CodeArtifactLogin._get_authorization_tokencCs�|jj�}|j|d}tj|jd|�}|j||�}|j|||�}|j||�}|d}	t	|d�}
|j|d|	|
|t
|�}|j|j�dS)Nr}rjZauthorizationTokenr"r~r)
r0r[r��	cli_utilsZ!create_client_from_parsed_globalsZ_sessionr�r�r�r�
subprocessr*r))r&r�Zparsed_globalsr0r}r�Zauth_token_resr#r%r!r"r*rrr�	_run_main�s

zCodeArtifactLogin._run_mainN)rBrCrD�__doc__rFr\r`r��NAMEZDESCRIPTION�list�keysZ	ARG_TABLEr�r�r�r�rrrrr|0sR


r|)r:r.rYr+r�rKrZdateutil.tzrZdateutil.relativedeltarZbotocore.utilsrZ
awscli.compatrrrZawscli.customizationsr	r�Zawscli.customizations.commandsr
r�objectr rFr\r`r|rrrr�<module>s$=Gq