%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�Hcf����dZddlZddlZddlmZddlmZmZmZm	Z	m
Z
ddlmZ
ddlmZmZddlmZddlmZmZdd	lmZdd
lmZdZdZej8e
j:e��Zd
efd�Z d
ede!fd�Z"d�Z#y)a%
Update messaging text for use in MOTD and APT custom Ubuntu Pro messages.

Messaging files will be emitted to /var/lib/ubuntu-advantage/message-* which
will be sourced by apt-hook/hook.cc and various /etc/update-motd.d/ hooks to
present updated text about Ubuntu Pro service and token state.
�N)�exists)�contract�defaults�messages�system�util)�_updates)�ContractExpiryStatus�_is_attached)�UAConfig)�ESMAppsEntitlement�ESMInfraEntitlement)�ApplicationStatus)�noticeszmotd-contract-statusz6/usr/lib/update-notifier/update-motd-updates-available�cfgc���|j}|jdd�}|jdi�jdi�jdd�}tj|�}|j	||�}|jdi�jdi�jdd�}|�A||j
jk7r'||ddd<|j
j|�yyy)N�machineToken��machineTokenInfo�contractInfo�id�effectiveTo)�
machine_token�getr�UAContractClient�get_contract_machine�machine_token_file�contract_expiry_datetime�write)r�
orig_tokenr�contract_id�contract_client�resp�resp_expirys       �A/usr/lib/python3/dist-packages/uaclient/timer/update_messaging.py�update_contract_expiryr&!s����"�"�J��N�N�>�2�6�M����)�2�.�	��^�R�	 �	��T�4���
�/�/��4�O��/�/�
�{�K�D����#�R�(�	��^�R�	 �	��]�D�	!��	���3�1�1�J�J�J�
�	�%�&�~�6��	
�	���$�$�Z�0�
K�	 ��returnc��t|�}|jsytjd�tj
j
|jdt�}|j}|j}|tjjtjjtjjfvr.t!|�t|�}|j}|j}|tj"jtj$jfvrCt'j(t&j*j,�t/j0|�y|tjjk(rtt'j(t&j*j,�t/j2|t4j6j9|�j;|��dz�y|tjjk(r�t'j(t&j*j,�t<j>|z}|j@jB}|�d}n|jEd�}t/j2|t4jFj9|�j;||��dz�y|tjjk(�rnt'jHt&j*j,�d	}d
}	t/jJ�rQtM|�jO�\}
}|
tPjRk(r�d}tU|�jVjX}	ndt/jZ�rPt]|�jO�\}}|tPjRk(r!d}tU|�jVj^}	|	d
k(r(t/j2|t4j,dz�yt/j2|t4j`j9|	�j;|	|�
�dz�y)z�Emit human-readable status message used by motd.

    Used by /etc/update.motd.d/91-contract-ua-esm-status

    :param cfg: UAConfig instance for this environment.
    Fz&Updating Ubuntu Pro messages for MOTD.r)�remaining_daysz

�Unknownz%d %b %Y)�expired_dater*zn/arz	esm-infrazesm-apps)�pkg_num�serviceT)1r�is_attached�LOG�info�os�path�join�data_dir�MOTD_CONTRACT_STATUS_FILE_NAME�contract_status�contract_remaining_daysr
�ACTIVE_EXPIRED_SOON�value�EXPIRED_GRACE_PERIOD�EXPIREDr&�ACTIVE�NONEr�remove�Notice�CONTRACT_EXPIREDr�ensure_file_absent�
write_filer�CONTRACT_EXPIRES_SOON�	pluralize�formatr�!CONTRACT_EXPIRY_GRACE_PERIOD_DAYSrr�strftime�CONTRACT_EXPIRED_GRACE_PERIOD�add�is_current_series_active_esmr�application_statusr�ENABLED�api_u_pro_packages_updates_v1�summary�num_esm_infra_updates�is_current_series_ltsr
�num_esm_apps_updates�CONTRACT_EXPIRED_WITH_PKGS)
r�is_attached_info�motd_contract_status_msg_path�
expiry_statusr*�grace_period_remaining�exp_dt�
exp_dt_strr.r-�esm_infra_status�_�esm_apps_statuss
             r%�update_motd_messagesr]:s���$�C�(���'�'���H�H�
5�6�$&�G�G�L�L����j�"@�%�!�%�4�4�M�%�=�=�N���0�0�6�6��1�1�7�7��$�$�*�*���
	�s�#�'��,��(�8�8�
�)�A�A����#�#�)�)��!�!�'�'���	���w�~�~�6�6�7��!�!�"?�@�D�C
�.�B�B�H�H�	H����w�~�~�6�6�7����)��*�*�4�4�^�D�K�K�-�
L�
��
�	
�~�q
�.�C�C�I�I�	I����w�~�~�6�6�7��6�6��G�	��'�'�@�@���>�"�J�����4�J����)��2�2�<�<��
��f�'�5����

�		
�\�I
�.�6�6�<�<�	<����G�N�N�3�3�4������.�.�0�"5�c�":�"M�"M�"O���a��#4�#<�#<�<�%��7����'�/�/���
)�
)�
+�!3�C�!8�!K�!K�!M��O�Q��"3�";�";�;�$��7����'�.�.���a�<����-��)�)�F�2�
��
���-��3�3�=�=�g�F�M�M�#�#�N���	�
�r'c��tt�r	tjtdg�yy#t$r}t
j
|�Yd}~yd}~wwxYw)Nz--force)r�UPDATE_NOTIFIER_MOTD_SCRIPTr�subp�	Exceptionr0�	exception)�excs r%�refresh_motdrd�sJ���)�*�	��K�K�4�i�@�A�+���	��M�M�#����	�s�.�	A�A�A)$�__doc__�loggingr2�os.pathr�uaclientrrrrr�&uaclient.api.u.pro.packages.updates.v1r	rN�(uaclient.api.u.pro.status.is_attached.v1r
r�uaclient.configr�uaclient.entitlementsr
r�(uaclient.entitlements.entitlement_statusr�uaclient.filesrr6r_�	getLogger�replace_top_level_logger_name�__name__r0r&�boolr]rd�r'r%�<module>rts�����	��?�?���%�I�F�"�!7��<���g���:��:�:�8�D�E��1��1�2d�h�d�4�d�N
r'

Zerion Mini Shell 1.0