AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/uaclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

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

F��c��@s�ddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZddlm
Z
ddlmZddlmZmZmZmZmZGdd�dejd	�ZdS)
�N)�join)�Any�Dict�Optional�Tuple�Type)�error)�	urlencode)�config�
exceptions�system�util�versionc	@s�eZdZdZdZeejdee	fdd���Z
eejdefdd���Zdde
ejddfd	d
�Zdd�Z					
	ddede
efdd�Zdefdd�Zdedee
eeefe
eeefffdd�ZdS)�UAServiceClient�N�returncC�dS)z1Set in subclasses to the type of API error raisedN���selfrr�8/usr/lib/python3/dist-packages/uaclient/serviceclient.py�
api_error_cls�zUAServiceClient.api_error_clscCr)z@String in subclasses, the UAConfig attribute containing base urlNrrrrr�cfg_url_base_attrrz!UAServiceClient.cfg_url_base_attr�cfgcCs,|st��dk}tj|d�|_dS||_dS)Nr)�	root_mode)�os�getuidr
�UAConfigr)rrrrrr�__init__s
zUAServiceClient.__init__cCsd�t���ddd�S)NzUA-Client/{}�application/json)z
user-agent�accept�content-type)�formatr�get_versionrrrr�headers&s�zUAServiceClient.headersT�potentially_sensitive�timeoutcCsj|�d�}|s|��}|�d�dkr|rt�|��d�}tt|j|j	�|�}|�
|�\}	}
|	r3|	|
fS|rHdd�t|���D�}|dt
|�7}|durN|n|j}ztj||||||d�\}
}W|
|fStjy�}zDd}t|d	�rw|j}nt|d
�r�|���d�}|r�z
tj|tjd�}Wnty�d}Ynw|r�|�||��tj|t|dd�||d
��d}~ww)N�/r"r zutf-8cSsi|]\}}|dur||�qS�Nr)�.0�k�vrrr�
<dictcomp>Bs
��z/UAServiceClient.request_url.<locals>.<dictcomp>�?)�url�datar%�methodr'r&�body�read)�cls�code�r5r%r/)�lstripr%�get�json�dumps�encode�urljoin�getattrrr�_get_fake_responses�sorted�itemsr	�url_timeoutr
�readurlr�URLError�hasattrr2r3�decode�loads�DatetimeAwareJSONDecoder�
ValueErrorrr�UrlError)r�pathr0r%r1�query_paramsr&r'r/�
fake_response�fake_headers�filtered_params�timeout_to_use�response�er2�
error_detailsrrr�request_url-s\


���


�����zUAServiceClient.request_urlr/cCsf|jdur|j�|g�S|jj�d�}|si|_ntj�|�s#i|_n	t�t	�
|��|_|j�|g�S)a.Return a list of fake response dicts for a given URL.

        serviceclient_url_responses in uaclient.conf should be a path
        to a json file which contains a dictionary keyed by full URL path.
        Each value will be a list of dicts representing each faked response
        for the given URL.

            The response dict item will have a code: <HTTP_STATUS_CODE> and
               response: "some string of content".
            The JSON string below fakes the available_resources URL on the
            contract server:
            '{"https://contracts.canonical.com/v1/resources":                [{"code": 200, "response": {"key": "val1", "key2": "val2"}}]}'

        :return: List of dicts for each faked response matching the url, or
           and empty list when no matching url found.
        N�serviceclient_url_responses)�_response_overlayr8r�featuresrrJ�existsr9rFr�	load_file)rr/�response_overlay_pathrrr�_get_response_overlayds
��z%UAServiceClient._get_response_overlaycCs�|�|�}|sdifSt|�dkr|d}n|�d�}|ddkr+|d|�di�fSt�|d�}tj||d|�di�|d�}|�d	�d
krQtj||dd��|�)a�Return response and headers if faked for this URL in uaclient.conf.

        :return: A tuple of response and header dicts if the URL has an overlay
            response defined. Return (None, {}) otherwise.

        :raises exceptions.URLError: When faked response "code" is != 200.
            URLError reason will be "response" value and any optional
            "headers" provided.
        N�rr5��rPr%r6�type�contract)�error_response)	rZ�len�popr8rrCrrI�ContractAPIError)rr/�	responsesrPrQ�
url_exceptionrrrr>�s*



��z#UAServiceClient._get_fake_responsesr))NNNNTN)�__name__�
__module__�__qualname__rArU�property�abc�abstractmethodr�	Exceptionr�strrrr
rrr%�bool�intrSrZrrrr>rrrrrs8
��
�7"�"�r)�	metaclass)rir9r�	posixpathrr<�typingrrrrr�urllibr�urllib.parser	�uaclientr
rrr
r�ABCMetarrrrr�<module>s

Anon7 - 2022
AnonSec Team