HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3/dist-packages/uaclient/cli/__pycache__/__init__.cpython-38.pyc
U

��Jh%�@s�dZddlZddlZddlmZmZmZmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4e�5�Z6e�7e�8e9��Z:dZ;eeeeeeeeee!e#e%e*e,e.e0gZ<dd�Z=d&dd�dd�Z>dd�dd�Z?dd �Z@d!d"�ZAeAd'd#d$��ZBe9d%k�r�e�CeB��dS)(z2Client to manage Ubuntu Pro services on a machine.�N)
�apt�defaults�event_logger�
exceptions�http�lock�log�messages�util�version)�api_command)�attach_command)�auto_attach_command)�collect_logs_command)�config_command)�cve_command)�cves_command)�detach_command)�disable_command)�enable_command)�fix_command)�help_command)�HelpCategory�ProArgumentParser)�refresh_command)�security_status_command)�status_command)�system_command)�UAConfig)�get_user_or_root_log_file_pathZprocCs�ttdtjjtdd�d�}|�tjdtjjtd��|j	ddtj
d	�|�tjdtj
�|j	d
dt��tj
jtd�d�|�tjd
tj
jtd��|jtjd
dd�}d|_tD]}|�|�q�|S)NFz	<command>)�name�command)�progZ
use_main_helpZepilogz
-h, --help)r z--debug�
store_true)�action�help�	--versionr)r$rr%r!)�title�dest�metavarT)r�NAMEr	ZCLI_HELP_EPILOG�formatZadd_help_entryr�FLAGSZCLI_HELP_FLAG_DESC�add_argumentZCLI_ROOT_DEBUGrZget_versionZCLI_ROOT_VERSIONZadd_subparsersZCLI_AVAILABLE_COMMANDSZrequired�COMMANDS�register)�parserZ
subparsersr!�r1�7/usr/lib/python3/dist-packages/uaclient/cli/__init__.py�
get_parser?sP�������r3)�returncCsX|r|jdkst|dd�dkr"dSt��}|rTt�d|�tjtj	j
|d�tjd�dS)NZapir+���json�yamlzNew version available: %s)r��	file_type)
r!�getattrrZcheck_for_new_version�LOG�warning�event�infor	ZWARN_NEW_VERSION_AVAILABLE_CLIr+�sys�stderr)�cmd_argsZnew_versionr1r1r2�_warn_about_new_versionks �����rCcCsV|jdkrRtj��sRt|d�r,|jdkr,dSt�d�tj	t
jj|jd�tjd�dS)z4Warn users that the user readable output may change.)�statuszsecurity-statusr+r6Nz.Not in a tty and human-readable command called)r!r9)
r!r@�stdout�isatty�hasattrr+r<r=r>r?r	ZWARNING_HUMAN_READABLE_OUTPUTrA�rBr1r1r2�_warn_about_output_redirection�s��
��rIcCsT|jdkrPt�|j�t|d�rP|jdkr8t�tjj�|jdkrPt�tjj	�dS)z3Set the right event mode based on the args provided)Zattach�detach�enable�disablerDr+r7r8N)
r!r>Zset_commandrGr+�set_event_moderZEventLoggerModeZJSONZYAMLrHr1r1r2rM�s



rMcs�fdd�}|S)Nc
s�z�||�WStk
rNt�d�ttjtjd�t�	�t�
d�Y�n�tjk
�r4}z�dt
|�kr�tj}t�d�r�tj}|j|jd�}tj|j|jd�tj|jtjd�nJtjd	|j|d
�tjj|j|jd�}tj|j|jd�tj|jtjd�t�	�t��t�t�
d�W5d}~XY�n�tjk
�r�}zntj}t�d��r`tj}|j|jd�}tj|j|jd�tj|jtjd�t�	�t��t�t�
d�W5d}~XY�ntjk
�rR}znt�|j�tj|j|j|j d�tjd
�|j�tjd�t!|tj"��s(t�	�t��t�t�
|j#�W5d}~XYn�t$k
�r�}zlt�d�t�	�tjtj%jt
|�t&�d�jtjd�tjt'|dt
|��dd�t��t�t�
d�W5d}~XYnXdS)N�KeyboardInterrupt)�file�ZCERTIFICATE_VERIFY_FAILEDzca-certificates)�url)�	error_msg�
error_code)Zinfo_msgr:zFailed to access URL: %s)�exc_info)rQ�cause_error)rRrS�additional_infoz{}z&Unhandled exception, please file a bug)rRZlog_path�msg�	exception)rRZ
error_type)(rNr<�error�printr	ZCLI_INTERRUPT_RECEIVEDr@rArZclear_lock_file_if_present�exitrZConnectivityError�strZ&SSL_VERIFICATION_ERROR_CA_CERTIFICATESrZis_installedZ%SSL_VERIFICATION_ERROR_OPENSSL_CONFIGr+rQr>rWr r?rXZE_CONNECTIVITY_ERRORrUZprocess_eventsrCZPycurlCACertificatesErrorZUbuntuProErrorZmsg_coderV�
isinstanceZ
LockHeldErrorZ	exit_code�	ExceptionZUNEXPECTED_ERRORrr;)�args�kwargs�excZtmplrW�e��funcr1r2�wrapper�s�

���
���z#main_error_handler.<locals>.wrapperr1)rdrer1rcr2�main_error_handler�sSrfc
Cspt�tjdtjd�t�}t�|j|j�|s8tj}t	�}|dd�}|s`|�
�t�d�|ddkrtd|d<d|kr�|�d�}|d|�}||dd�}n|}g}|j
|d�}|jr�t�tj�}|�tj�t�d	��|�t|�|j}	|j}
tj|	|
d
�t�d|�|��dd
�tt��� ��D�}|�rLt�d|�t!|�|j"|||d�}t#|�|S)N�	log_level�log_filerPrrr&z--)r_Z	ubuntupro)�
http_proxy�https_proxyzExecuted with sys.argv: %rcSsg|]\}}d�||��qS)z{}={})r+)�.0�k�vr1r1r2�
<listcomp>#s�zmain.<locals>.<listcomp>z'Executed with environment variables: %r)�cfg�
extra_args)$rZsetup_cli_loggingrZCONFIG_DEFAULTSrrgrhr@�argvr3Z
print_helpr[�index�
parse_args�debug�loggingZ
StreamHandlerrAZsetLevel�DEBUG�	getLoggerZ
addHandlerrMrirjrZconfigure_web_proxyr<Zwarn_about_invalid_keys�sortedr
Zget_pro_environment�itemsrIr$rC)
Zsys_argvror0Z
cli_argumentsZdouble_dash_indexZpro_cli_argsrpr_Zconsole_handlerrirjZpro_environmentZreturn_valuer1r1r2�main�sR�

�rz�__main__)N)N)D�__doc__rur@Zuaclientrrrrrrrr	r
rZuaclient.cli.apirZuaclient.cli.attachr
Zuaclient.cli.auto_attachrZuaclient.cli.collect_logsrZuaclient.cli.configrZuaclient.cli.cverZuaclient.cli.cvesrZuaclient.cli.detachrZuaclient.cli.disablerZuaclient.cli.enablerZuaclient.cli.fixrZuaclient.cli.helprZuaclient.cli.parserrrZuaclient.cli.refreshrZuaclient.cli.security_statusrZuaclient.cli.statusrZuaclient.cli.systemrZuaclient.configrZuaclient.logrZget_event_loggerr>rwZreplace_top_level_logger_name�__name__r<r*r.r3rCrIrMrfrzr[r1r1r1r2�<module>sf0�,W>