Your IP : 216.73.217.13


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

U

8�-d��@s�ddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
e�e�Ze
��Zedddd	d
g�ZGdd�dee�ZGd
d�d�Zdadd�Zedd�dd�Zedd�dd�Zeed�dd�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
ddejjd�Zeddd
ej
d�Z
edddejd�Zeddd
ejd�Zeddd
ejd�Zeddd
ejd�Zedddejd�Zeddd
ejd�Zeddddd�Zedd dejd�Zed!d"d
ejd�Zd#S)$�NoticeZreboot_requiredZ10FzSystem reboot required)rrr
rZenable_reboot_requiredZ11Zreboot_script_failedZ12TZfips_reboot_requiredZ20Zfips_system_reboot_requiredZ21Zfips_install_out_of_dateZ22Zfips_disable_reboot_requiredZ23Zfips_proc_file_errorZ24Zfips_manual_disable_urlZ25Zwrong_fips_metapackage_on_cloudZlp_lts_reboot_requiredZ30Zcontract_refresh_warningZ40Zoperation_in_progressZ60z"Operation in progress: {operation}Zauto_attach_retry_full_noticeZ70Zauto_attach_total_failureZ71N)�__name__�
__module__�__qualname__r
ZREBOOT_REQUIREDrZENABLE_REBOOT_REQUIRED_TMPLZENABLE_REBOOT_REQUIREDZREBOOT_SCRIPT_FAILEDZFIPS_REBOOT_REQUIRED_MSGZFIPS_REBOOT_REQUIREDZFIPS_SYSTEM_REBOOT_REQUIRED�msgZFIPS_INSTALL_OUT_OF_DATEZFIPS_DISABLE_REBOOT_REQUIREDZFIPS_PROC_FILE_ERRORZNOTICE_FIPS_MANUAL_DISABLE_URLZFIPS_MANUAL_DISABLE_URLZ&NOTICE_WRONG_FIPS_METAPACKAGE_ON_CLOUDZWRONG_FIPS_METAPACKAGE_ON_CLOUDZLIVEPATCH_LTS_REBOOT_REQUIREDZNOTICE_REFRESH_CONTRACT_WARNINGZCONTRACT_REFRESH_WARNINGZOPERATION_IN_PROGRESSZAUTO_ATTACH_RETRY_NOTICEZAUTO_ATTACH_RETRY_FULL_NOTICEZ&AUTO_ATTACH_RETRY_TOTAL_FAILURE_NOTICEZAUTO_ATTACH_RETRY_TOTAL_FAILURE�rr�8/usr/lib/python3/dist-packages/uaclient/files/notices.pyrs����������������rc@s<eZdZeed�dd�Zed�dd�Zeed�dd	�Zd
S)�NoticesManager)�notice_details�descriptionc	Cslt��s*t���t�d�W5QRXdS|jjr8tjntj	}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'Trying to add a notice as non-root userN�{}-{})r	�we_are_currently_root�disable_log_to_console�LOG�warning�valuer
r�NOTICES_PERMANENT_DIRECTORY�NOTICES_TEMPORARY_DIRECTORY�formatrrrZ
write_file�os�path�join)�selfrr�	directory�filenamerrr�addns 
����zNoticesManager.add)rc	Csjt��s*t���t�d�W5QRXdS|jjr8tjntj	}d�
|jj|jj�}t
�tj�||��dS)ziDeletes a notice file.

        :param notice_details: Holds details concerning the notice file.
        z*Trying to remove a notice as non-root userNr)r	rrrrrr
rrr r!rrrZensure_file_absentr"r#r$)r%rr&r'rrr�remove�s
���zNoticesManager.remove��returnc
stjtjf}g}|D]�tj���s&q�fdd�t���D�}|D]�}t�tj�	�|��}|rj|�
|�qBzT|�d�\}}d}tD]}	|	j
|kr�|	j|kr�|	}q�|dkr�t��|�
|jj�WqBtk
r�t���t�d�|��W5QRXYqBXqBq|��|S)zdGets all the notice files currently saved.

        :returns: List of notice file contents.
        cs&g|]}tj�tj��|��r|�qSr)r"r#�isfiler$)�.0�	file_name�Znotice_directoryrr�
<listcomp>�s�z'NoticesManager.list.<locals>.<listcomp>�-Nz1Something went wrong while processing notice: {}.)rrr r"r#�exists�listdirrZ	load_filer$�append�splitrrr�	Exceptionrrr	r�loggingrr!�sort)
r%Znotice_directoriesZnoticesZnotice_file_namesZnotice_file_nameZnotice_file_contentsrr�notice�nrr/r�list�sD�
��
��zNoticesManager.listN)	rrrr�strr(r)rr;rrrrrms
�rcCstdkrt�atS�N)�_notice_clsrrrrr�
get_notice�sr?)rr+cKs$t�}|jjf|�}|�||�dSr=)r?rr!r()r�kwargsr9rrrrr(�sr(cCst�}|�|�dSr=)r?r))rr9rrrr)�sr)r*cCst�}|��Sr=)r?r;)r9rrrr;�sr;)r7r"�collectionsr�enumr�typingrZuaclientrrrrr	Z	getLoggerrrZget_event_loggerZeventr
rrr>r?r(r)r<r;rrrr�<module>s$

�]b