https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/uaclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/uaclient/__pycache__/apt_news.cpython-310.pyc
o

��Jh�!�@s�ddlZddlZddlZddlZddlZddlZddlmZmZddl	Z	ddl
mZmZm
Z
mZddlmZmZddlmZmZmZddlmZddlmZddlmZmZmZmZmZm Z dd	l!m"Z"m#Z#m$Z$e�%e�&e'��Z(Gd
d�de�Z)Gdd
�d
e�Z*dd�Z+dedee)de,fdd�Z-dejdeejde,fdd�Z.de/de,fdd�Z0de*de,fdd�Z1dedee2dee*fd d!�Z3edefd"d#��Z4dedee/fd$d%�Z5dedee/fd&d'�Z6d(e/de/fd)d*�Z7defd+d,�Z8dS)-�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)�
machine_token�notices�state_filesc@s�eZdZedee�dd�edee�dd�ededd�edee�dd�edeee��dd�gZdddddd	�dee	e
dee	e
deedee	e
dee	e	e
f
d
d�ZdS)�AptNewsMessageSelectors�	codenamesF��required�clouds�pro�
architectures�packagesN�rrrrrcCs"||_||_||_||_||_dS�Nr )�selfrrrrr�r#�3/usr/lib/python3/dist-packages/uaclient/apt_news.py�__init__+s
	
z AptNewsMessageSelectors.__init__)
�__name__�
__module__�__qualname__rrrr�fieldsrr�str�boolr%r#r#r#r$r s2��
�
�
��
��rc
@sneZdZede�ededd�ededd�edee��gZddd�de	j	de
e	j	de
edeefd	d
�Z
dS)�AptNewsMessage�begin�endFr�	selectors�linesN)r.r/cCs||_||_||_||_dSr!)r-r.r/r0)r"r-r.r/r0r#r#r$r%Cs
zAptNewsMessage.__init__)r&r'r(rrrrrr)�datetimerrr*r%r#r#r#r$r,;s"������r,cCs�z|\}}}Wntyt�d|�YdSwt|�}|dur"dSt||�}t|dko/|dv|dko6|dv|dko=|dvg�S)NzInvalid package selector: %rFr)z==�<=�>=)�<r2)�>r3)�
ValueError�LOG�warningrr�any)�package_selector�package_name�version_operator�package_version�installed_package_version�version_comparisonr#r#r$�_does_package_selector_applyQs&����r@�cfgr/�returncCs�|durdS|jdurt��j|jvrdS|jdur,t�\}}|dur%dS||jvr,dS|jdur;|jt|�jkr;dS|j	durIt�
�|j	vrIdS|jdurZtdd�|jD��sZdSdS)NTFcS�g|]}t|��qSr#)r@)�.0r:r#r#r$�
<listcomp>�s��z&do_selectors_apply.<locals>.<listcomp>)
rr�get_release_info�seriesrr
rr	�is_attachedr�
get_dpkg_archrr9)rAr/�cloud_id�failr#r#r$�do_selectors_applyis2






��rLr-r.cCsVtj�tjj�}||krdS|tjdd�}|dus||kr!|}n|}||kr)dSdS)NF�)�daysT)r1�now�timezone�utc�	timedelta)r-r.rO�one_month_after_begin�
end_to_user#r#r$�do_dates_apply�srU�ccCst�|�ddkS)Nr�C)�unicodedata�category)rVr#r#r$�is_control_char�srZ�msgcCs^t|j�dkr	dSt|j�dkrdS|jD]}tdd�|D��r#dSt|�dkr,dSqdS)N�F�cSrCr#)rZ)rDrVr#r#r$rE�sz$is_message_valid.<locals>.<listcomp>�MT)�lenr0r9)r[�liner#r#r$�is_message_valid�s
�rarcCs�|D]K}zt�|�}Wnty#}zt�d|�WYd}~qd}~wwt|�s/t�d|�qt|j|j�s=t�d|�qt	||j
�sJt�d|�q|SdS)Nzmsg failed parsing: %rzmsg not valid: %rzmsg dates don't apply: %rzmsg selectors don't apply: %r)r,�	from_dict�	Exceptionr7�debugrarUr-r.rLr/)rAr�msg_dictr[�er#r#r$�select_message�s&��rgcCsbtjtjdd�tjtjdd�t��}tj||j	dtjd�}|�
�t�|j
�}tj|tjd�S)NT)�exist_ok�_apt)�user�)�hash�destdir)�cls)�os�makedirsr�
APT_NEWS_PATH�shutil�chown�apt_pkg�Acquire�AcquireFile�apt_news_url�runr�	load_file�destfile�json�loadsr�DatetimeAwareJSONDecoder)rA�acq�
apt_news_file�apt_news_contentsr#r#r$�fetch_aptnews_json�s��r�cCs>t|�}t||�dg��}t�d|�|durd�|j�SdS)Nrz
using msg: %r�
)r�rg�getr7rd�joinr0)rA�	news_dictr[r#r#r$�fetch_and_process_apt_news�sr�cCs�t|�}|j}|j}t�|�}|tjjkrt�	tj
j�tjSt�
tj
j�|tjjkr6tj�|�j|d�S|tjjkr[tj|}|j}|durKd}n|�d�}tj�|�j||d�SdS)z4
    :return: str if local news, None otherwise
    )�remaining_daysN�Unknownz%d %b %Y)�expired_dater�)r	�contract_status�contract_remaining_daysr�get_machine_token_filer�EXPIRED�valuer�add�Notice�CONTRACT_EXPIREDr�remove�ACTIVE_EXPIRED_SOON�CONTRACT_EXPIRES_SOON�	pluralize�format�EXPIRED_GRACE_PERIODr�!CONTRACT_EXPIRY_GRACE_PERIOD_DAYS�contract_expiry_datetime�strftime�CONTRACT_EXPIRED_GRACE_PERIOD)rA�is_attached_info�
expiry_statusr��machine_token_file�grace_period_remaining�exp_dt�
exp_dt_strr#r#r$�local_apt_news�s4
��
��r��newscCs.d}|�d�D]	}|d�|�7}q|d7}|S)Nz#
r�z# {}
)�splitr�)r��resultr`r#r#r$�format_news_for_apt_update	s
r�c
Cs�z,t|�}|st|�}|r tj�|�t|�}tj�|�WdStj��tj��WdStyO}zt	�
d|�tj��tj��WYd}~dSd}~ww)Nz2something went wrong while processing apt_news: %r)r�r�r�apt_news_raw_file�writer��apt_news_contents_file�deletercr7rd)rAr��apt_update_formatted_newsrfr#r#r$�update_apt_newss 

��r�)9r1r{�loggingrorrrX�typingrrrt�uaclientrrrr�(uaclient.api.u.pro.status.is_attached.v1rr	�uaclient.aptr
rr�uaclient.clouds.identityr
�uaclient.configr�uaclient.data_typesrrrrrr�uaclient.filesrrr�	getLogger�replace_top_level_logger_namer&r7rr,r@r+rLrUr*rZra�dictrgr�r�r�r�r�r#r#r#r$�<module>s` ��
�%��
���
�	&

https://t.me/RX1948 - 2025