Current File : //proc/353637/root/lib/python3/dist-packages/uaclient/cli/__pycache__/config.cpython-312.pyc
�

��Jh�*���ddlmZmZmZmZmZmZmZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZddlmZddlmZddlmZdd	lmZdd
lmZmZddlmZmZej@�Z!d�Z"d
�Z#e
jHd��Z%e
jHd��Z&edejNejNe#eedejPd��g��g��Z)edejTejTe%eedejVjYdj[ej\�����g��g��Z/edej`ej`e&eedejbjYdj[ej\���d��g��g��Z2edejfejhe"ejje)e/e2g��Z6y) �)�apt_news�config�entitlements�event_logger�
exceptions�http�messages)�_is_attached)�
AptProxyScope)�cli_util)�ProArgument�ProArgumentGroup�
ProCommand)�HelpCategory)�ApplicationStatus)�state_files)�LXDGuestAttachEnum)�configure_livepatch_proxy�unconfigure_livepatch_proxy)�configure_snap_proxy�unconfigure_snap_proxyc�<�ddlm}|�jd�y)Nr��
get_parserr)�uaclient.clir�print_help_for_command)�args�cfg�kwargsrs    �5/usr/lib/python3/dist-packages/uaclient/cli/config.py�
action_configr!s��'��L�'�'��1��c��|jr�|jtjvrMtjdj|j�dj
tj����tdj|jt||jd����ytttjD�cgc]
}t|���c}�dz�}d	|zd
z}tjD])}t|j|t||d�����+|js|jr3|js|jrtt j"�yyycc}w)z�Perform the 'config show' action optionally limit output to a single key

    :return: 0 on success
    :raise UbuntuProError: on invalid keys
    z'{}'�, ��arg�choicesz
{key} {value}N��key�valuer�z{key: <z	} {value})r)r�UA_CONFIGURABLE_KEYSr�InvalidArgChoice�format�join�print�getattr�str�max�len�global_apt_http_proxy�global_apt_https_proxy�ua_apt_http_proxy�ua_apt_https_proxyr	�CLI_CONFIG_GLOBAL_XOR_UA_PROXY)rrr�x�	col_width�row_tmplr)s       r �action_config_showr=#s:���x�x��8�8�6�6�6�6��-�-��M�M�$�(�(�+��	�	�&�"=�"=�>��
�	��"�"��H�H�G�C����4�$@�
#�
�	
�
��C��)D�)D�E�A��Q��E�F��J�K�I��9�$�{�2�H��*�*�G��
�h�o�o�#�W�S�#�t�-D�o�E�F�G�	�!�!�S�%?�%?�����!7�!7�
�h�5�5�6�"8�&@��
Fs�E>c��
�ddlm}|�}	|jjd�\}}|tjvrE|jd�t
jddjtj��	��|j�s'|jd�t
j|�
��tt||d��t k(r<|j#�dvrt
jd
d�	��|j#�dk(}|dvr�|jd�d}|dk(rt$j&}nt$j(}t%j*|||�||i}t-d#i|��t.j0j3|�}	|	j5�\}
}|
t6j8k(�rt;d#i|���n||j<vr�|jd�d}|dk(rt$j>}nt$j@}t%j*|||�t!|jBxs|jD�}|r*tGtHjJjMdd���tOjP|tRjT||�d|_!d|_"�n.||jV|jXzv�r$d|vrdnd}|dk(rt$j>}nt$j@}||jVvrMtGtHjZjMdjM|�djM|����d|z}t%j*|||�t!|j\xs|j^�}|r*tGtHjJjMdd���tOjP|tRj`||�d|_.d|_/n�|dvr,	tc|�}|dkrt	djM|���n�|d k(r7|rtgjh|�n�tjjljo�n�|d!k(r}tq|�jrst
jt��tjjvjytkjzt}j~|j#���"��t�|||�y#t$r3|jd�t
jd|j���wxYw#t$r4|jd�tGd�t
jd||���wxYw)$zMPerform the 'config set' action.

    @return: 0 on success, 1 otherwise
    rr�=z
config setz
<key>=<value>)�expected�actual�<key>r$r%)r&N)�true�falsez<value>ztrue, falserC��
http_proxy�https_proxy�_r�zpro scoped aptz
global apt)�
current_proxy�previous_proxy�https�apt_{}_proxy�global_apt_{}_proxy��old�new�global_)�update_messaging_timer�metering_timerzInvalid interval for {}�r(r�lxd_guest_attach��guest_attach�)Arr�key_value_pair�split�
ValueErrorrr�GenericInvalidFormatrr,r-r/�strip�EmptyConfigValue�typer1�bool�lowerr�PROXY_VALIDATION_SNAP_HTTP_URL�PROXY_VALIDATION_SNAP_HTTPS_URL�validate_proxyrr�	livepatch�LivepatchEntitlement�application_statusr�ENABLEDr�ua_scoped_proxy_options�PROXY_VALIDATION_APT_HTTP_URL�PROXY_VALIDATION_APT_HTTPS_URLr5r6r0r	�WARNING_APT_PROXY_OVERWRITEr.r�configure_apt_proxyr�UACLIENT�&deprecated_global_scoped_proxy_options�global_scoped_proxy_options�WARNING_CONFIG_FIELD_RENAMEr7r8�GLOBAL�int�InvalidPosIntConfigValuer�update_apt_newsr�apt_news_contents_file�deleter
�is_attached�UnattachedError�lxd_pro_config_file�write�LXDProConfigr�
from_value�setattr)
rrrr�parser�set_key�	set_value�
protocol_type�validate_url�entitlement�livepatch_statusrH�
unset_currents
             r �action_config_setr�Bs���(�
�\�F�
�!�0�0�6�6�s�;�����f�1�1�1��%�%�l�3��)�)�����6�+F�+F�!G�
�	
��?�?���%�%�l�3��)�)�g�6�6��G�C��$�'�(�D�0��?�?��$5�5��-�-��}��
��O�O�%��/�	��/�/��
�
�c�*�1�-�
��F�"��>�>�L��?�?�L����M�9�l�C��9�%���&�v�&�"�,�,�A�A�#�F��)�<�<�>���!��0�8�8�8�%�/��/�	�C�/�/�	/��
�
�c�*�1�-�
��F�"��=�=�L��>�>�L����M�9�l�C���%�%�C��)C�)C�
�
����4�4�;�;�"2�<�<��
�
	�$�$���'�'��)�	
�%)��!�%)��"�	��2�2�

�
)�
)�	*�
�$+�g�#5��6�
��F�"��=�=�L��>�>�L��c�@�@�@���4�4�;�;�&�-�-�m�<�-�4�4�]�C�<��
� �'�)�G����M�9�l�C��S�2�2�L�c�6L�6L�M�
����4�4�;�;�".�?O�<��
�
	�$�$���%�%�w�	�	
�!%���!%���	��
�
	��I��I��1�}� �!:�!A�!A�'�!J�K�K��
�J�	���$�$�S�)��.�.�5�5�7�	�&�	&��C� �,�,��,�,�.�.��'�'�-�-��$�$�/�:�:�9�?�?�;L�M�
�	
��C��)�$��{�
��%�%�l�3��-�-�$�T�-@�-@�
�	
�
��P�	��)�)�,�7��"�I��5�5��9��
�		�s�S+�4*T*�+<T'�*=U'c�&�ddlm}|jtjvrL|�}|jd�t
jddjtj����|jdvr~|jjd�d}t|�	�tjj|�}|j�\}}|tj k(�r�t#|�	��n�|j|j$vr2t'j(|t*j,|jd
��n6|j|j.|j0zvr�|j|j.vrxd|jvrdnd}t2j5t6j8j;d
j;|�dj;|����d|jz|_t'j(|t*j<|jd
�nP|jdk(rAt>j@jCt?jDtFjH���tK||jd
�y)zOPerform the 'config unset' action.

    @return: 0 on success, 1 otherwise
    rrzconfig unsetrBr$r%rErH)r�NrLrrMrNrOrRrVrW)&rrr)rr,rrr-r/r[rrrfrgrhrrirrjrrnrrorprq�event�infor	rrr.rsrr{r|r}r�OFFr)	rrrrr�r�r�r�rHs	         r �action_config_unsetr��s���(��x�x�v�2�2�2�����%�%�n�5��)�)�����6�+F�+F�!G�
�	
��x�x�0�0������s�+�A�.�
��]�;�"�,�,�A�A�#�F��)�<�<�>���!��0�8�8�8�'�m�D�	
���S�0�0�	0��$�$���'�'����4�	
�
����2�2�

�
)�
)�	*�
��8�8�s�A�A�A�'.�$�(�(�':�G��M��J�J��4�4�;�;�&�-�-�m�<�-�4�4�]�C�<��
�!�4�8�8�+�D�H��$�$�S�-�*>�*>����$�O�	
���'�	'��'�'�-�-��$�$�2D�2H�2H�I�	
��C����4� �r"�showr)�?)�help�nargs)�	arguments)r��description�action�argument_groups�setrZr$)�options)r��unset)r��metavarr)r�r�r��
help_category�subcommandsN)7�uaclientrrrrrrr	�(uaclient.api.u.pro.status.is_attached.v1r
�uaclient.aptrrr�uaclient.cli.commandsr
rr�uaclient.cli.parserr�(uaclient.entitlements.entitlement_statusr�uaclient.filesr�uaclient.files.user_config_filer�uaclient.livepatchrr�
uaclient.snaprr�get_event_loggerr�r!r=�assert_rootr�r��CLI_CONFIG_SHOW_DESC�CLI_CONFIG_SHOW_KEY�show_subcommand�CLI_CONFIG_SET_DESC�CLI_CONFIG_SET_KEY_VALUEr.r/r,�set_subcommand�CLI_CONFIG_UNSET_DESC�CLI_CONFIG_UNSET_KEY�unset_subcommand�CLI_ROOT_CONFIG�CLI_CONFIG_DESC�OTHER�config_commandrYr"r �<module>r�s������B�&�!�K�K�,�F�&�>��G�%��%�%�'��
�7�>
���G%��G%�T
���-
��-
�`�
�	�	&�	&��-�-������ <� <�C���	
���� �	�	�	%�	%��,�,����$� �9�9�@�@�$(�I�I�f�.I�.I�$J�A���	�	
�
���*��	�	'�	'��.�.����� �5�5�<�<�$(�I�I�f�.I�.I�$J�=��"��
�	
����,��	�	!�	!��(�(���$�$� �.�2B�C�
�r"