Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
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__/snap.cpython-310.pyc
o

��f^�	@s�ddlZddlZddlZddlZddlZddlmZmZm	Z	ddl
mZmZm
Z
mZmZmZmZdZgd�ZdZdZdZd	Ze
��Ze�e�e��Zed
defdefd
efdefdefg�Zde fdd�Z!de fdd�Z"			d0de	ede	ede	ee#ddfdd�Z$	d1dede	ee#ddfdd�Z%dede	efdd�Z&deefd d!�Z'd"d#�Z(d$ej)fd%d&�Z*		'd2d(ede	ed)e fd*d+�Z+d(efd,d-�Z,d(edefd.d/�Z-dS)3�N)�List�
NamedTuple�Optional)�api�apt�event_logger�
exceptions�messages�system�utilz
/usr/bin/snap)g�?g�?g@z
proxy.httpzproxy.httpsz/run/snapd.socketz/v2/snaps/{}�SnapPackage�name�version�revision�channel�	publisher�returncCsdt��vS)z(Returns whether or not snap is installed�snapd)r�get_installed_packages_names�rr�//usr/lib/python3/dist-packages/uaclient/snap.py�is_snapd_installed!srcCstdd�t�D��S)z3Returns whether or not snapd is installed as a snapcss�|]}|jdkVqdS)rN�r
)�.0�snaprrr�	<genexpr>(s�z/is_snapd_installed_as_a_snap.<locals>.<genexpr>)�any�get_installed_snapsrrrr�is_snapd_installed_as_a_snap&sr�
http_proxy�https_proxy�retry_sleepscCsxt�s
t�d�dS|s|rt�tjjdd��|r(tj	dddd�|�g|d�|r:tj	dddd	�|�g|d�dSdS)
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.
    z6Skipping configure snap proxy. snapd is not installed.Nr)�service�setr
z
proxy.http={}�r!zproxy.https={})
r�LOG�debug�event�infor	�SETTING_SERVICE_PROXY�formatr
�subp)rr r!rrr�configure_snap_proxy+s 
�
��r,�
protocol_typecCs4t�s
t�d�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.
    z8Skipping unconfigure snap proxy. snapd is not installed.Nr�unsetr
zproxy.{}r$)rr%r&r
r+r*)r-r!rrr�unconfigure_snap_proxyPs

�r/�keycCs8zt�ddd|g�\}}|��WStjyYdSw)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�getr
N)r
r+�stripr�ProcessExecutionError)r0�out�_rrr�get_config_option_valuees
�r6cCsRt�gd��\}}|��}|dd�}g}|D]}|��d}|�t|��q|S)N)r�listz--color�neverz	--unicoder8�r)r
r+�
splitlines�split�append�
get_snap_info)r4r5�apps�snaps�linerrrrrrs�rc
Cs�t�tjjdd��z	t�t���Wntj	y.}zt
�dt|��WYd}~nd}~wwz
t
jgd�tjd�WdStjyHt���w)Nzstandard Ubunturz<Trying to install snapd. Ignoring apt-get update failure: %s)zapt-get�installz--assume-yesrr$)r'r(r	�APT_UPDATING_LISTr*r�update_sources_list�get_system_sources_filer�UbuntuProErrorr%r&�strr
r+�APT_RETRIESr3�CannotInstallSnapdError)�errr�
install_snapd�s$�����rJ�progressc
Csvztjtdddgdd�WdStjy:}zt�dt|����r.t	�
d�|�dtj
�n�WYd}~dSd}~ww)	N�waitr
zseed.loadedT��capturezunknown command .*waitz9Detected version of snapd that does not have wait commandr()r
r+�SNAP_CMDrr3�re�searchrF�lowerr%�warning�emitr	�SNAPD_DOES_NOT_HAVE_WAIT_CMD)rKrIrrr�run_snapd_wait_cmd�s����rVFr�classic_confinement_supportcCs@td|g}|r|dg7}|r|d�|�g7}tj|dtd�dS)NrAz	--classicz--channel={}T)rNr!)rOr*r
r+�SNAP_INSTALL_RETRIES)rrrW�cmdrrr�install_snap�s


�rZcCstjtd|gdd�dS)N�refreshTrM)r
r+rO�rrrr�refresh_snap�sr]c

Cs�t�tjtj�}|�t�tj�d�}||_t	�
|�}z�zj|�dt	�
|��|��}|�
�jddd�}zt�|�}Wn tjyZ}ztjd|||d�tjd�
|�|d	��d}~ww|jd
kr�|jdkrv|�di��d
�dkrvtj|d��|�di��d�}tj|d��Wnty�t���wW|��|��n	|��|��w|�di�}	t|	�dd�|	�dd�|	�dd�|	�dd�|	�di��dd�d�S)N�	localhost�GETzutf-8�ignore)�errorsz]JSONDecodeError while parsing result of snap api call to %s, returning None. output was: "%s")�exc_infozSNAPD API {})�sourcer4��i��result�kindzsnap-not-foundr\�message)�errorr
�rrrr�username)r
rrrr)�socket�AF_UNIX�SOCK_STREAM�connect�SNAPD_SOCKET_PATH�http�client�HTTPConnection�sock�SNAPD_SNAPS_APIr*�request�getresponse�read�decode�json�loads�JSONDecodeErrorr%rSr�InvalidJson�statusr1�SnapNotInstalledError�UnexpectedSnapdAPIError�ConnectionRefusedError�SnapdAPIConnectionRefused�closer)
r�	snap_sock�conn�url�responser4�datarI�	error_msg�	snap_inforrrr=�s\

�
���

�
��
�




�r=)NNN)N)NF).�http.clientrpry�loggingrPrk�typingrrr�uaclientrrrrr	r
rrOrX�HTTP_PROXY_OPTION�HTTPS_PROXY_OPTIONrort�get_event_loggerr'�	getLogger�replace_top_level_logger_name�__name__r%rFr�boolrr�floatr,r/r6rrJ�ProgressWrapperrVrZr]r=rrrr�<module>sz$�����
�
�&��
�
�
���
�

Spamworldpro Mini