Your IP : 216.73.216.14


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

U

8�-dB�@s�ddlZddlZddlmZmZddlmZmZmZm	Z	m
Z
dZdddgZdZ
d	Zd
Ze��Zed�dd
�Zdeeeeeeedd�dd�Zdeeeedd�dd�Zeeed�dd�Zeeed�dd�ZGdd�d�Zeed�dd�ZdS) �N)�List�Optional)�apt�event_logger�
exceptions�messages�systemz
/usr/bin/snapg�?g�?g@z
proxy.httpzproxy.httpsu…)�returncCsdt��kS)z(Returns whether or not snap is installedZsnapd)rZget_installed_packages_names�r
r
�//usr/lib/python3/dist-packages/uaclient/snap.py�is_installedsr)�
http_proxy�https_proxy�retry_sleepsr	cCs~t�t�st�d�t��dS|s&|r:t�tj	jdd��|rZtj
dddd�|�g|d�|rztj
dddd	�|�g|d�dS)
a
    Configure snap to use http and https proxies.

    :param http_proxy: http proxy to be used by snap. If None, it will
                       not be configured
    :param https_proxy: https proxy to be used by snap. If None, it will
                        not be configured
    :param retry_sleeps: Optional list of sleep lengths to apply between
        retries. Specifying a list of [0.5, 1] tells subp to retry twice
        on failure; sleeping half a second before the first retry and 1 second
        before the second retry.
    z1Skipping configure snap proxy. {} does not exist.N�snap)�service�setrz
proxy.http={}�rzproxy.https={})r�which�SNAP_CMD�logging�debug�format�event�inforZSETTING_SERVICE_PROXY�subp)r
rrr
r
r�configure_snap_proxys&
����r)�
protocol_typerr	cCs>t�t�st�d�t��dStjdddd�|�g|d�dS)a�
    Unset snap configuration settings for http and https proxies.

    :param protocol_type: String either http or https
    :param retry_sleeps: Optional list of sleep lengths to apply between
        retries. Specifying a list of [0.5, 1] tells subp to retry twice
        on failure; sleeping half a second before the first retry and 1 second
        before the second retry.
    z3Skipping unconfigure snap proxy. {} does not exist.NrZunsetrzproxy.{}r)rrrrrrr)rrr
r
r�unconfigure_snap_proxy>s
���r)�keyr	cCs>z t�ddd|g�\}}|��WStjk
r8YdSXdS)z�
    Gets the config value from snap.
    :param protocol: can be any valid snap config option
    :return: the value of the snap config option, or None if not set
    r�getrN)rr�striprZProcessExecutionError)r�out�_r
r
r�get_config_option_valueWs

r$)�packager	c	Cs:t�dd|ddddg�\}}t�d|�}|r6|�d�SdS)Nrr�--color�never�	--unicodeztracking:\s+(?P<tracking>.*)�tracking)rr�re�search�group)r%r"r#�matchr
r
r�get_snap_package_info_trackingds�
r.c@seZdZdd�ZdS)�SnapPackagecCs(||_||_||_||_||_||_dS)N)�name�version�revr)�	publisher�notes)�selfr0r1r2r)r3r4r
r
r�__init__oszSnapPackage.__init__N)�__name__�
__module__�__qualname__r6r
r
r
rr/nsr/cCs�t�ddddddg�\}}|��}|dd�}g}|D]D}|��}t|�}|j�t�rpt|j	�}|rh|n|j|_|�
|�q6|S)Nr�listr&r'r(�)rr�
splitlines�splitr/r)�endswith�SNAP_CHANNEL_SHORTEN_VALUEr.r0�append)r"r#ZappsZsnaps�line�pkgrZchannelr
r
r�get_installed_snapsxs�
rC)NNN)N)rr*�typingrrZuaclientrrrrrrZSNAP_INSTALL_RETRIESZHTTP_PROXY_OPTIONZHTTPS_PROXY_OPTIONr?Zget_event_loggerr�boolr�str�floatrrr$r.r/rCr
r
r
r�<module>s:
�
�*�
�