404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.118.198.191: ~ $
3

\�meCm�@sddlZddlZddlZddlZddlZddlZddlmZmZm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZddlmZmZmZmZmZmZmZdd	lmZmZmZddl Z dd
l m!Z!ddl"m#Z#ej$e%�Z&dZ'd
d�Z(dd�Z)ed5d�dd�Z*Gdd�d�Z+Gdd�de+�Z,Gdd�d�Z-Gdd�de.�Z/dd�Z0d6e1e-d"�d#d$�Z2d7ed%efe3e4ej5ee6ed&�d'd(�Z7d8ed%efee3e6e4ed+�d,d-�Z8dde&j9dddddd!dd)feeee4eeeeee4ge4fe3e1e6d.�d/d0�Z:Gd1d2�d2�Z;d9d3d4�Z<dS):�N)�ThreadPoolExecutor�TimeoutError�as_completed)�	parsedate)�ENOENT)�partial)�	NOT_FOUND)�count)�Any�Callable�Iterator�List�Optional�Tuple�Union)�quote�urlparse�
urlunparse)�
exceptions)�version�REDACTEDcCs>tt|dd��}|dr6|dr6|d|d<d|d<t|�S)NZhttp)�scheme���)�listrr)�urlZ
parsed_url�r� /usr/lib/python3.6/url_helper.py�	_cleanurl$s
rcGs(dd�}|}x|D]}|||�}qW|S)NcSsPtt|��}|d}|r,|jd�r,|d7}|tt|�dd�7}||d<t|�S)Nr�/z/:)Zsafe)rr�endswithr�strr)r�add_onZ
url_parsed�pathrrr�combine_single/sz#combine_url.<locals>.combine_singler)�baseZadd_onsr%rr#rrr�combine_url.s
	
r'�FileResponse�UrlResponse)�returncKs�|j�}|jd�rd|}|j�jd�r�|jd�r>tjd|�|td�d�}y"t|d��}|j�}WdQRXWnHt	k
r�}z,|j
}|j
tkr�t}t
||d|d�|�WYdd}~XnXt||d	�St|f|�SdS)
a0Wrapper function around readurl to allow passing a file path as url.

    When url is not a local file path, passthrough any kwargs to readurl.

    In the case of parameter passthrough to readurl, default values for some
    parameters. See: call-signature of readurl in this module for param docs.
    r z	file://%szfile://�dataz'Unable to post data to file resource %sN�rb)�cause�code�headersr)�contents)�lstrip�
startswith�lower�get�LOG�warning�len�open�read�IOError�errnorr�UrlErrorr(�readurl)r�kwargsZ	file_path�fpr0�er.rrr�read_file_or_url>s"


$rAc@s&eZdZd	dd�Zdd�Zdd�ZdS)
�StringResponse��cCs||_i|_||_d|_dS)N)r.r/r0r)�selfr0r.rrr�__init__^szStringResponse.__init__cOs|jdkrdSdS)NrCFT)r.)rD�argsr>rrr�okds
zStringResponse.okcCs|jjd�S)Nzutf-8)r0�decode)rDrrr�__str__iszStringResponse.__str__N)rC)�__name__�
__module__�__qualname__rErGrIrrrrrB]s
rBc@seZdZddd�ZdS)r(rCcCstj|||d�||_dS)N)r.)rBrEr)rDr$r0r.rrrrEnszFileResponse.__init__N)rC)rJrKrLrErrrrr(msc@s�eZdZejd�dd�Zeed�dd��Zedd��Z	dd
d�Z
edd
��Zedd��Zdd�Z
deeeeed�dd�ZdS)r))�responsecCs
||_dS)N)�	_response)rDrMrrrrEtszUrlResponse.__init__)r*cCs|jjdkrdS|jjS)N�)rN�content)rDrrrr0wszUrlResponse.contentscCs|jjS)N)rNr)rDrrrr}szUrlResponse.urlFcCs2d}|rd}d|jko |knr*dSdSdS)Ni,i�rCTF)r.)rDZredirects_ok�upperrrrrG�szUrlResponse.okcCs|jjS)N)rNr/)rDrrrr/�szUrlResponse.headerscCs|jjS)N)rN�status_code)rDrrrr.�szUrlResponse.codecCs|jjS)N)rN�text)rDrrrrI�szUrlResponse.__str__r)�
chunk_size�decode_unicoder*ccs|jj||�EdHdS)atIterates over the response data.

        When stream=True is set on the request, this avoids reading the content
        at once into memory for large responses.

        :param chunk_size: Number of bytes it should read into memory.
        :param decode_unicode: If True, content will be decoded using the best
        available encoding based on the response.
        N)rN�iter_content)rDrTrUrrrrV�szUrlResponse.iter_contentN)F)rF)rJrKrL�requestsZResponserE�property�bytesr0rrGr/r.rIr�int�boolrrVrrrrr)ss
	
c@seZdZddd�ZdS)r<NcCs<tj|t|��||_||_||_|jdkr2i|_||_dS)N)r:rEr"r-r.r/r)rDr-r.r/rrrrrE�s
zUrlError.__init__)NNN)rJrKrLrErrrrr<�sr<cCs�i}t|�j}|dkr~|r~d|kr8|dr8|d|d<nd|d<d|krfd|krf|d|dg|d<nd|kr~t|d�|d<|S)NZhttpsZca_certsZverifyTZ	cert_fileZkey_fileZcert)rrr")r�ssl_detailsZssl_argsrrrr�
_get_ssl_args�s
r]rTFr)�streamr*cs"t|�}||d�}|jt||��|
|d<|s:|r6dnd}||d<|dk	rpt|t�r^||d<ntt|�d�|d<|dkr|g}d	}|r�tt|�d	d	�}d
dtj	�i}�r�|j��|�|ṡfdd
�}|}|r�||d<|dkr�d}g}�x*|
r�t
�ntd|�D�]}||�|d<i}x�|j�D]t\}�|dk�r6�q |dk�r�|�r��fdd�|D�}|�r�t
j��||<x$|D]}t|||<�qrWn�||<�q Wy�|�r�tjd||
�r�dn|||�|dk�r�tj�}|�}|jf|�}WdQRX|	�r�|j�tjd||jt|j�|d	�t|�Stjk
�r}z�t|tj��rzt|d��rzt|jd��rz|jt ||jj|jj!|d��n"|jt ||d��t|tj"��r�P|�r�||j
�|d��r�P|
�r�|dk�s�|d	|k�r�|dk�r�|�r�tjd|�t#j$|�WYdd}~XnX�qW|d�dS)a�Wrapper around requests.Session to read the url and retry if necessary

    :param url: Mandatory url to request.
    :param data: Optional form data to post the URL. Will set request_method
        to 'POST' if present.
    :param timeout: Timeout in seconds to wait for a response. May be a tuple
        if specifying (connection timeout, read timeout).
    :param retries: Number of times to retry on exception if exception_cb is
        None or exception_cb returns True for the exception caught. Default is
        to fail with 0 retries on exception.
    :param sec_between: Default 1: amount of seconds passed to time.sleep
        between retries. None or -1 means don't sleep.
    :param headers: Optional dict of headers to send during request
    :param headers_cb: Optional callable returning a dict of values to send as
        headers during request
    :param headers_redact: Optional list of header names to redact from the log
    :param ssl_details: Optional dict providing key_file, ca_certs, and
        cert_file keys for use on in ssl connections.
    :param check_status: Optional boolean set True to raise when HTTPError
        occurs. Default: True.
    :param allow_redirects: Optional boolean passed straight to Session.request
        as 'allow_redirects'. Default: True.
    :param exception_cb: Optional callable which accepts the params
        msg and exception and returns a boolean True if retries are permitted.
    :param session: Optional exiting requests.Session instance to reuse.
    :param infinite: Bool, set True to retry indefinitely. Default: False.
    :param log_req_resp: Set False to turn off verbose debug messages.
    :param request_method: String passed as 'method' to Session.request.
        Typically GET, or POST. Default: POST if data is provided, GET
        otherwise.
    :param stream: if False, the response content will be immediately
    downloaded.
    )rr^�allow_redirectsZPOSTZGET�methodN�timeoutrrz
User-Agentz
Cloud-Init/%scs�S)Nr)r)r/rr�_cbszreadurl.<locals>._cbr+r/csg|]}�j|�r|�qSr)r4)�.0�k)�vrr�
<listcomp>'szreadurl.<locals>.<listcomp>z'[%s/%s] open '%s' with %s configuration�infinitez(Read from %s (%s, %sb) after %s attemptsrMrR)r.r/r)rz1Please wait %s seconds while we wait to try again���rhrh)%r�updater]�
isinstance�tuple�max�floatrZrZversion_stringr	�range�items�copy�deepcopyrr5�debugrWZSessionZrequestZraise_for_statusrRr7rPr)rZRequestExceptionZ	HTTPError�hasattrrM�appendr<r/ZSSLError�time�sleep)rr+raZretriesZsec_betweenr/�
headers_cb�headers_redactr\�check_statusr_�exception_cbZsessionrgZlog_req_resp�request_methodr^Zreq_argsZmanual_triesZdef_headersrbZexcps�iZfiltered_req_argsrdZmatched_headers�keyZsess�rr@r)r/rerr=�s�4






"r=.)�func�addrra�event�delayr*cCs|r|j|d�rdS|||�S)z Execute func with optional delay)raN)�wait)rr�rar�r�rrr�_run_func_with_delayusr��333333�?�
)r�	addresses�
stagger_delayrar*csd}d}d}g}tj��tt|�d��z�y������fdd�t|�D�}xTt|�d�D]D}	||	}|	j�}
|
r~|
}|j|�qV|	j�}|rV�j	�||fSqVW|r�t
jd||�|�nt
jd|�t
d��Wn.tk
r�t
jd	d
j|�d
j|��YnXWd�jdd�X||fS)
aexecute multiple callbacks in parallel

    Run blocking func against two different addresses staggered with a
    delay. The first call to return successfully is returned from this
    function and remaining unfinished calls are cancelled if they have not
    yet started
    N)�max_workerscs,i|]$\}}|�jt�|��|�d��qS))rr�rar�r�)Zsubmitr�)rcr|r�)�executorr�is_doner�rarr�
<dictcomp>�s	zdual_stack.<locals>.<dictcomp>)raz<Exception(s) %s during request to %s, raising last exceptionzEmpty result for address %szNo result returnedzJTimed out waiting for addresses: %s, exception(s) raised while waiting: %s� F)r�)�	threading�Eventrr7�	enumerater�	exceptionrt�result�setr5r6�error�
ValueErrorr�joinZshutdown)rr�r�raZ
return_resultZreturned_addressZlast_exceptionrZfuturesZfutureZreturn_exceptionr)r�rr�r�rar�
dual_stack�sD
	r�)�	status_cbrw�
sleep_timerz�
sleep_time_cbr{�connect_synchronously�async_delaycsttd�dd�}dd��	dd����fdd	�����fd
d�������	�
fdd
�}
����
fdd�}tj�}|
rv|
n|}|p�|}d�d}xt||��}|||||�}|r�|\}}||jfS�	�|�r�P�d�tjd|�tj|�t|�tj��p�d}q�Wtjd�
�dS)a�
    urls:      a list of urls to try
    max_wait:  roughly the maximum time to wait before giving up
               The max time is *actually* len(urls)*timeout as each url will
               be tried once and given the timeout provided.
               a number <= 0 will always result in only one try
    timeout:   the timeout provided to urlopen
    status_cb: call method with string message when a url is not available
    headers_cb: call method with single argument of url to get headers
                for request.
    headers_redact: a list of header names to redact from the log
    exception_cb: call method with 2 arguments 'msg' (per status_cb) and
                  'exception', the exception that occurred.
    sleep_time_cb: call method with 2 arguments (response, loop_n) that
                   generates the next sleep time.
    request_method: indicate the type of HTTP request, GET, PUT, or POST
    connect_synchronously: if false, enables executing requests in parallel
    async_delay: delay before parallel metadata requests, see RFC 6555
    returns: tuple of (url, response contents), on failure, (False, None)

    the idea of this routine is to wait for the EC2 metadata service to
    come up.  On both Eucalyptus and EC2 we have seen the case where
    the instance hit the MD before the MD service was up.  EC2 seems
    to have permanently fixed this, though.

    In openstack, the metadata service might be painfully slow, and
    unable to avoid hitting a timeout of even up to 10 seconds or more
    (LP: #894279) for a simple GET.

    Offset those needs with the need to not hang forever (and block boot)
    on a system where cloud-init is configured to look for EC2 Metadata
    service but is not going to find one.  It is possible that the instance
    data host (169.254.169.254) may be firewalled off Entirely for a system,
    meaning that the connection will block forever unless a timeout is set.

    A value of None for max_wait will retry indefinitely.
    )�loop_numberr*cSst|d�dS)N�r)rZ)�_r�rrr�default_sleep_timesz(wait_for_url.<locals>.default_sleep_timecSs$|dkrdS|dkp"tj�||kS)z4Check if time is up based on start time and max waitNFr)ru)�max_wait�
start_timerrr�timeupszwait_for_url.<locals>.timeupcSsf|js*d|j}tt|�|j|j|d�}n4|j�sVd|j}tt|�|j|j|d�}nd}d}||fS)z?Map requests response code/contents to internal "UrlError" typezempty response [%s])r.r/rzbad status code [%s]rN)r0r.r<r�r/rG)rMr�reason�url_excrrr�handle_url_responses"



z)wait_for_url.<locals>.handle_url_responsec
s�d}d}y*||�\}}�||�\}}|s0||fSWnZtk
r`}	zd|	}|	}WYdd}	~	Xn.tk
r�}	zd|	}|	}WYdd}	~	XnXttj�|�}
�r�d�nd}d||
||f}||�|r�|||d�dS)	z:Execute request, handle response, optionally log exceptionrNzrequest error [%s]zunexpected error [%s]z%ssZ	unlimitedzCalling '%s' failed [%s/%s]: %s)�msgr�)r<�	ExceptionrZru)
Z
url_reader_cb�urlsr��exc_cb�log_cbr�rrMr�r@Z
time_takenZmax_wait_strZ
status_msg)r�r�rr�read_url_handle_exceptions.s.z0wait_for_url.<locals>.read_url_handle_exceptionscs$t|�dkrin�|��|d�d�S)NF)r/rxraryr{)r=)rra)rwrxr{rr�read_url_cbNsz!wait_for_url.<locals>.read_url_cbcs���fdd�}xn�D]f}tj�}�dkrb��|�r6dS�dk	rb�rb|�|�krbt|�|���|||||�}|r|SqWdS)z|iterate over list of urls, request each one and handle responses
        and thrown exceptions individually per url
        cs|�|��fS)Nr)r)r�rarr�url_reader_serial]sz@wait_for_url.<locals>.read_url_serial.<locals>.url_reader_serialrN)rurZ)r�rar�r�r�rZnow�out)�loop_nr�r�r�r�r�)rar�read_url_serialXs

z%wait_for_url.<locals>.read_url_serialcs,tt��|d�}�|�|||�}|r(|SdS)z�pass list of urls to dual_stack which sends requests in parallel
        handle response and exceptions of the first endpoint to respond
        )r�raN)rr�)r�rar�r�Zurl_reader_parallelr�)r�r�r�r�rr�read_url_parallelssz'wait_for_url.<locals>.read_url_parallelrNrz1Please wait %s seconds while we wait to try againz$Timed out, no response from urls: %sF)FN)rZrur0r5rrrvr�)r�r�rar�rwrxr�rzr�r{r�r�r�r�r�r�Zdo_read_urlZcalculate_sleep_timerMrZaddressr)r�r�rwrxr�r�r�r�r{r�r�r�wait_for_url�s64 




r�c@s^eZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�ZdS)�OauthUrlHelperN�/run/oauth_skew.jsoncCst||_|pd|_||_||_||_d|_d|_|j|j|jf}t|�sNd|_nt|�s^t	d��|j
�}|pli|_dS)NrTr�FzBall or none of token_key, token_secret, or consumer_key can be set)�consumer_key�consumer_secret�	token_key�token_secret�skew_data_file�	_do_oauth�skew_change_limit�any�allr��read_skew_file�	skew_data)rDr�r�r�r�r�Zrequired�oldrrrrE�s
zOauthUrlHelper.__init__c	Cs8|jr4tjj|j�r4t|jdd��}tj|�SQRXdS)Nr~)�mode)r��osr$�isfiler8�json�load)rDr?rrrr��szOauthUrlHelper.read_skew_filec
CsT|js
dS|j�}|dkri}|||<t|jdd��}|jtj|��WdQRXdS)N�w)r�)r�r�r8�writer��dumps)rD�host�valueZcurr?rrr�update_skew_file�szOauthUrlHelper.update_skew_filec	Cs�t|t�o|jdkp|jdks"dSd|jkr>tjd|j�dS|jd}ytjt|��}Wn.t	k
r�}ztjd||�dSd}~XnXt
|tj��}t|j�j
}|jj|d�}t||�|jkr�|j||�tjd||�||j|<dS)Ni�i��datez$Missing header 'date' in %s responsez#Failed to convert datetime '%s': %srz$Setting oauth clockskew for %s to %d)rjr<r.r/r5r6ruZmktimerr�rZrr�netlocr�r4�absr�r�)	rDr�r�r�Zremote_timer@Zskewr�Zold_skewrrrrz�s(



zOauthUrlHelper.exception_cbcCsZ|js
iSd}t|�j}|jr>||jkr>ttj��|j|}t||j|j|j	|j
|d�S)N)rr�r�r�r��	timestamp)r�rr�r�rZru�
oauth_headersr�r�r�r�)rDrr�r�rrrrw�s
zOauthUrlHelper.headers_cbcCs6t|j|jd��|d<t|j|jd��|d<|||�S)Nrwrz)r�_headers_cbr4�
_exception_cb)rDZwrapped_funcrFr>rrr�_wrappeds
zOauthUrlHelper._wrappedcOs|jt||�S)N)r�r�)rDrFr>rrrr�szOauthUrlHelper.wait_for_urlcOs|jt||�S)N)r�r=)rDrFr>rrrr=szOauthUrlHelper.readurlcCs*d}z|r|||�}Wd|j||�X|S)N)rz)rDZextra_exception_cbr�r��retrrrr�szOauthUrlHelper._exception_cbcCs$i}|r||�}|j|j|��|S)N)rirw)rDZextra_headers_cbrr/rrrr�s
zOauthUrlHelper._headers_cb)NNNNr�)
rJrKrLrEr�r�rzrwr�r�r=r�r�rrrrr��s
		r�cCszyddlj}Wn,tk
r:}ztd�|�WYdd}~XnX|rJt|�}nd}|j|||||j|d�}|j|�\}	}
}|
S)Nrzoauth support is not available)Z
client_secretZresource_owner_keyZresource_owner_secretZsignature_methodr�)Zoauthlib.oauth1�oauth1�ImportError�NotImplementedErrorr"ZClientZSIGNATURE_PLAINTEXTZsign)rr�r�r�r�r�r�r@ZclientZ_uriZsigned_headersZ_bodyrrrr�&s 
r�)r(r))NNrrNNNNTTNNFTrF)N)r�r�)N)=rpr�Zloggingr�r�ru�concurrent.futuresrrrZemail.utilsrr;r�	functoolsrZhttp.clientr�	itertoolsr	Ztypingr
rrr
rrrZurllib.parserrrrWrZ	cloudinitrZ	getLoggerrJr5rrr'rArBr(r)r:r<r]r[r=r"rZr�rmr�r�rrr�r�r�rrrr�<module>s~$

1(P8F|

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 113 B 0644
__init__.cpython-36.pyc File 113 B 0644
apport.cpython-36.opt-1.pyc File 5.92 KB 0644
apport.cpython-36.pyc File 5.96 KB 0644
atomic_helper.cpython-36.opt-1.pyc File 2.05 KB 0644
atomic_helper.cpython-36.pyc File 2.05 KB 0644
cloud.cpython-36.opt-1.pyc File 3.08 KB 0644
cloud.cpython-36.pyc File 3.08 KB 0644
dmi.cpython-36.opt-1.pyc File 5.32 KB 0644
dmi.cpython-36.pyc File 5.32 KB 0644
event.cpython-36.opt-1.pyc File 1.97 KB 0644
event.cpython-36.pyc File 1.97 KB 0644
features.cpython-36.opt-1.pyc File 1.47 KB 0644
features.cpython-36.pyc File 1.47 KB 0644
gpg.cpython-36.opt-1.pyc File 3.76 KB 0644
gpg.cpython-36.pyc File 3.76 KB 0644
helpers.cpython-36.opt-1.pyc File 13.31 KB 0644
helpers.cpython-36.pyc File 13.31 KB 0644
importer.cpython-36.opt-1.pyc File 1.68 KB 0644
importer.cpython-36.pyc File 1.68 KB 0644
log.cpython-36.opt-1.pyc File 4.61 KB 0644
log.cpython-36.pyc File 4.61 KB 0644
netinfo.cpython-36.opt-1.pyc File 12.67 KB 0644
netinfo.cpython-36.pyc File 12.67 KB 0644
persistence.cpython-36.opt-1.pyc File 2.82 KB 0644
persistence.cpython-36.pyc File 2.82 KB 0644
registry.cpython-36.opt-1.pyc File 1.38 KB 0644
registry.cpython-36.pyc File 1.38 KB 0644
safeyaml.cpython-36.opt-1.pyc File 8 KB 0644
safeyaml.cpython-36.pyc File 8 KB 0644
settings.cpython-36.opt-1.pyc File 1.14 KB 0644
settings.cpython-36.pyc File 1.14 KB 0644
signal_handler.cpython-36.opt-1.pyc File 1.58 KB 0644
signal_handler.cpython-36.pyc File 1.58 KB 0644
simpletable.cpython-36.opt-1.pyc File 2.53 KB 0644
simpletable.cpython-36.pyc File 2.53 KB 0644
ssh_util.cpython-36.opt-1.pyc File 15.36 KB 0644
ssh_util.cpython-36.pyc File 15.36 KB 0644
stages.cpython-36.opt-1.pyc File 25.15 KB 0644
stages.cpython-36.pyc File 25.15 KB 0644
subp.cpython-36.opt-1.pyc File 9.97 KB 0644
subp.cpython-36.pyc File 9.97 KB 0644
temp_utils.cpython-36.opt-1.pyc File 2.81 KB 0644
temp_utils.cpython-36.pyc File 2.81 KB 0644
templater.cpython-36.opt-1.pyc File 4.55 KB 0644
templater.cpython-36.pyc File 4.55 KB 0644
type_utils.cpython-36.opt-1.pyc File 437 B 0644
type_utils.cpython-36.pyc File 437 B 0644
url_helper.cpython-36.opt-1.pyc File 21.03 KB 0644
url_helper.cpython-36.pyc File 21.03 KB 0644
user_data.cpython-36.opt-1.pyc File 8.25 KB 0644
user_data.cpython-36.pyc File 8.25 KB 0644
util.cpython-36.opt-1.pyc File 73.64 KB 0644
util.cpython-36.pyc File 73.64 KB 0644
version.cpython-36.opt-1.pyc File 429 B 0644
version.cpython-36.pyc File 429 B 0644
warnings.cpython-36.opt-1.pyc File 3.25 KB 0644
warnings.cpython-36.pyc File 3.25 KB 0644