%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�Hcf� ��8�ddlZddlZddlZddlZddlZddlmZmZddlZddl	m
Z
mZmZm
Z
ddlmZmZddlmZmZmZddlmZddlmZddlmZmZmZmZmZmZdd	l m!Z!m"Z"ejFe
jHe%��Z&Gd
�de�Z'Gd�d
e�Z(d�Z)dedee'de*fd�Z+dejdeejde*fd�Z,de-de*fd�Z.de(de*fd�Z/dedee0dee(fd�Z1edefd��Z2dedee-fd�Z3dedee-fd�Z4de-de-fd �Z5defd!�Z6y)"�N)�List�Optional)�defaults�messages�system�util)�ContractExpiryStatus�_is_attached)�ensure_apt_pkg_init�get_pkg_version�version_compare)�get_cloud_type)�UAConfig)�
BoolDataValue�
DataObject�DatetimeDataValue�Field�StringDataValue�	data_list)�notices�state_filesc��eZdZedee�d��edee�d��eded��edee�d��edeee��d��gZdddddd	�dee	e
dee	e
deedee	e
dee	e	e
f
d
�Zy)�AptNewsMessageSelectors�	codenamesF��required�clouds�pro�
architectures�packagesN�rrrrr c�J�||_||_||_||_||_y�Nr!)�selfrrrrr s      �3/usr/lib/python3/dist-packages/uaclient/apt_news.py�__init__z AptNewsMessageSelectors.__init__*s(��#���������*��� ��
�)
�__name__�
__module__�__qualname__rrrr�fieldsrr�str�boolr&�r'r%rrs���
�k�9�_�5��F�
�h�	�/�2�U�C�
�e�]�U�3�
�o�y��9�E�J�
��	�)�O�"<�=��	
��F�*.�&*�"�-1�.2�
!��D��I�&�
!���c��#�	
!�
�d�^�
!� ��S�	�*�

!��4��S�	�?�+�
!r'rc
��eZdZede�eded��eded��edee��gZddd�de	jde
e	jde
edeefd	�Z
y)
�AptNewsMessage�begin�endFr�	selectors�linesN)r2r3c�<�||_||_||_||_yr#)r1r2r3r4)r$r1r2r3r4s     r%r&zAptNewsMessage.__init__Bs ����
����"�����
r')r(r)r*rrrrrr+�datetimerrr,r&r.r'r%r0r0:s���
�g�(�)�
�e�&��7�
�k�2�U�C�
�g�y��1�2�	�F�,0�7;��� � ���h�'�'�
(�	�
�3�4���C�y�
r'r0c���	|\}}}t|�}|�yt	||�}t|dk(xr|dv|dkxr|dv|dkDxr|dvg�S#t$rtjd|�YywxYw)NzInvalid package selector: %rFr)z==�<=�>=)�<r8)�>r9)�
ValueError�LOG�warningrr
�any)�package_selector�package_name�version_operator�package_version�installed_package_version�version_comparisons      r%�_does_package_selector_applyrFPs����:J�7��&��!0�� =�� �(��(�!�?����#�a�'�;�$�(:�:�
�!�
#�
G�(8�K�(G�
�!�
#�
G�(8�K�(G�
	
�	�	�������2�4D�E���s�A�A-�,A-�cfgr3�returnc��|�y|j�+tj�j|jvry|j�t�\}}|�y||jvry|j�#|jt|�jk7ry|j�!tj�|jvry|j�-t|jD�cgc]
}t|���c}�syycc}w)NTF)rr�get_release_info�seriesrrrr
�is_attachedr�
get_dpkg_archr r?rF)rGr3�cloud_id�failr@s     r%�do_selectors_applyrPhs���������&��"�"�$�+�+�9�3F�3F�F�����#�'�)���$�����9�+�+�+���}�}� ��=�=�L��-�9�9�9�����*����!��)@�)@�@�����%��)2�(:�(:�
�$�-�-=�>�
�
����
s�!C<r1r2c���tjjtjj�}||kry|tjd��z}|�||kDr|}n|}||kDryy)NF�)�daysT)r6�now�timezone�utc�	timedelta)r1r2rT�one_month_after_begin�
end_to_uses     r%�do_dates_applyrZ�sk���
�
�
�
�� 1� 1� 5� 5�
6�C�
�U�{��!�H�$6�$6�B�$?�?��
�{�c�1�1�*�
��
�
�Z���r'�cc�8�tj|�ddk(S)Nr�C)�unicodedata�category)r[s r%�is_control_charr`�s������"�1�%��,�,r'�msgc	��t|j�dkryt|j�dkDry|jD]6}t|D�cgc]
}t|���c}�ryt|�dkDs�6yycc}w)N�F��MT)�lenr4r?r`)ra�liner[s   r%�is_message_validrh�sn��
�3�9�9�~����
�3�9�9�~�����	�	����D�1�q���"�1�2���t�9�r�>��	���2s�A9
rc��|D]�}	tj|�}t|�stj	d|��;t
|j|j�stj	d|��rt||j�stj	d|���|cSy#t$r }tj	d|�Yd}~��d}~wwxYw)Nzmsg failed parsing: %rzmsg not valid: %rzmsg dates don't apply: %rzmsg selectors don't apply: %r)r0�	from_dict�	Exceptionr=�debugrhrZr1r2rPr3)rGr�msg_dictra�es     r%�select_messagero�s������	� �*�*�8�4�C� ��$��I�I�)�3�/���c�i�i����1��I�I�1�3�7��!�#�s�}�}�5��I�I�5�s�;���
�� ���	��I�I�.��2���	�s�B(�(	C�1C�Cc�~�tjtjd��t	j
�}t	j||jdtj��}|j�tj|j�}tj|tj��S)NT)�exist_ok�)�hash�destdir)�cls)�os�makedirsr�UAC_RUN_PATH�apt_pkg�Acquire�AcquireFile�apt_news_url�runr�	load_file�destfile�json�loadsr�DatetimeAwareJSONDecoder)rG�acq�
apt_news_file�apt_news_contentss    r%�fetch_aptnews_jsonr��s����K�K��%�%��5�
�/�/�
�C��'�'��S�
�
�B��0E�0E��M��G�G�I��(�(��)?�)?�@���:�:���)�)��r'c��t|�}t||jdg��}tj	d|�|�dj|j�Sy)Nrz
using msg: %r�
)r�ro�getr=rl�joinr4)rG�	news_dictras   r%�fetch_and_process_apt_newsr��sL��"�3�'�I�
��i�m�m�J��;�
<�C��I�I�o�s�#�
���y�y����#�#�r'c��t|�}|j}|j}|tjj
k(r=t
jtjj�tjSt
jtjj�|tjj
k(r/tjj|�j|��S|tj j
k(rot"j$|z}|j&j(}|�d}n|j+d�}tj,j|�j||��Sy)z4
    :return: str if local news, None otherwise
    )�remaining_daysN�Unknownz%d %b %Y)�expired_dater�)r
�contract_status�contract_remaining_daysr	�EXPIRED�valuer�add�Notice�CONTRACT_EXPIREDr�remove�ACTIVE_EXPIRED_SOON�CONTRACT_EXPIRES_SOON�	pluralize�format�EXPIRED_GRACE_PERIODr�!CONTRACT_EXPIRY_GRACE_PERIOD_DAYS�machine_token_file�contract_expiry_datetime�strftime�CONTRACT_EXPIRED_GRACE_PERIOD)rG�is_attached_info�
expiry_statusr��grace_period_remaining�exp_dt�
exp_dt_strs       r%�local_apt_newsr��s?��$�C�(��$�4�4�M�%�=�=�N��,�4�4�:�:�:����G�N�N�3�3�4��(�(�(��N�N�7�>�>�2�2�3��,�@�@�F�F�F��-�-�7�7��G�N�N�)�O�
�	
��,�A�A�G�G�G��6�6��G�	��'�'�@�@���>�"�J�����4�J��5�5�?�?��
�
�&�#�4J��
�	
�r'�newsc�h�d}|jd�D]}|dj|�z
}�|dz
}|S)Nz#
r�z# {}
)�splitr�)r��resultrgs   r%�format_news_for_apt_updater�s@��
�F��
�
�4� �(���(�/�/�$�'�'��(�
�e�O�F��Mr'c��	t|�}|st|�}|rJtjj	|�t|�}tjj	|�ytjj�tjj�y#t$r\}tjd|�tjj�tjj�Yd}~yd}~wwxYw)Nz2something went wrong while processing apt_news: %r)r�r�r�apt_news_raw_file�writer��apt_news_contents_file�deleterkr=rl)rGr��apt_update_formatted_newsrns    r%�update_apt_newsr�
s���/��c�"���-�c�2�D���)�)�/�/��5�(B�4�(H�%��.�.�4�4�5N�O��.�.�5�5�7��)�)�0�0�2���/��	�	�F��J��*�*�1�1�3��%�%�,�,�.�.��/�s�A#B#�&<B#�#	D�,AD�D)7r6r��loggingrvr^�typingrrry�uaclientrrrr�(uaclient.api.u.pro.status.is_attached.v1r	r
�uaclient.aptrrr
�uaclient.clouds.identityr�uaclient.configr�uaclient.data_typesrrrrrr�uaclient.filesrr�	getLogger�replace_top_level_logger_namer(r=rr0rFr-rPrZr,r`rh�dictror�r�r�r�r�r.r'r%�<module>r�s������	��!��5�5��O�N�3�$���0��g���:��:�:�8�D�E��!�j�!�6�Z��,�0"�	�"�&�'>�?�"�	�"�J�����#+�H�,=�,=�#>��	��$-�s�-�t�-��.��T���	��!�$�Z��
�n���,��H�����H���#���"��"�X�c�]�"�J�S��S��/��/r'

Zerion Mini Shell 1.0