AlkantarClanX12

Your IP : 3.138.61.52


Current Path : /proc/self/root/lib/python3.6/site-packages/rhn/__pycache__/
Upload File :
Current File : //proc/self/root/lib/python3.6/site-packages/rhn/__pycache__/transports.cpython-36.pyc

3

�U�f�|�@sZddlZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZy ddlZddl
mZmZmZWn*ek
r�ddljZeZeZeZYnXdZdZGd	d
�d
e�ZGdd�dej�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�d�Zd%dd�Z d&dd�Z!Gdd�d�Z"Gdd�d�Z#d'dd �Z$d(d!d"�Z%e#Z&Gd#d$�d$�Z'dS))�N)�connections)�sstr�bstr)�SmartIO)�UserDictCase)�IntType�
StringType�ListTypezI2.8.62.8.6-8.module_el8.10.0+6858+3ddf28328.module_el8.10.0+6858+3ddf2832�c@seZdZdS)�NotProcessedN)�__name__�
__module__�__qualname__�rr� /usr/lib/python3.6/transports.pyr$src@s�eZdZdeZd'dd�Zd(dd�Zd	d
�Zdd�Zd
d�Z	d)dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd*dd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS)+�	Transportzrhn.rpclib.py/%srNcCszd|_ddd�|_|j||d�t�|_d|_d|_d|_d|_||_	||_
d|_d|_d|_
d|_d|_||_||_dS)NFr)�transfer�encoding�POSTi@)Z_use_builtin_types�_transport_flags�set_transport_flagsr�_headers�verbose�
connection�method�_lang�refreshCallback�progressCallback�
bufferSize�
headers_in�response_status�response_reason�_redirectedZ
_use_datetime�timeout)�selfrrrrZuse_datetimer#rrr�__init__*s"zTransport.__init__�@cCs||_||_dS)N)rr)r$rrrrr�set_progress_callback?szTransport.set_progress_callbackcCs
||_dS)N)r)r$rrrr�set_refresh_callbackDszTransport.set_refresh_callbackcCs|dkrd}||_dS)Ni@)r)r$rrrr�set_buffer_sizeJszTransport.set_buffer_sizecCs|dkrtd|��||_dS)N�GETrzUnknown request method %s)r*r)�IOErrorr)r$rrrr�
set_methodRszTransport.set_methodcKs<|jj|�|dk	r||jd<|dk	r0||jd<|j�dS)Nrr)r�update�validate_transport_flags)r$rr�kwargsrrrrXs

zTransport.set_transport_flagscCs
|jj�S)N)r�copy)r$rrr�get_transport_flagscszTransport.get_transport_flagscCsH|jjd�}t|dd�}||jd<|jjd�}t|dd�}||jd<dS)Nr�)�strictr)r�get�lookupTransfer�lookupEncoding)r$rrrrrr.fs
z"Transport.validate_transport_flagscCs@t|�tg�tf�gkr.dd�|D�|j|<nt|�|j|<dS)NcSsg|]}t|��qSr)�str)�.0�arrr�
<listcomp>tsz(Transport.set_header.<locals>.<listcomp>)�typerr7)r$�name�argrrr�
set_headerqszTransport.set_headercCsF||jkr&|j|}t|t�s4|g}ng}|j|<|jt|��dS)N)r�
isinstancer	�appendr7)r$r<r=Zvlistrrr�
add_headerxs


zTransport.add_headercCs|jj�dS)N)r�clear)r$rrr�
clear_headers�szTransport.clear_headerscCs8|jrtd|f�|jr*tj||jd�Stj|�SdS)NzConnecting via http to %s)r#)r�printr#r�HTTPConnection)r$�hostrrr�get_connection�s
zTransport.get_connectioncCsX||_|j|�\}}}|sg}|j|�}|j|j�|jrJ|j|jd�t||jd�}|jf|j	�|j
d|j�x*t|jj
��|D]\}	}
|j
|	|
�q�W|j
dd�|j|�xd
D]}|j|�q�W|j||�\}}
|j�rtd�x$|j
�D]\}	}
td	|	|
f�q�W|
jdk�r6|d|_|
j|_dS||_|
j|_|
j|_|j|
|�S)Nr2)rrz
User-AgentzContent-Typeztext/xml�Content-Length�HostzIncoming headers:z	%s : %s�-�.ZLocation)rHrI)rJrK)r�
get_host_inforGZset_user_agent�
user_agentZset_debuglevel�Outputrrrr>�listr�items�process�clear_header�	send_httprD�statusr"r r�reasonr!�_process_response)r$rF�handlerZrequest_bodyr�
extra_headers�x509rZreq�header�value�h�headers�fdrrr�request�s<



zTransport.requestcCsbt|j|j|jd�}|j|�}t|t�rPt|j|j	|j
|j|jd�}|j|_|S|j�|j|�S)N)rr)rr)
�Inputrrr�decoder?�InputStream�Filer^�lengthr<�close�parse_response)r$r^rZresp�frrrrV�s




zTransport._process_responsecCs|jS)N)r")r$rrr�
redirected�szTransport.redirectedcCsf|j�\}}x@|jd�}|sP|jr,|j�|jr@tdt|��|j|�qW|j�|j�|j�S)Nizbody:)Z	getparser�readrrrD�reprZfeedre)r$rg�p�u�responserrrrf�s
zTransport.parse_responsecCs
||_dS)N)r)r$�langrrr�setlang�szTransport.setlang)rrNNNN)r&)NN)r)rr
r�__version__rMr%r'r(r)r,rr1r.r>rArCrGr_rVrhrfrorrrrr's&


	
8rc@s&eZdZd	dd�Zdd�Zdd�ZdS)
�
SafeTransportrNcCs<tj||||||d�g|_x|p$gD]}|j|�q&WdS)N)rrr#)rr%�
trusted_certs�add_trusted_cert)r$rrrrrrr#�certfilerrrr%�s
zSafeTransport.__init__cCs*tj|tj�std|��|jj|�dS)Nz%Certificate file %s is not accessible)�os�access�R_OK�
ValueErrorrrr@)r$rtrrrrsszSafeTransport.add_trusted_certcCsR|j|�\}}}|jr$td|f�|jr>tj||j|jd�Stj||jd�SdS)NzConnecting via https to %s)rrr#)rr)rLrrDr#rZHTTPSConnectionrr)r$rFrXrYrrrrGszSafeTransport.get_connection)rrNNNN)rr
rr%rsrGrrrrrq�s
rqc@seZdZddd�Zdd�ZdS)�ProxyTransportNrc		Cs,tj||||||d�||_||_||_dS)N)rrr#)rr%�_proxy�_proxy_username�_proxy_password)	r$�proxy�
proxyUsername�
proxyPasswordrrrrr#rrrr%s
zProxyTransport.__init__cCs^|jr td||j|j|jf�|jrBtj|j||j|j|jd�Stj|j||j|jd�SdS)Nz8Connecting via http to %s proxy %s, username %s, pass %s)�username�passwordr#)r�r�)rrDrzr{r|r#rZHTTPProxyConnection)r$rFrrrrG#s


zProxyTransport.get_connection)NNrrNNN)rr
rr%rGrrrrrys
ryc@s&eZdZd	dd�Zdd�Zdd�ZdS)
�SafeProxyTransportNrc
CsBtj|||||||||	d�	g|_x|p*gD]}
|j|
�q,WdS)N)r~rrrrrr#)ryr%rrrs)r$r}r~rrrrrrrr#rtrrrr%0szSafeProxyTransport.__init__cCs*tj|tj�std|��|jj|�dS)Nz%Certificate file %s is not accessible)rurvrwrxrrr@)r$rtrrrrs=sz#SafeProxyTransport.add_trusted_certcCsf|jr td||j|j|jf�|jrFtj|j||j|j|j|jd�Stj|j||j|j|jd�SdS)Nz9Connecting via https to %s proxy %s, username %s, pass %s)r�r�rrr#)r�r�rr)	rrDrzr{r|r#rZHTTPSProxyConnectionrr)r$rFrrrrGBs

z!SafeProxyTransport.get_connection)NNrrNNNN)rr
rr%rsrGrrrrr�/s

r�c@s:eZdZddd�Zejfdd�Zejfdd	�Zd
d�ZdS)
r`N��@cCs�d|_d|_d|_d|_d|_d|_||_||_||_|s�dt	j
krTt	j
dj�|_dt	j
krnt	j
dj�|_dt	j
kr�t	j
dj�|_dt	j
kr�tt	j
d�|_dt	j
kr�t	j
d|_d	t	j
kr�t	j
d	|_n�x�|j
�D]�}||}|j�}|d
k�r&yt|�|_Wntk
�r"d|_YnXq�|dk�r<|j�|_q�|dk�rR|j�|_q�|d
k�rh|j�|_q�|dk�r~|j�|_q�|dkr�||_q�Wd|_dS)Nr�C�ZHTTP_CONTENT_TRANSFER_ENCODINGZHTTP_CONTENT_ENCODINGzCONTENT-TYPEZCONTENT_LENGTHZHTTP_ACCEPT_LANGUAGEZHTTP_X_PACKAGE_FILENAMEzcontent-lengthzcontent-transfer-encodingzcontent-encodingzcontent-typezaccept-languagezx-package-filename)rrr;rdrnr<rr�max_mem_sizeru�environ�lower�int�keysrx�io)r$r]rrr�rZr[r\rrrr%hsR











zInput.__init__cCs�|jdkrdS|jr2t||j|j|j|jd�|_n
t|�|_|jsN|jdkrRdS|jdkr�ddl	}|j}|j
dd�t|jd�|_|j||j�n
t
|j��dS)Nzapplication/octet-stream)rrr��binary�base64r)r�)r;rd�_smart_readrrr�r��_smart_total_readrr��seekrra�NotImplementedError)r$r^r�Zold_iorrrri�s"


z
Input.readcCs^|jdkr t||j|j|jd�S|js0|j|�t|d�rB|j�|jsT|jdkrVn�|jdkr�ddl	}|j
�}|jjdd�|j|jj��|j
�}~t|�|_t|jd�|_|jj|�n�|jdk�r ddl}|jjdd�|jdt|jd�}|j�}t|�|_t|jd�|_|jj|�n*|jd
k�r<t|j|j��nt|j|j��|jjdd�|jS)Nzapplication/octet-stream)rere�__plain�x-zlib�deflater)r��x-gzip�gzip�rb)�mode�
compresslevel�fileobjzx-gpg)r�r�)r�r�)r;rbrdr<rer�ri�hasattrr�zlibZ
decompressobjr�Z
decompress�flush�lenrr��writer��GzipFile�COMPRESS_LEVELr�r)r$r^r��obj�datar��gzrrrra�s>






zInput.decodecCs|jS)N)rn)r$rrr�getlang�sz
Input.getlang)NNr�r�)	rr
rr%�sys�stdinrirar�rrrrr`gs

70r`��@cCs.t|d�}x|j|�}|sP|j|�qW|S)z�
    Tries to read data from the supplied stream, and puts the results into a
    StmartIO object. The data will be in memory or in a temporary file,
    depending on how much it's been read
    Returns a SmartIO object
    )r�)rrir�)r^rr�r��chunkrrrr��s

r�cCs�tj�}|}t|d�}|}x�|dkr�tj�}	t||�}
|j|
�}t|�}
|
sNP||
}|j|�|dkrjq|	|dks~|dkr|	}t||�}||	|d}
|dkr�d}n||
}||||
|�qW|jdd�|S)N)r�rr2g���ư>)�timer�minrir�r��floatr�)r^�amtrrr�Z	startTimeZlastTime�bufZorigsizeZcurTime�lr�Z	bytesReadZspeedZsecsrrrr�s2




r�c@seZdZddd�Zdd�ZdS)rb�	<unknown>NcCs ||_t|�|_||_||_dS)N)r^r�rdr<re)r$r^rdr<rerrrr%=s
zInputStream.__init__cCsd|j|jfS)Nz0Input data is a stream of %d bytes for file %s.
)rdr<)r$rrr�__repr__CszInputStream.__repr__)r�N)rr
rr%r�rrrrrb<s
rbc@s�eZdZdZdZdZdZdZdZdZ	ddgddgd	d
gdggZ
ddd
gZd dd�Zdd�Z
dd�Zdd�Zd!dd�Zd"dd�Zdd�Zdd�ZdS)#�
BaseOutputrr2��Nr�zx-gzipr�zx-zlibr�zx-gpgr�r�rcCs�|rt|tj�std��||_||_d|_t�|_d|_	d|_
i|_d|_d|_
d|_d|_d|_d|_|j||d�d|_dS)Nz&Expected an HTTPConnection type objectr)rr)r?rrE�	Exceptionr�_connectionr�rr]rr�transport_flagsr�r��_hostZ_handlerZ
_http_typeZ	_protocolr�_BaseOutput__processed)r$rrrrrrrr%cs$zBaseOutput.__init__cCsBt|�tg�tf�gkr0djtt|��|j|<nt|�|j|<dS)N�,)r;�join�mapr7r])r$r<r=rrrr>�szBaseOutput.set_headercCs||jkr|j|=dS)N)r])r$r<rrrrR�s
zBaseOutput.clear_headercCs�||_|j|jkr�ddl}|j|jd}|jd|�tdd�}|jdt|d�}t	j
ddkrn|jt|��n|jt
|��|j�|j�|_|j�n�|j|jkr�ddl}|j|jd}|jd|�|jt�}|j|�|j�|_n8|j|jk�r t|j|j��|j|jd}|jd|�|j|jk�rT|j|j}|jd|�|jd	d
�nH|j|jk�r�ddl}	|j|j}|jd|�|jd	d�|	j|j�|_|jdt|j��t}
ttj��dk�r�tj�d}
|jd
d|
�d|_ dS)NrzContent-Encodingr2)Z	force_mem�wb)r�r�r�r�zContent-Transfer-EncodingzContent-Typezapplication/binaryztext/base64zContent-LengthzX-Transport-Infoz=Extended Capabilities Transport (C) Red Hat, Inc (version %s))!r�r�ENCODE_GZIPr��	encodingsr>rr�r�r��version_infor�rrre�getvalue�ENCODE_ZLIBr�Zcompressobj�compressr��
ENCODE_GPGr�r�TRANSFER_BINARY�	transfers�TRANSFER_BASE64r�Zencodestringr�rp�splitr�)r$r�r�Z
encoding_namergr�r�r�Z
transfer_namer�Zrpc_versionrrrrQ�sT



zBaseOutput.processcKs||_||_|jj|�dS)N)rrr�r-)r$rrr/rrrr�szBaseOutput.set_transport_flags�/RPC2cCs�|js
t�||_|jdkr"td��|jj�|jj|j|t|j	�|j
d�|jj�}|j|�s~t
jd|j|f|j|j|j��|j|fS)NzNo connection object found)Zbodyr]z%s %s)r�rr�r�r�Zconnectr_rrr�r]Zgetresponse�response_acceptable�	xmlrpclibZ
ProtocolErrorrTrU�msg)r$rFrWrmrrrrS�s




zBaseOutput.send_httpcCsP|jdkrdS|jd
krdS|jdkr*dS|jjd�s:dS|jdd	krLdSdS)z*Returns true if the response is acceptable��r2�-�.��rZallow_partial_contentzContent-Typezapplication/octet-stream)r�r�)rTr�r4r�)r$rmrrrr��s


zBaseOutput.response_acceptablecCs|jr|jj�d|_dS)N)r�re)r$rrrre�s
zBaseOutput.close)rrNr)rr)r�)rr
rZENCODE_NONEr�r�r�Z
TRANSFER_NONEr�r�r�r�r%r>rRrQrrSr�rerrrrr�Is,
8

r�cCs�|dkrdSt|t�r8d|ko.ttj�knr8|St|t�rpx,tttj��D]}tj||j�krR|SqRW|r�td|��dS)zTGiven a string or numeric representation of a transfer, return the
    transfer codeNrzUnsupported transfer %s)	r?rr�rNr�r�ranger�rx)rr3�irrrr5s(
r5cCs�|dkrdSt|t�r8d|ko.ttj�knr8|St|t�rpx,tttj��D]}|j�tj|krR|SqRW|r�td|��dS)zUGiven a string or numeric representation of an encoding, return the
    encoding codeNrzUnsupported encoding %s)	r?rr�rNr�rr�r�rx)rr3r�rrrr6s(
r6c@s@eZdZddd�Zdd�Zddd	�Zd
d�Zdd
�Zdd�ZdS)rcrN�@cCsF||_||_|j|_||_d|_|r<||jd�dd�|_||_dS)Nr��/r2)rd�file_objrerr<�rfindr)r$r�rdr<rrrrrr%&sz
File.__init__cCs|jS)N)rd)r$rrr�__len__1szFile.__len__cCs$|dkr|j�}|j�S|jj|�S)N)�	_get_filerir�)r$r�r^rrrri4sz	File.readcCsP|j�}xB|j|j�}|sPtjddkr:|jt|��q
|jt|��q
W|S)zHCopies the contents of this File object into another file
        objectrr�)r�rirr�r�r�rr)r$�filer^r�rrr�read_to_file<szFile.read_to_filecCsL|jr,t|j|j|j|jd�}|jdd�nt|j|jd�}|jdd�|S)z�Read everything into a temporary file and call the progress
        callbacks if the file length is defined, or just reads till EOF)rrr)r)rdr�r�rrr�r�)r$r�rrrr�Js

zFile._get_filecCs|jr|j�d|_dS)N)re)r$rrr�__del__XszFile.__del__)rNNr�)N)	rr
rr%r�rir�r�r�rrrrrc%s


rc)r�r�)r�Nr�)r)r)(rur�r�ZrhnrZrhn.i18nrrZrhn.SmartIOrZrhn.UserDictCaserr��typesrrr	�ImportErrorZ
xmlrpc.clientZclientr��bytesrOrpr�r�rrrqryr�r`r�r�rbr�r5r6rNrcrrrr�<module>
sD

V8	

;
8