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__/disable.cpython-38.pyc
U

��Jh�*�@s�ddlZddlZddlZddlmZmZmZddlmZm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZmZddlmZddlmZddlmZmZmZdd	lmZdd
lm Z e�!�Z"e�#e�$e%��Z&ej'e(eeee(e(e(d�dd
�Z)dd�dd�Z*ej+ej,e�-ej.�e�/d�dd�����Z0ede
j1e
j2e0ej3eede
j4j5d�6e
j7e�'�d��d�ddd�ede
j8j5dd�dd �ed!e
j9j5d"d#�dd"d$gd"d%�ed&e
j:dd �gd'�gd(�Z;dS))�N)�Any�Dict�List)�config�contract�entitlements�event_logger�
exceptions�messages�status�util)�ProgressWrapper)�ServiceWithDependencies�
_dependencies)�_enabled_services)�cli_util)�ProArgument�ProArgumentGroup�
ProCommand)�HelpCategory)�CanDisableFailure)�cfg�service�all_dependencies�enabled_service_names�called_name�
service_titlecCs�g}|D]<}|j|ks|j|kr"q|jD]}|j|kr(|�|j�q(q|D]:}	t�||	�}
tjj||
d�}tj	|d�sJt
j||
d��qJdS)N)Zservice_being_disabled�dependent_service)�msg)�nameZ
depends_on�appendrZ	get_titler
ZDEPENDENT_SERVICE�formatrZprompt_for_confirmationr	ZDependentServiceStopsDisable)rrrrrrZdependent_services�sZrequirementrZdependent_service_titleZuser_msg�r#�6/usr/lib/python3/dist-packages/uaclient/cli/disable.py�prompt_for_dependency_handlings*

���r%T)�
update_statusc	Cs�|j}|dk	r|}|rt�}nttj|d��}|�|�\}}|s�t�|j�|dk	r�t|t	�r�|j
dk	r�t�|j
j�tj
|j
j|j
j|jd�nt�|j�|r�tj|d�|S)aPerform the disable action on a named entitlement.

    :param entitlement_name: the name of the entitlement to enable
    :param cfg: the UAConfig to pass to the entitlement
    :param json_output: output should be json only

    @return: True on success, False otherwise
    N��
assume_yes)Z	error_msgZ
error_coder�r)�enabled_variantr
r�CLIEnableDisableProgress�disable�eventZservice_failedr�
isinstancer�message�infor�errorZservice_processedr)	Zentitlementr�json_outputr(r&�variant�progress�ret�reasonr#r#r$�perform_disable>s.

�
�r7zpro disablecKs~g}g}g}g}tjddd�}|jdk}|j}	t�|�}
|jrP|	rPtjddd��t	|dg�}t
�||�\}}
d	d
�t|�j
D�}t|�j}d}|D�]�}t
j|||jd�}|j}|d
k	r�|}|	�s:zt||j||||jd�WnZtjk
�r8}z8t�|�|
|j�|
tjj|jd��d}WY�q�W5d
}~XYnX|�rHt�}nttj|	d��}|��|_z�|�|�\}}t j |d�|�s�d}|�!|�|d
k	�rt"|t#��r|j$d
k	�r|
|j$j�|�!d|j|j$j|j$jd��n2|�!|�|�%�}|�rd|d<|
tj&jdd��Wq�tjk
�r�}zNd}|�!|�|
|j�|
tj'j|jd��|�!d|j|j|j(|j)d��W5d
}~XYq�Xq�|
�rd}dd�*t
j+|d��d}d�*t,j-|dddd��}tj.dd�*|
�|d�}|
|j�|�!dd
|j|j(|j)d��t/�0|�}|�1�|�rp|�2�|�2�|�r2dnd |d!<||d"<||d#<||d$<||d%<t3t4j5|t6j7dd&��|�rzd'Sd(S))zbPerform the disable action on a list of entitlements.

    @return: 0 on success, 1 otherwise
    ZsuccessF)Z_schema_version�result�needs_reboot�json�--purge�--assume-yes)Zoption1Zoption2rcSsg|]
}|j�qSr#)r)�.0r"r#r#r$�
<listcomp>�sz"action_disable.<locals>.<listcomp>T)rr�purgeN)rr)�titler'r))�typerr/�message_coder9zdisable operation)�	operation)rArr/rB�additional_infozTry �, �.�
�P)�widthZbreak_long_wordsZbreak_on_hyphensr,)rCZinvalid_service�service_msg�systemZfailurer8�processed_services�failed_services�errors�warnings)�clsZ	sort_keysr�)8rZJSON_SCHEMA_VERSIONr!r(rZ&create_interactive_only_print_functionr?r	ZInvalidOptionCombination�getattrrZget_valid_entitlement_namesrZenabled_servicesr�servicesZentitlement_factoryr*r%rr@ZUbuntuProError�LOGZ	exceptionrr
Z
ENABLE_FAILEDr
r+Zcalculate_total_disable_stepsZtotal_stepsr,rr r.rr/Z_check_for_rebootZENABLE_REBOOT_REQUIRED_TMPLZDISABLE_FAILED_TMPLZmsg_coderD�join�valid_services�textwrapZwrapZInvalidServiceOpErrorrZUAContractClientZupdate_activity_token�sort�printr:�dumpsrZDatetimeAwareJSONEncoder)�argsr�kwargsrLrMrNrOZ
json_responser2r(Zinteractive_only_print�namesZentitlements_foundZentitlements_not_foundrrr5Zent_nameZentr3�er4Zdisable_retr6Zent_reboot_requiredZvalid_namesrJ�errZcontract_clientr#r#r$�action_disablels(	�
�
�
��

��


�
�

���	
��

���
����
��

��r`r,rrEr))ZoptionsZstore�+)�help�action�nargsr<)Zcommand�
store_true)rbrcz--formatZcli)�defaultr:)rbrc�choicesrfr;)Z	arguments)rbZdescriptionrcZ
help_categoryZargument_groups)<r:ZloggingrW�typingrrrZuaclientrrrrr	r
rrZuaclient.apir
Z+uaclient.api.u.pro.services.dependencies.v1rrZ-uaclient.api.u.pro.status.enabled_services.v1rZuaclient.clirZuaclient.cli.commandsrrrZuaclient.cli.parserrZ(uaclient.entitlements.entitlement_statusrZget_event_loggerr-Z	getLoggerZreplace_top_level_logger_name�__name__rTZUAConfig�strr%r7Zverify_json_format_argsZassert_rootZassert_attachedZ&_raise_enable_disable_unattached_errorZassert_lock_filer`ZCLI_ROOT_DISABLEZCLI_DISABLE_DESCZOTHERZCLI_DISABLE_SERVICEr!rUrVZCLI_ASSUME_YESZCLI_FORMAT_DESCZ	CLI_PURGEZdisable_commandr#r#r#r$�<module>s�(
� �.
6���
�������