HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/uaclient/files/__pycache__/notices.cpython-310.pyc
o

nHJe��@s�ddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
e�e
�e��Ze
��Zedgd��ZGdd	�d	ee�ZGd
d�d�Zdadd
�Zdeddfdd�Zdeddfdd�Zdeefdd�ZdS)�N)�
namedtuple)�Enum)�List)�defaults�event_logger�messages�system�util�NoticeFileDetails)�order_id�label�is_permanent�messagec@seZdZeddddd�Zedddejd�Zedd	d
ejd�Zedddej	d�Z
ed
ddejd�Zeddd
ejd�Zedddej
d�Z
eddd
ejjd�Zeddd
ejd�Zeddd
ejd�Zedddejd�Zeddd
ejd�Zeddddd�Zedd dejd�Zed!d"d
ejd�Zd#S)$�Notice�reboot_required�10FzSystem reboot required)rrr
r�enable_reboot_required�11�reboot_script_failed�12T�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__r
�REBOOT_REQUIREDr�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�rGrG�8/usr/lib/python3/dist-packages/uaclient/files/notices.pyrs���������������
�rc@s>eZdZdedefdd�Zdefdd�Zdeefdd	�Zd
S)�NoticesManager�notice_details�descriptioncCs^t��st�d|jj�dS|jjrtjntj	}d�
|jj|jj�}t�
tj�||�|�dS)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r
r�NOTICES_PERMANENT_DIRECTORY�NOTICES_TEMPORARY_DIRECTORY�formatrr�
write_file�os�path�join)�selfrJrK�	directory�filenamerGrGrH�addns"�����zNoticesManager.addcCs\t��st�d|jj�dS|jjrtjntj	}d�
|jj|jj�}t�
tj�||��dS)ziDeletes a notice file.

        :param notice_details: Holds details concerning the notice file.
        z1NoticesManager.remove(%s) called as non-root userNrL)r	rMrNrOrPrr
rrQrRrSrr�ensure_file_absentrUrVrW)rXrJrYrZrGrGrH�remove�s����zNoticesManager.remove�returnc

s�tjtjf}g}|D]e�tj���sq
�fdd�t���D�}|D]M}t�tj�	�|��}|r5|�
|�q!z*|�d�\}}d}tD]}	|	j
|krO|	j|krO|	}qA|durWt��|�
|jj�Wq!tynt�d|�Yq!wq
|��|S)zdGets all the notice files currently saved.

        :returns: List of notice file contents.
        cs&g|]}tj�tj��|��r|�qSrG)rUrV�isfilerW)�.0�	file_name��notice_directoryrGrH�
<listcomp>�s��z'NoticesManager.list.<locals>.<listcomp>�-Nz1Something went wrong while processing notice: %s.)rrQrRrUrV�exists�listdirr�	load_filerW�append�splitrrr�	ExceptionrPrrNrO�sort)
rX�notice_directories�notices�notice_file_names�notice_file_name�notice_file_contentsrr�notice�nrGrbrH�list�sF�
������zNoticesManager.listN)	r-r.r/r�strr[r]rrtrGrGrGrHrIms�
�rIcCstdurt�atS�N)�_notice_clsrIrGrGrGrH�
get_notice�srxrJr^cKs(t�}|jjdi|��}|�||�dS)NrG)rxrrSr[)rJ�kwargsrrrKrGrGrHr[�sr[cCst�}|�|�dSrv)rxr])rJrrrGrGrHr]�sr]cCst�}|��Srv)rxrt)rrrGrGrHrt�srt)�loggingrU�collectionsr�enumr�typingr�uaclientrrrrr	�	getLogger�replace_top_level_logger_namer-rN�get_event_logger�eventr
rrIrwrxr[r]rurtrGrGrGrH�<module>s$�]d