%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�Hcf�!��8�ddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
eje
je��Ze
j$�Zedgd��ZGd�d	ee�ZGd
�d�Zdad�Zd
eddfd�Zd
eddfd�Zdeefd�Zy)�N)�
namedtuple)�Enum)�List)�defaults�event_logger�messages�system�util�NoticeFileDetails)�order_id�label�is_permanent�messagec��eZdZedddej
��Zedddd��Zed	d
dej��Zedddej��Z	ed
ddej��Zedddej��Zedddej��Z
edddej��Zedddejj ��Zedddej"��Zedddej&��Zedddej*��Zedddej,��Zedddd ��Zed!d"dej2��Zed#d$dej6��Zy%)&�Notice�contract_expired�5T)r
rrr�reboot_required�10FzSystem reboot required�enable_reboot_required�11�reboot_script_failed�12�fips_reboot_required�20�fips_system_reboot_required�21�fips_install_out_of_date�22�fips_disable_reboot_required�23�fips_proc_file_error�24�fips_manual_disable_url�25�wrong_fips_metapackage_on_cloud�lp_lts_reboot_required�30�contract_refresh_warning�40�operation_in_progress�60z"Operation in progress: {operation}�auto_attach_retry_full_notice�70�auto_attach_total_failure�71N)�__name__�
__module__�__qualname__rr�CONTRACT_EXPIRED�REBOOT_REQUIRED�ENABLE_REBOOT_REQUIRED_TMPL�ENABLE_REBOOT_REQUIRED�REBOOT_SCRIPT_FAILED�FIPS_REBOOT_REQUIRED_MSG�FIPS_REBOOT_REQUIRED�FIPS_SYSTEM_REBOOT_REQUIRED�FIPS_INSTALL_OUT_OF_DATE�FIPS_DISABLE_REBOOT_REQUIRED�FIPS_PROC_FILE_ERROR�tmpl_msg�NOTICE_FIPS_MANUAL_DISABLE_URL�FIPS_MANUAL_DISABLE_URL�&NOTICE_WRONG_FIPS_METAPACKAGE_ON_CLOUD�WRONG_FIPS_METAPACKAGE_ON_CLOUD�LIVEPATCH_LTS_REBOOT_REQUIRED�NOTICE_REFRESH_CONTRACT_WARNING�CONTRACT_REFRESH_WARNING�OPERATION_IN_PROGRESS�AUTO_ATTACH_RETRY_NOTICE�AUTO_ATTACH_RETRY_FULL_NOTICE�&AUTO_ATTACH_RETRY_TOTAL_FAILURE_NOTICE�AUTO_ATTACH_RETRY_TOTAL_FAILURE���8/usr/lib/python3/dist-packages/uaclient/files/notices.pyrrs���(� ����)�)�	��(����(�	�O�/�&����4�4�	��-�$����-�-�	��-�$����1�1�	��#4�+����4�4�	#�� 1�(����1�1�	 ��$5�,����5�5�	$� �-�$����-�-�6�6�	��0�'����7�7�	��'8�/����?�?�	'�#�%6�&����6�6�	%�!� 1�(����8�8�	 ��.�%���4�	��%6�-����1�1�	%�!�'8�)����?�?�	'�#rMrc�t�eZdZdedefd�Zdefd�Zdedeefd�Zdedede	fd	�Z
dedefd
�Zdeefd�Zy)
�NoticesManager�notice_details�descriptionc���tj�s+tjd|jj
�y|jjrtjntj}dj|jj|jj
�}tjtjj!||�|�y)z�Adds a notice file. If the notice is found,
        it overwrites it.

        :param notice_details: Holds details concerning the notice file.
        :param description: The content to be written to the notice file.
        z.NoticesManager.add(%s) called as non-root userN�{}-{})r
�we_are_currently_root�LOG�warning�valuer
rr�NOTICES_PERMANENT_DIRECTORY�NOTICES_TEMPORARY_DIRECTORY�formatrr	�
write_file�os�path�join)�selfrQrR�	directory�filenames     rN�addzNoticesManager.addts����)�)�+��K�K�@��$�$�*�*�
�
��#�#�0�0�
�0�0��5�5�	�
�>�>�� � �)�)�>�+?�+?�+E�+E�
��	����G�G�L�L��H�-��	
rMc���tj�s+tjd|jj
�y|jjrtjntj}dj|jj|jj
�}tjtjj!||��y)ziDeletes a notice file.

        :param notice_details: Holds details concerning the notice file.
        z1NoticesManager.remove(%s) called as non-root userNrT)r
rUrVrWrXr
rrrYrZr[rr	�ensure_file_absentr]r^r_)r`rQrarbs    rN�removezNoticesManager.remove�s���
�)�)�+��K�K�C��$�$�*�*�
�
��#�#�0�0�
�0�0��5�5�	�
�>�>�� � �)�)�>�+?�+?�+E�+E�
��	�!�!�"�'�'�,�,�y�(�"C�DrMra�returnc	���tj|�D�cgc]S}tjjtjj	||��r|j||�r|��Uc}Scc}w)z�Gets the list of notice file names in the given directory.

        :param directory: The directory to search for notice files.
        :returns: List of notice file names.
        )r]�listdirr^�isfiler_�_is_valid_notice_file)r`ra�	file_names   rN�_get_notice_file_namesz%NoticesManager._get_notice_file_names�s\�� �Z�Z�	�2�
���w�w�~�~�b�g�g�l�l�9�i�@�A��*�*�9�i�@�
�
�	
��
s�AA3rlc���|tjk(}tD�chc]7}|j|k(r&dj	|j
|j���9}}||vScc}w)z�Checks if the notice file is valid.

        :param file_name: The name of the notice file.
        :returns: True if the file is valid, False otherwise.
        rT)rrYrrr[rr
)r`rarl�is_permanent_dir�n�valid_file_namess      rNrkz$NoticesManager._is_valid_notice_file�sh��%��(L�(L�L���
���~�~�!1�1�
�N�N�1�:�:�q�w�w�/�
��
�
�,�,�,��
s�<Ac��|jd�\}}tD]9}|j|k(s�|j|k(s�#|jj
cSy)z�Gets the default message for a notice file.

        :param file_name: The name of the notice file.
        :returns: The default message defined in the enum.
        �-�)�splitrrr
rXr)r`rlrr
�notices     rN�_get_default_messagez#NoticesManager._get_default_message�sQ��$�/�/�#�.���%��	,�F����(�*�v�|�|�u�/D��|�|�+�+�+�	,�rMc�
�tjtjf}g}|D]�}tjj|�s�#|j
|�}|D]l}	tjtjj||��}|r|j|��K|j|�}|j|��n��|j�|S#t$rtjd|z�Y��wxYw)zdGets all the notice files currently saved.

        :returns: List of notice file contents.
        zPermission error while reading )rrYrZr]r^�existsrmr	�	load_filer_�PermissionErrorrVrW�appendrw�sort)r`�notice_directories�notices�notice_directory�notice_file_names�notice_file_name�notice_file_contents�default_messages        rN�listzNoticesManager.list�s��
�0�0��0�0�
���� 2�	4���7�7�>�>�"2�3�� $� ;� ;�<L� M��$5�
4� ��+1�+;�+;������%5�7G�H�,�(�(��N�N�#7�8�&*�&?�&?�(�'�O��N�N�?�3�!
4�		4�*	�������'���K�K�9�<L�L���	�s�3C�!D�DN)
r1r2r3r�strrcrfrrm�boolrkrwr�rLrMrNrPrPss{��
��
��
�>E�V�E�,
��
��S�	�
�-�s�-�s�-�t�-�
�c�
�c�
� �d�3�i� rMrPc�.�t�
t�atS�N)�_notice_clsrPrLrMrN�
get_noticer��s����$�&���rMrQrgc�t�t�}|jjdi|��}|j||�y)NrL)r�rr[rc)rQ�kwargsrvrRs    rNrcrc�s2��
�\�F�/�.�(�(�/�/�9�&�9�K�
�J�J�~�{�+rMc�:�t�}|j|�yr�)r�rf)rQrvs  rNrfrfs��
�\�F�
�M�M�.�!rMc�6�t�}|j�Sr�)r�r�)rvs rNr�r�	s��
�\�F��;�;�=�rM)�loggingr]�collectionsr�enumr�typingr�uaclientrrrr	r
�	getLogger�replace_top_level_logger_namer1rV�get_event_logger�eventrrrPr�r�rcrfr�r�rLrMrN�<module>r�s����	�"���C�C��g���:��:�:�8�D�E��%��%�%�'����I���
`�
��`�F}�}�@���,��,�T�,�"�6�"�d�"�
�d�3�i�rM

Zerion Mini Shell 1.0