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/http/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

��pf��@stddlZddlZddlZddlZddlmZmZmZddlm	Z	ddl
mZmZm
Z
mZmZGdd�dejd�ZdS)�N)�Any�Dict�Optional)�	urlencode)�config�http�system�util�versionc@s�eZdZdZdZeejdefdd���Z	dde
ejddfdd�Z
d	d
�Z						dded
e
edejfdd�Zdefdd�Zdede
ejfdd�ZdS)�UAServiceClient�N�returncCsdS)z@String in subclasses, the UAConfig attribute containing base urlN���selfrr�=/usr/lib/python3/dist-packages/uaclient/http/serviceclient.py�cfg_url_base_attrsz!UAServiceClient.cfg_url_base_attr�cfgcCs|s	t��|_dS||_dS�N)r�UAConfigr)rrrrr�__init__s
zUAServiceClient.__init__cCsd�t���ddd�S)NzUA-Client/{}�application/json)z
user-agent�accept�content-type)�formatr
�get_versionrrrr�headerss�zUAServiceClient.headersT�log_response_body�timeoutcCs�|�d�}|s|��}|�d�dkr|rtj|tjd��d�}t�	t
|j|j�|�}|�
|�}	|	r3|	S|rHdd�t|���D�}
|dt|
�7}|durN|n|j}tj||||||d	�S)
N�/rr)�clszutf-8cSsi|]\}}|dur||�qSrr)�.0�k�vrrr�
<dictcomp>>sz/UAServiceClient.request_url.<locals>.<dictcomp>�?)�url�datar�methodrr)�lstripr�get�json�dumpsr	�DatetimeAwareJSONEncoder�encode�	posixpath�join�getattrrr�_get_fake_responses�sorted�itemsr�url_timeoutr�readurl)r�pathr'rr(�query_paramsrrr&�
fake_response�filtered_params�timeout_to_userrr�request_url%s2

�

��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_overlayr*r�features�osr7�existsr+�loadsr�	load_file)rr&�response_overlay_pathrrr�_get_response_overlayMs
��z%UAServiceClient._get_response_overlaycCs�|�|�}|s	dSt|�dkr|d}n|�d�}i}g}|d}t|t�r)|}nt|t�r0|}tj|d|�di�t	j
|ddd�||d	�S)
z7Return response if faked for this URL in uaclient.conf.N�r�response�coderT)�	sort_keys)rHr�body�	json_dict�	json_list)rE�len�pop�
isinstance�dict�listr�HTTPResponser*r+r,)rr&�	responsesrGrKrL�resprrrr2os(





�z#UAServiceClient._get_fake_responsesr)NNNNTN)�__name__�
__module__�__qualname__r5r>�property�abc�abstractmethod�strrrrrrr�bool�intrrRr<rEr2rrrrrs.
���	
�("r)�	metaclass)rYr+r@r/�typingrrr�urllib.parser�uaclientrrrr	r
�ABCMetarrrrr�<module>s

Spamworldpro Mini