PHP WebShell

Текущая директория: /usr/lib/python3/dist-packages/uaclient/api/u/unattended_upgrades/status/__pycache__

Просмотр файла: v1.cpython-310.pyc

o

��g+.�
@s�ddlZddlZddlmZmZmZmZmZddlm	Z	m
Z
mZmZddl
mZddlmZddlmZddlmZmZddlmZdd	lmZmZmZmZmZmZmZgd
�Z dZ!Gdd
�d
e�Z"Gdd�dee�Z#de$fdd�Z%de$dee&ee&ee&ffdee$eej'ffdd�Z(deejfdd�Z)de#fdd�Z*dede#fdd�Z+edde+dd �Z,d!d"d#e#ed$fgd%d&d'd(d)�	Z-dS)*�N)�Dict�List�Optional�Tuple�Union)�apt�
exceptions�messages�system)�APIEndpoint)�AdditionalInfo)�UnattendedUpgradesError)�get_apt_config_keys�get_apt_config_values)�UAConfig)�
BoolDataValue�
DataObject�DatetimeDataValue�Field�IntDataValue�StringDataValue�	data_list)�APT::Periodic::Enable�#APT::Periodic::Update-Package-Lists�!APT::Periodic::Unattended-Upgrade�#Unattended-Upgrade::Allowed-Originsz#/var/lib/apt/periodic/upgrade-stampc@s:eZdZededd�ededd�gZdedefdd�ZdS)	� UnattendedUpgradesDisabledReason�msgzHuman readable reason��doc�codezReason codecCs||_||_dS�N�rr )�selfrr �r$�N/usr/lib/python3/dist-packages/uaclient/api/u/unattended_upgrades/status/v1.py�__init__%s
z)UnattendedUpgradesDisabledReason.__init__N)�__name__�
__module__�__qualname__rr�fields�strr&r$r$r$r%rs
�rc@s�eZdZededd�ededd�ededd�eded	d�ed
ee�dd�eded
d�ededdd�ede	ddd�gZ
dedededed
e
ededeedeejfdd�ZdS)�UnattendedUpgradesStatusResult�systemd_apt_timer_enabledz4Indicate if the ``apt-daily.timer`` jobs are enabledr�apt_periodic_job_enabledzFIndicate if the ``APT::Periodic::Enabled`` configuration is turned off�$package_lists_refresh_frequency_dayszFThe value of the ``APT::Periodic::Update-Package-Lists`` configuration�"unattended_upgrades_frequency_dayszDThe value of the ``APT::Periodic::Unattended-Upgrade`` configuration�#unattended_upgrades_allowed_originszFThe value of the ``Unattended-Upgrade::Allowed-Origins`` configuration�unattended_upgrades_runningzRIndicate if the ``unattended-upgrade`` service is correctly configured and running�#unattended_upgrades_disabled_reasonFzyObject that explains why ``unattended-upgrades`` is not running -- if the application is running, the object will be null)�requiredr�unattended_upgrades_last_runz)The last time ``unattended-upgrades`` ranc	Cs4||_||_||_||_||_||_||_||_dSr!)r-r.r/r0r1r2r3r5)	r#r-r.r/r0r1r2r3r5r$r$r%r&ks����
z'UnattendedUpgradesStatusResult.__init__N)r'r(r)rrrrrrrr*�bool�intrr+r�datetimer&r$r$r$r%r,*s~�������
��@������	���r,�returnc
CsLzt�d�}t�d�}|o|}W|Stjy%}ztt|�d��d}~ww)Nzapt-daily.timerzapt-daily-upgrade.timer)�	error_msg)r
�is_systemd_unit_activer�ProcessExecutionErrorr
r+)�apt_daily_job_enabled�apt_daily_upgrade_job_enabledr-�er$r$r%�_get_apt_daily_job_status�s������r@r-�unattended_upgrades_cfgcCsl|sdtjfStD]*}|�|�}t|t�r"|s"dtjj|d�fS|dks(|s3dtjj|d�fSq	dS)NF)�cfg_name�0)TN)	r	�(UNATTENDED_UPGRADES_SYSTEMD_JOB_DISABLED�UNATTENDED_UPGRADES_CONFIG_KEYS�get�
isinstance�list�(UNATTENDED_UPGRADES_CFG_LIST_VALUE_EMPTY�format�(UNATTENDED_UPGRADES_CFG_VALUE_TURNED_OFF)r-rA�key�valuer$r$r%�_is_unattended_upgrades_running�s$

�����rNcCs2ztj�t�}Wn
tyYdSwtj�|�Sr!)�os�path�getctime�UNATTENDED_UPGRADES_STAMP_PATH�FileNotFoundErrorr8�
fromtimestamp)�creation_epochr$r$r%�!_get_unattended_upgrades_last_run�s�rVcCs
tt��Sr!)�_statusrr$r$r$r%�status�s
rX�cfgc
Cs�t�d�stddddgttjjtjjd�ddd�St�}t	�}t
ttt
d���}|dp.d	|d<|d
p6g|d
<t||�\}}|rKt|j|jd�}nd}t|t|�dd��d	kt|�d�p_d�t|�d
�pgd�t|�d
�pog�|||d�}d|i|_|S)a�
    This endpoint returns the status around ``unattended-upgrades``. The focus
    of the endpoint is to verify if the application is running and how it is
    configured on the machine.

    .. important::

        For this endpoint, we deliver a unique key under ``meta`` called
        ``raw_config``. This field contains all related ``unattended-upgrades``
        configurations, unparsed. This means that this field will maintain both
        original name and values for those configurations.
    zunattended-upgradesFrr"N)r-r.r/r0r1r3r2r5zUnattended-Upgrader�1r�rr�
raw_config)r�is_installedr,rr	�UNATTENDED_UPGRADES_UNINSTALLEDr�namer@rVr�setrErrNr+rFr7rH�meta)rYr-r5rAr2�disabled_reasonr3�unattended_upgrades_resultr$r$r%rW�s�

�����
�
����
������
��
rW�v1�UnattendedUpgradesStatus)�versionr_�fn�options_clsz27.14FzT
from uaclient.api.u.unattended_upgrades.status.v1 import status

result = status()
zYRaised if we cannot run a necessary command to show the status of ``unattended-upgrades``z'pro api u.unattended_upgrades.status.v1a@
{
    "apt_periodic_job_enabled": true,
    "package_lists_refresh_frequency_days": 1,
    "systemd_apt_timer_enabled": true,
    "unattended_upgrades_allowed_origins": [
        "${distro_id}:${distro_codename}",
        "${distro_id}:${distro_codename}-security",
        "${distro_id}ESMApps:${distro_codename}-apps-security",
        "${distro_id}ESM:${distro_codename}-infra-security"
    ],
    "unattended_upgrades_disabled_reason": null,
    "unattended_upgrades_frequency_days": 1,
    "unattended_upgrades_last_run": null,
    "unattended_upgrades_running": true
}
a�
- Possible attributes in JSON ``meta`` field:

  .. code-block:: json

     {
         "meta": {
             "environment_vars": [],
             "raw_config": {
                 "APT::Periodic::Enable": "1",
                 "APT::Periodic::Unattended-Upgrade": "1",
                 "APT::Periodic::Update-Package-Lists": "1",
                 "Unattended-Upgrade::Allowed-Origins": [
                     "${distro_id}:${distro_codename}",
                     "${distro_id}:${distro_codename}-security",
                     "${distro_id}ESMApps:${distro_codename}-apps-security",
                     "${distro_id}ESM:${distro_codename}-infra-security"
                 ]
             }
         }
     }
�)	�
introduced_in�requires_network�example_python�result_classr�example_cli�example_json�extra�extra_indent).r8rO�typingrrrrr�uaclientrrr	r
�uaclient.api.apir�uaclient.api.data_typesr�uaclient.api.exceptionsr
�uaclient.aptrr�uaclient.configr�uaclient.data_typesrrrrrrrrErRrr,r6r@r+�NamedMessagerNrVrXrW�endpoint�_docr$r$r$r%�<module>sX$
a��
�	b���
�

Выполнить команду


Для локальной разработки. Не используйте в интернете!