Your IP : 3.147.42.34


Current Path : /usr/lib/python3.6/site-packages/rhn/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/rhn/__pycache__/rpclib.cpython-36.opt-1.pyc

3

�U�f�^�@s`dZddlZddlZddlZddlmZddlmZddlm	Z	y<ddl
Z
ddlmZm
Z
mZmZmZmZddlmZmZWnFek
r�ddljZ
eZeZ
eZeZeZeZddlmZmZYnXdZd	d
�Zdd�Z d
d�Z!Gdd�de"�Z#Gdd�d�Z$Gdd�de$�Z%Gdd�de&�Z'Gdd�de&�Z(dd�Z)Gdd�d�Z*Gdd�de*�Z+dd �Z,dS)!zI2.8.62.8.6-8.module_el8.10.0+6858+3ddf28328.module_el8.10.0+6858+3ddf2832�N)�
transports)�sstr)�UserDictCase)�ListType�	TupleType�
StringType�UnicodeType�DictType�DictionaryType)�	splittype�	splithost�c	Cs"ytjtj|�dSdSdS)z5 Returns true if n is IPv6 address, false otherwise. TFN)�socketZ	inet_ptonZAF_INET6)�n�r�/usr/lib/python3.6/rpclib.py�
check_ipv6.s
rc	Cs�|jdd�}d}d}d}d}t|�dkr^|d}|djdd�}|d}t|�dkrf|d}n|d}|ddkr�tjdtd�\}}|jd�jd	�}n6t|�r�|}n(|jdd�}|d}t|�dkr�|d}||||fS)
z| Function used to split host information in an URL per RFC 2396
        handle full hostname like user:passwd@host:port
    �@�N�r�:�[z(?<=\]):�])�split�len�reZip_port�lstrip�rstripr)	Z
hoststring�l�hostZport�userZpasswdZhostportZuserinfo�arrrrr�
split_host6s,
r"cCs8|dkrtd��|jdd�}t|�dkr0|d}t|�S)NzHost string cannot be nullz://rr)�
ValueErrorrrr")�proxyr!rrr�get_proxy_info[sr%c@seZdZdS)�MalformedURIErrorN)�__name__�
__module__�__qualname__rrrrr&gsr&c	@seZdZdZejZejZej	Z
ejZd;dd�Z
d<dd�Zdd	�Zd
d�Zdd
�Zdd�Zd=dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZeZd'd(�Zd>d)d*�Z d+d,�Z!d-d.�Z"d/d0�Z#d1d2�Z$d3d4�Z%d?d5d6�Z&d7d8�Z'd9d:�Z(dS)@�Servera7uri [,options] -> a logical connection to an XML-RPC server

    uri is the connection point on the server, given as
    scheme://host/target.

    The standard implementation always supports the "http" scheme.  If
    SSL socket support is available (Python 2.0), it also supports
    "https".

    If the target part and the slash preceding it are both omitted,
    "/RPC2" is assumed.

    The following options can be given as keyword arguments:

        transport: a transport factory
        encoding: the request encoding (default is UTF-8)
        verbose: verbosity level
        proxy: use an HTTP proxy
        username: username for authenticated HTTP proxy
        password: password for authenticated HTTP proxy

    All 8-bit strings passed to the server proxy are assumed to use
    the given encoding.
    NrcCs6|dkrZt|�\}}}
}|dk	r.d||f}n|}|
dk	rZ|dkrZ|
}|dk	rZ|dkrZ|}t|�|_d|_d|_d|_||_||_||_|
|_	t
tj��dkr�tj�d|_
nt|_
|j�|dkr�d|_|j|j||||
�}nd|_d|_d|_||_g|_d|_||_||_|j|�|j|	�d|_t�|_dS)Nz%s:%srr)r%r�_uri�_refreshCallback�_progressCallback�_bufferSize�_proxy�	_username�	_password�_timeoutr�__version__r�rpc_version�_reset_host_handler_and_type�_allow_redirect�default_transport�_type�_redirected�use_handler_path�
_transport�_trusted_cert_files�_lang�	_encoding�_verbose�set_refresh_callback�set_progress_callback�send_handlerr�_headers)�self�uri�	transport�encoding�verboser$�username�password�refreshCallback�progressCallback�timeoutZphZppZpuZpwrrr�__init__�sJ



zServer.__init__cCsZ|r4|dkr |j||||d�}qV|j||||d�}n"|dkrJ|j|d�}n|j|d�}|S)N�https)Z
proxyUsernameZ
proxyPasswordrM)rM)�_transport_class_https_proxy�_transport_class_proxy�_transport_class_https�_transport_class)rD�typer$rIrJrMrFrrrr7�szServer.default_transportcCs
||_dS)N)r6)rDZallowrrr�allow_redirect�szServer.allow_redirectcCs|js
dS|jS)N)r6r9)rDrrr�
redirected�szServer.redirectedcCs||_|jj|�dS)N)r,r;r@)rDrKrrrr@�szServer.set_refresh_callbackcCs||_|jj|�dS)N)r.r;�set_buffer_size)rD�
bufferSizerrrrW�szServer.set_buffer_size�@cCs||_|jj||�dS)N)r-r;rA)rDrLrXrrrrA�szServer.set_progress_callbackcCstj|||jd�S)N)rG)�	xmlrpclib�dumpsr>)rD�params�
methodnamerrr�	_req_body�szServer._req_bodycCs|jr|jjSdS)N)r;Z
headers_in)rDrrr�get_response_headers�szServer.get_response_headerscCs|jr|jjSdS)N)r;�response_status)rDrrr�get_response_status�szServer.get_response_statuscCs|jr|jjSdS)N)r;Zresponse_reason)rDrrr�get_response_reasonszServer.get_response_reasonc	Cs�|j�}|sdS|jd�}|s"dStd|j��}|djd�}|\}}|dkrTd}nt|�}|jd�\}}|t|�t|�d�}|S)aSReturns a dictionary with three values:
            length: the total length of the entity-body (can be None)
            first_byte_pos: the position of the first byte (zero based)
            last_byte_pos: the position of the last byte (zero based)
           The range is inclusive; that is, a response 8-9/102 means two bytes
        Nz
Content-Ranger�/�*�-)ZlengthZfirst_byte_posZ
last_byte_pos)r_�get�filterr�int)	rD�headersZ
content_ranger!�brangeZ	total_len�start�end�resultrrr�get_content_ranges"
zServer.get_content_rangecCs$|j�}|sdSd|kr |dSdS)Nz
Accept-Ranges)r_)rDrirrr�
accept_ranges)szServer.accept_rangescCs�t|j�\}}|dkrtd��t|�dks:|dd�dkr>t�|dkrR|j�|_n||_|jdkrjtd	��t|�\|_|_	|j	s�d
|_	dS)z Reset the attributes:
            self._host, self._handler, self._type
            according the value of self._uri.
        Nzmissing protocol in uri�rrz//�httprOzunsupported XML-RPC protocolz/RPC2)rqrO)
rr+r&r�lowerr8�IOErrorr�_host�_handler)rDrTrErrrr51s
z#Server._reset_host_handler_and_typecs�d}g}x�|D]�}t|�}|tks*|tkr>tj|dt|��}nf|tkr^t�fdd�|D��}nF|tkrz�fdd�|D�}n*|t	ks�|t
kr�t�fdd�|j�D��}|j
|�qWt|�dkr�|d	St|�Sd
S)a> Strip characters, which are not allowed according:
            http://www.w3.org/TR/2006/REC-xml-20060816/#charsets
            From spec:
            Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]  /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */
        z#[\x00-\x09]|[\x0b-\x0c]|[\x0e-\x1f]�c3s|]}�j|�VqdS)N)�_strip_characters)�.0�i)rDrr�	<genexpr>Usz+Server._strip_characters.<locals>.<genexpr>csg|]}�j|��qSr)rw)rxry)rDrr�
<listcomp>Wsz,Server._strip_characters.<locals>.<listcomp>csg|]\}}�j||��qSr)rw)rx�name�val)rDrrr{YsrrN)rTrrr�subrr�tuplerr	r
�dict�items�appendr)rD�argsZregexprm�itemZ	item_typer)rDrrwHs 
zServer._strip_charactersc
Cs�d}d}|j��xt|tkr$td��|jj�x$|jj�D]\}}|jj||�q:W|jjdd|j	�|jjdd�|j
r�|jjdd�|r�|jjd	d
�|jr�|jjd|j�|j|j
|�|�}y&|jj|j|j||jd�}|jj}	Wn2tjk
�r|j�r
�ntj�dj}	YnXd
|_|d7}|	dk�r:Pn|	dk�rLd|_q|jj�|_d|_d}|j
�srtd��|j�r�td|j|jf�t|j�\}
}|
d
k�r�|
j�}
|
dk�r�td|
��|jdk�r�|
dk�r�td��t |�\|_|_|j�sd|_|`|j!|
|j"|j#|j$|j%�|_|j&|j'�|j(|j)�|j*|j+�|j,|j-�|j.gkrt/|jd�rx|j.D]}|jj0|��qnWqWt1|t2j3��r�|St1|t4��r�t5|�dk�r�|d}|S)zL Call a method on the remote server
            we can handle redirections. rz!Unable to fetch requested PackagezX-Infoz+RPC Processor (C) Red Hat, Inc (version %s)zX-Client-VersionrzX-RHN-Transport-Capabilityzfollow-redirects=3zX-RHN-Redirect�0z
X-RHN-Path)rHN���-�.zRedirects not allowedz%s redirected to %srqrOz%Redirected to unsupported protocol %sz)HTTPS redirected to HTTP is not supportedz/RPC2�add_trusted_cert)r�r�)rqrO)6r5�MAX_REDIRECTIONS�InvalidRedirectionErrorr;Z
clear_headersrCr��
set_header�
add_headerr4r6rBr^rw�requestrtrur?r`rZZ
ProtocolErrorr:�sys�exc_info�errcoder9rV�printr+rrrr8rr7r/r0r1r2rAr-r@r,rWr.�setlangr=r<�hasattrr��
isinstancerZFilerr)
rDr]r\Zredirect_responseZretry�k�vr�ZresponseZ
save_response�typrE�certfilerrr�_requestbs�









zServer._requestcCsd|jj|j|jfS)Nz
<%s for %s%s>)�	__class__r'rtru)rDrrr�__repr__�szServer.__repr__cCst|j|�S)N)�_Methodr�)rDr|rrr�__getattr__�szServer.__getattr__cKs,|js
dS|j||d��|jjf|�dS)N)�transferrG)r;�update�set_transport_flags)rDr�rG�kwargsrrrr��s
zServer.set_transport_flagscCs|js
iS|jj�S)N)r;�get_transport_flags)rDrrrr��szServer.get_transport_flagscCsdS)Nr)rDrrr�reset_transport_flags�szServer.reset_transport_flagscCs@t|�tg�tf�gkr.dd�|D�|j|<nt|�|j|<dS)NcSsg|]}t|��qSr)�str)rx�arrrr{�sz%Server.set_header.<locals>.<listcomp>)rTrCr�)rDr|�argrrrr��szServer.set_headercCsF||jkr&|j|}t|t�s4|g}ng}|j|<|jt|��dS)N)rCr�rr�r�)rDr|r�Zvlistrrrr�s


zServer.add_headercCs(||_|jr$t|jd�r$|jj|�dS)Nr�)r=r;r�r�)rDZlangrrrr�
szServer.setlangcCstd��dS)NzThis method is deprecated)�NotImplementedError)rDZca_chainrrr�use_CA_chainszServer.use_CA_chaincCs.|jj|�|jr*t|jd�r*|jj|�dS)Nr�)r<r�r;r�r�)rDr�rrrr�szServer.add_trusted_certcCs|jr|jj�d|_dS)N)r;�close)rDrrrr�s
zServer.close)	NNrNNNNNN)NNNN)rY)rr)N))r'r(r)�__doc__rZ	TransportrSZ
SafeTransportrRZProxyTransportrQZSafeProxyTransportrPrNr7rUrVr@rWrAr^r_rarbrnror5rwr�r��__str__r�r�r�r�r�r�r�r�r�r�rrrrr*lsH
C

#s



r*c	@s\eZdZdddddidddf	dd�Zdd�Zdd�Zdd	d
�Zdd�Zd
d�Zddd�Z	dS)�	GETServerNrcCsBtj||||||||	|
d�	||_||_|j|_|jddd�dS)N)r$rIrJrFrKrLrM)�offset�amount)r*rNZ_client_versionrCru�
_orig_handler�	set_range)rDrErFr$rIrJZclient_versionrirKrLrMrrrrNszGETServer.__init__cCs$|st|�dkrtd��tdd�|jjd��}|d|d|gt|dd��}ddj|�|_|j|_|j	r�|j
r�|j�|_x$|jj
�D]\}}|jj||�q�W|jdk	�r |jdkr�t|j�d}|jdk	r�|t|j|jd�}ndt|j�}|jjd	d
|�|jjdd�dS)
Nrz$Required parameter channel not foundcSs|dkS)Nrvr)�xrrr�<lambda>5sz%GETServer._req_body.<locals>.<lambda>rcz$RHNrreZRangezbytes=)�allow_partial_contentrv)r�	Exceptionrgr�r�list�joinrurBr9r:�
_new_req_bodyrCr�r;r��_offsetr��_amountr�)rDr\r]Zh_compsZhndl�hr�rjrrrr^1s&"


zGETServer._req_bodycCst|j�\}}t|�\}}|S)N)rr9r)rDrTZtmpuriZsiteZhandlerrrrr�UszGETServer._new_req_bodycCs�|dk	rByt|�}Wn,tk
r@td|dtj�d��YnX|dk	r�yt|�}Wn,tk
r�td|dtj�d��YnX|dkr�td|��||_||_dS)NzInvalid value `%s' for offsetrzInvalid value `%s' for amountr)rhr#�
RangeErrorr�r�r�r�)rDr�r�rrrr�ZszGETServer.set_rangecCs|jjdd�dS)Nr)r�)r;r�)rDrrrr�oszGETServer.reset_transport_flagscCst|j|�S)N)�
SlicingMethodr�)rDr|rrrr�rszGETServer.__getattr__cCs$tj||||||d�}|jd�|S)N)r$rIrJrMZGET)r*r7Z
set_method)rDrTr$rIrJrM�retrrrr7vs
zGETServer.default_transport)NN)NNNN)
r'r(r)rNr^r�r�r�r�r7rrrrr�s$
r�c@seZdZdS)r�N)r'r(r)rrrrr�|sr�c@seZdZdS)r�N)r'r(r)rrrrr�sr�cCs>ddl}t||j�s*||kr&||gSgSdd�|j|�D�S)NrcSs g|]}|jdd�dj��qS)rr)r�strip)rxr�rrrr{�sz#getHeaderValues.<locals>.<listcomp>)�	mimetoolsr�ZMessageZgetallmatchingheaders)rir|r�rrr�getHeaderValues�s
r�c@s4eZdZdZdd�Zdd�Zdd�Zdd	�ZeZd
S)r�z{ some magic to bind an XML-RPC method to an RPC server.
        supports "nested" methods (e.g. examples.getStateName)
    cCs||_||_dS)N)�_send�_name)rD�sendr|rrrrN�sz_Method.__init__cCst|jd|j|f�S)Nz%s.%s)r�r�r�)rDr|rrrr��sz_Method.__getattr__cGs|j|j|�S)N)r�r�)rDr�rrr�__call__�sz_Method.__call__cCsd|jj|j|jfS)Nz<%s %s (%s)>)r�r'r�r�)rDrrrr��sz_Method.__repr__N)	r'r(r)r�rNr�r�r�r�rrrrr��sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r�z;
    A "slicing method" allows for byte range requests
    cCstj|||�d|_dS)N)r�rNr�)rDr�r|rrrrN�szSlicingMethod.__init__cCst|jd|j|f�S)Nz%s.%s)r�r�r�)rDr|rrrr��szSlicingMethod.__getattr__cOs�|jd�|_|jd�|_y|jjj|j|jd�Wntk
rFYnX|j|j|�}y|jjj�Wntk
rzYnX|S)Nr�r�)r�r�)	rfr�r�r�Zim_selfr��AttributeErrorr�r�)rDr�r�rmrrrr��szSlicingMethod.__call__N)r'r(r)r�rNr�r�rrrrr��sr�cCsbd}d}d}||kr t||�}d}||krZt||�}|rZdj|�}ddl}d|j|�}||fS)z% Reports the error from the headers. rrvzX-RHN-Fault-CodezX-RHN-Fault-StringNz%s)rhr�r��base64Zdecodestring)rir��errmsg�sZ_sListZ_sr�rrr�reportError�s

r�)-r3rrr�ZrhnrZrhn.i18nrZrhn.UserDictCaserrZ�typesrrrrr	r
Zurllibrr�ImportErrorZ
xmlrpc.clientZclientr�r�bytesr�r�Zurllib.parser�rr"r%rsr&r*r�r�r�r�r�r�r�r�rrrr�<module>sF 
%5^


?>