AlkantarClanX12

Your IP : 18.220.112.210


Current Path : /opt/alt/python35/lib64/python3.5/xmlrpc/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/xmlrpc/__pycache__/client.cpython-35.pyc



��Yf���&@s�dZddlZddlZddlZddlmZddlZddlZddl	m
Z
ddlZddlm
Z
yddlZWnek
r�dZYnXdd�Zejdd�ZdXZdZZd[Zd\Zd]Zd^Zd_Zd`ZdaZdbZdcZddZdeZdfZ Gdd�de!�Z"Gdd�de"�Z#Gdd�de"�Z$Gdd�de"�Z%e&Z'Z(eddd�Z)e)j*d�dkr�d d!�Z+n0e)j*d"�dkr�d#d!�Z+nd$d!�Z+[)d%d&�Z,Gd'd(�d(�Z-d)d*�Z.d+d,�Z/Gd-d.�d.�Z0d/d0�Z1e-e0fZ2Gd1d2�d2�Z3Gd3d4�d4�Z4Gd5d6�d6�Z5Gd7d8�d8�Z6Gd9d:�d:�Z7Gd;d<�d<�Z8dZ9Z:Z;d=d=d>d?�Z<dddd=d@dA�Z=d=d=dBdC�Z>dDdE�Z?dFdGdH�Z@GdIdJ�dJer<ejAneB�ZCGdKdL�dL�ZDGdMdN�dN�ZEGdOdP�dPeE�ZFGdQdR�dR�ZGeGZHeIdSkr�eGdT�ZJyeKeJjLjM��Wn2e"k
r�ZNzeKdUeN�WYddZN[NXnXe8eJ�ZOeOjP�eOjQd	dV�eOjRdd	�y"xeO�D]ZSeKeS�qAWWn2e"k
r�ZNzeKdUeN�WYddZN[NXnXdS)ga�
An XML-RPC client interface for Python.

The marshalling and response parser code can also be used to
implement XML-RPC servers.

Exported exceptions:

  Error          Base class for client errors
  ProtocolError  Indicates an HTTP protocol error
  ResponseError  Indicates a broken response package
  Fault          Indicates an XML-RPC fault package

Exported classes:

  ServerProxy    Represents a logical connection to an XML-RPC server

  MultiCall      Executor of boxcared xmlrpc requests
  DateTime       dateTime wrapper for an ISO 8601 string or time tuple or
                 localtime integer value to generate a "dateTime.iso8601"
                 XML-RPC value
  Binary         binary data wrapper

  Marshaller     Generate an XML-RPC params chunk from a Python data structure
  Unmarshaller   Unmarshal an XML-RPC response from incoming XML event message
  Transport      Handles an HTTP transaction to an XML-RPC server
  SafeTransport  Handles an HTTPS transaction to an XML-RPC server

Exported constants:

  (none)

Exported functions:

  getparser      Create instance of the fastest available parser & attach
                 to an unmarshalling object
  dumps          Convert an argument tuple or a Fault instance to an XML-RPC
                 request (or response, if the methodresponse option is used).
  loads          Convert an XML-RPC packet to unmarshalled data plus a method
                 name (None if not present).
�N)�datetime)�expat)�BytesIOcCs4|jdd�}|jdd�}|jdd�S)N�&z&amp;�<z&lt;�>z&gt;)�replace)�s�r
�2/opt/alt/python35/lib64/python3.5/xmlrpc/client.py�escape�sr����i�iXi�~i�~i,~i�i�iYiZi[c@s"eZdZdZdd�ZdS)�ErrorzBase class for client errors.cCs
t|�S)N)�repr)�selfr
r
r�__str__�sz
Error.__str__N)�__name__�
__module__�__qualname__�__doc__rr
r
r
rr�src@s.eZdZdZdd�Zdd�ZdS)�
ProtocolErrorz!Indicates an HTTP protocol error.cCs5tj|�||_||_||_||_dS)N)r�__init__�url�errcode�errmsg�headers)rrrrrr
r
rr�s

			zProtocolError.__init__cCs#d|jj|j|j|jfS)Nz<%s for %s: %s %s>)�	__class__rrrr)rr
r
r�__repr__�szProtocolError.__repr__N)rrrrrr r
r
r
rr�src@seZdZdZdS)�
ResponseErrorz$Indicates a broken response package.N)rrrrr
r
r
rr!�sr!c@s.eZdZdZdd�Zdd�ZdS)�Faultz#Indicates an XML-RPC fault package.cKs#tj|�||_||_dS)N)rr�	faultCode�faultString)rr#r$Zextrar
r
rr�s
	zFault.__init__cCsd|jj|j|jfS)Nz<%s %s: %r>)rrr#r$)rr
r
rr �szFault.__repr__N)rrrrrr r
r
r
rr"�sr"z%YZ0001cCs
|jd�S)Nz%Y%m%dT%H:%M:%S)�strftime)�valuer
r
r�_iso8601_formatsr'z%4YcCs
|jd�S)Nz%4Y%m%dT%H:%M:%S)r%)r&r
r
rr'scCs|jd�jd�S)Nz%Y%m%dT%H:%M:%S�)r%�zfill)r&r
r
rr'scCsjt|t�rt|�St|ttjf�sX|dkrItj�}tj|�}d|dd�S)Nrz%04d%02d%02dT%02d:%02d:%02d�)�
isinstancerr'�tuple�timeZstruct_timeZ	localtime)r&r
r
r�	_strftimes
r.c@s�eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�DateTimez�DateTime wrapper for an ISO 8601 string or time tuple or
    localtime integer value to generate 'dateTime.iso8601' XML-RPC
    value.
    rcCs.t|t�r||_nt|�|_dS)N)r+�strr&r.)rr&r
r
rr(szDateTime.__init__cCs�t|t�r$|j}|j}n�t|t�rK|j}t|�}n�t|t�rl|j}|}nmt|d�r�|j�}|j�}nCt|d�r�|jj	p�t
|�}td|jj	|f��||fS)N�	timetuplerzCan't compare %s and %s)r+r/r&rr'r0�hasattrr1rr�type�	TypeError)r�otherr	�oZotyper
r
r�make_comparable.s$				zDateTime.make_comparablecCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__lt__CszDateTime.__lt__cCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__le__GszDateTime.__le__cCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__gt__KszDateTime.__gt__cCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__ge__OszDateTime.__ge__cCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__eq__SszDateTime.__eq__cCstj|jd�S)Nz%Y%m%dT%H:%M:%S)r-�strptimer&)rr
r
rr1WszDateTime.timetuplecCs|jS)N)r&)rr
r
rr_szDateTime.__str__cCs d|jj|jt|�fS)Nz<%s %r at %#x>)rrr&�id)rr
r
rr bszDateTime.__repr__cCst|�j�|_dS)N)r0�stripr&)r�datar
r
r�decodeeszDateTime.decodecCs.|jd�|j|j�|jd�dS)Nz<value><dateTime.iso8601>z</dateTime.iso8601></value>
)�writer&)r�outr
r
r�encodehs
zDateTime.encodeN)rrrrrr7r8r9r:r;r<r1rr rArDr
r
r
rr/"sr/cCst�}|j|�|S)N)r/rA)r@r&r
r
r�	_datetimems	
rEcCstj|d�S)Nz%Y%m%dT%H:%M:%S)rr=)r@r
r
r�_datetime_typessrFc@sUeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�ZdS)
�BinaryzWrapper for binary data.NcCsY|dkrd}n7t|ttf�s@td|jj��t|�}||_dS)N�z#expected bytes or bytearray, not %s)r+�bytes�	bytearrayr4rrr@)rr@r
r
rrs	zBinary.__init__cCst|jd�S)Nzlatin-1)r0r@)rr
r
rr�szBinary.__str__cCs%t|t�r|j}|j|kS)N)r+rGr@)rr5r
r
rr<�s	z
Binary.__eq__cCstj|�|_dS)N)�base64�decodebytesr@)rr@r
r
rrA�sz
Binary.decodecCsF|jd�tj|j�}|j|jd��|jd�dS)Nz<value><base64>
�asciiz</base64></value>
)rBrK�encodebytesr@rA)rrC�encodedr
r
rrD�s
z
Binary.encode)	rrrrrrr<rArDr
r
r
rrG|srGcCst�}|j|�|S)N)rGrA)r@r&r
r
r�_binary�s	
rPc@s4eZdZdd�Zdd�Zdd�ZdS)�ExpatParsercCs`tjdd�|_}||_|j|_|j|_|j|_	d}|j
|d�dS)N)rZParserCreate�_parser�_target�startZStartElementHandler�endZEndElementHandlerr@ZCharacterDataHandler�xml)r�target�parser�encodingr
r
rr�s	zExpatParser.__init__cCs|jj|d�dS)Nr)rR�Parse)rr@r
r
r�feed�szExpatParser.feedcCsBy
|j}Wntk
r!YnX|`|`|jdd�dS)NrHT)rR�AttributeErrorrSrZ)rrXr
r
r�close�s

zExpatParser.closeN)rrrrr[r]r
r
r
rrQ�s	rQc@s\eZdZdZdddd�ZiZdd�Zdd	�Zd
d�Zeee	d�<dd
�Z
e
ee<dd�Zeee
<eZdd�Zeee<edd�Zeee<dd�Zeee<eee<dd�Zeee<eee<edd�Zeee<dd�Zeee<dd�Zeee<eee <eed<dS)�
MarshalleravGenerate an XML-RPC params chunk from a Python data structure.

    Create a Marshaller instance for each set of parameters, and use
    the "dumps" method to convert your data (represented as a tuple)
    to an XML-RPC params chunk.  To write a fault response, pass a
    Fault instance instead.  You may prefer to use the "dumps" module
    function for this purpose.
    NFcCs(i|_d|_||_||_dS)N)�memor@rY�
allow_none)rrYr`r
r
rr�s			zMarshaller.__init__cCs�g}|j}|j}t|t�r]|d�|d|jd|ji|�|d�nF|d�x/|D]'}|d�|||�|d�qnW|d�d	j|�}|S)
Nz<fault>
r#r$z	</fault>
z	<params>
z<param>
z	</param>
z
</params>
�)�append�_Marshaller__dumpr+r"r#r$�join)r�valuesrCrB�dump�v�resultr
r
r�dumps�s"		






zMarshaller.dumpscCs�y|jt|�}Wn�tk
r�t|d�sLtdt|���xBt|�jD]1}||jj�kr\tdt|���q\W|jd}YnX||||�dS)N�__dict__zcannot marshal %s objects�_arbitrary_instance)�dispatchr3�KeyErrorr2r4�__mro__�keys)rr&rB�fZtype_r
r
rZ__dump�s
zMarshaller.__dumpcCs#|jstd��|d�dS)Nz0cannot marshal None unless allow_none is enabledz<value><nil/></value>)r`r4)rr&rBr
r
r�dump_nil
s	zMarshaller.dump_nilcCs.|d�||rdpd�|d�dS)Nz<value><boolean>�1�0z</boolean></value>
r
)rr&rBr
r
r�	dump_bools
zMarshaller.dump_boolcCsR|tks|tkr$td��|d�|tt|���|d�dS)Nzint exceeds XML-RPC limitsz<value><int>z</int></value>
)�MAXINT�MININT�
OverflowErrorr0�int)rr&rBr
r
r�	dump_longs

zMarshaller.dump_longcCs(|d�|t|��|d�dS)Nz<value><double>z</double></value>
)r)rr&rBr
r
r�dump_double$s
zMarshaller.dump_doublecCs(|d�|||��|d�dS)Nz<value><string>z</string></value>
r
)rr&rBrr
r
r�dump_unicode*s
zMarshaller.dump_unicodecCs:|d�tj|�}||jd��|d�dS)Nz<value><base64>
rMz</base64></value>
)rKrNrA)rr&rBrOr
r
r�
dump_bytes0s
zMarshaller.dump_bytescCs}t|�}||jkr'td��d|j|<|j}|d�x|D]}|||�qNW|d�|j|=dS)Nz"cannot marshal recursive sequencesz<value><array><data>
z</data></array></value>
)r>r_r4rc)rr&rB�irfrgr
r
r�
dump_array8s
	


zMarshaller.dump_arraycCs�t|�}||jkr'td��d|j|<|j}|d�xj|j�D]\\}}|d�t|t�s�td��|d||��|||�|d�qTW|d�|j|=dS)Nz%cannot marshal recursive dictionariesz<value><struct>
z	<member>
zdictionary key must be stringz<name>%s</name>
z
</member>
z</struct></value>
)r>r_r4rc�itemsr+r0)rr&rBrr}rf�krgr
r
r�dump_structFs
	



zMarshaller.dump_structcCs(|d�|t|��|d�dS)Nz<value><dateTime.iso8601>z</dateTime.iso8601></value>
)r.)rr&rBr
r
r�
dump_datetimeXs
zMarshaller.dump_datetimecCsE|jtkr.||_|j|�|`n|j|j|�dS)N)r�WRAPPERSrBrDr�rj)rr&rBr
r
r�
dump_instance^s
	
	zMarshaller.dump_instancerk)!rrrrrrlrircrqr3rt�boolryrxZdump_intrz�floatrr{r0r|rIrJr~r,�listr��dictr�rr�r/rGr
r
r
rr^�s<









	

r^c@s�eZdZdZdddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZiZdd�Z
e
ed<dd�Zeed<dd�Zeed<eed<eed<dd�Zeed <d!d"�Zeed#<eed$<d%d&�Zeed'<d(d)�Zeed*<d+d,�Zeed-<d.d/�Zeed0<d1d2�Zeed3<d4d5�Zeed6<d7d8�Zeed9<d:d;�Zeed<<d=S)>�UnmarshalleraUnmarshal an XML-RPC response, based on incoming XML event
    messages (start, data, end).  Call close() to get the resulting
    data structure.

    Note that this reader is fairly tolerant, and gladly accepts bogus
    XML-RPC data without complaining (but not bogus XML).
    FcCsjd|_g|_g|_g|_d|_d|_d|_|jj|_|pW||_||_	dS)NFzutf-8)
�_type�_stack�_marks�_data�_value�_methodname�	_encodingrb�
_use_datetime�
_use_bytes)r�use_datetime�use_builtin_typesr
r
rr~s							zUnmarshaller.__init__cCsP|jdks|jr!t��|jdkrCt|jd��t|j�S)N�faultr)r�r�r!r"r�r,)rr
r
rr]�s
	zUnmarshaller.closecCs|jS)N)r�)rr
r
r�
getmethodname�szUnmarshaller.getmethodnamecCs
||_dS)N)r�)rrYZ
standaloner
r
rrV�szUnmarshaller.xmlcCsu|dks|dkr1|jjt|j��g|_|jrb||jkrbtd|��|dk|_dS)N�array�structzunknown tag %rr&)r�rb�lenr�r�r�rlr!)r�tagZattrsr
r
rrT�s	zUnmarshaller.startcCs|jj|�dS)N)r�rb)r�textr
r
rr@�szUnmarshaller.datacCsCy|j|}Wntk
r%YnX||dj|j��SdS)Nra)rlrmrdr�)rr�rpr
r
rrU�s

zUnmarshaller.endcCs7y|j|}Wntk
r%YnX|||�SdS)N)rlrm)rr�r@rpr
r
r�end_dispatch�s

zUnmarshaller.end_dispatchcCs|jd�d|_dS)Nr)rbr�)rr@r
r
r�end_nil�s
zUnmarshaller.end_nilZnilcCsQ|dkr|jd�n(|dkr8|jd�ntd��d|_dS)NrsFrrTzbad boolean valuer)rbr4r�)rr@r
r
r�end_boolean�szUnmarshaller.end_boolean�booleancCs |jt|��d|_dS)Nr)rbrxr�)rr@r
r
r�end_int�szUnmarshaller.end_intZi4Zi8rxcCs |jt|��d|_dS)Nr)rbr�r�)rr@r
r
r�
end_double�szUnmarshaller.end_doubleZdoublecCs5|jr|j|j�}|j|�d|_dS)Nr)r�rArbr�)rr@r
r
r�
end_string�s	
zUnmarshaller.end_string�string�namecCs?|jj�}|j|d�g|j|d�<d|_dS)Nr)r��popr�r�)rr@�markr
r
r�	end_array�s#zUnmarshaller.end_arrayr�cCs�|jj�}i}|j|d�}x6tdt|�d�D]}||d|||<qAW|g|j|d�<d|_dS)Nrrr)r�r�r��ranger�r�)rr@r�r�rr}r
r
r�
end_struct�szUnmarshaller.end_structr�cCsKt�}|j|jd��|jr1|j}|j|�d|_dS)NrMr)rGrArDr�r@rbr�)rr@r&r
r
r�
end_base64�s			
zUnmarshaller.end_base64rKcCs<t�}|j|�|jr+t|�}|j|�dS)N)r/rAr�rFrb)rr@r&r
r
r�end_dateTimes
	
	zUnmarshaller.end_dateTimezdateTime.iso8601cCs|jr|j|�dS)N)r�r�)rr@r
r
r�	end_values	zUnmarshaller.end_valuer&cCs
d|_dS)N�params)r�)rr@r
r
r�
end_paramsszUnmarshaller.end_paramsr�cCs
d|_dS)Nr�)r�)rr@r
r
r�	end_faultszUnmarshaller.end_faultr�cCs1|jr|j|j�}||_d|_dS)N�
methodName)r�rAr�r�)rr@r
r
r�end_methodNames		zUnmarshaller.end_methodNamer�N)rrrrrr]r�rVrTr@rUr�rlr�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr�rsN	








	





r�c@s4eZdZdd�Zdd�Zdd�ZdS)�_MultiCallMethodcCs||_||_dS)N)�_MultiCallMethod__call_list�_MultiCallMethod__name)rZ	call_listr�r
r
rr$s	z_MultiCallMethod.__init__cCst|jd|j|f�S)Nz%s.%s)r�r�r�)rr�r
r
r�__getattr__'sz_MultiCallMethod.__getattr__cGs|jj|j|f�dS)N)r�rbr�)r�argsr
r
r�__call__)sz_MultiCallMethod.__call__N)rrrrr�r�r
r
r
rr�!sr�c@s.eZdZdZdd�Zdd�ZdS)�MultiCallIteratorzaIterates over the results of a multicall. Exceptions are
    raised in response to xmlrpc faults.cCs
||_dS)N)�results)rr�r
r
rr0szMultiCallIterator.__init__cCso|j|}t|�ti�kr?t|d|d��n,t|�tg�kr_|dStd��dS)Nr#r$rz#unexpected type in multicall result)r�r3r"�
ValueError)rr}�itemr
r
r�__getitem__3s
zMultiCallIterator.__getitem__N)rrrrrr�r
r
r
rr�,sr�c@sLeZdZdZdd�Zdd�ZeZdd�Zdd	�Zd
S)�	MultiCalla~server -> an object used to boxcar method calls

    server should be a ServerProxy object.

    Methods can be added to the MultiCall using normal
    method call syntax e.g.:

    multicall = MultiCall(server_proxy)
    multicall.add(2,3)
    multicall.get_address("Guido")

    To execute the multicall, call the MultiCall object e.g.:

    add_result, address = multicall()
    cCs||_g|_dS)N)�_MultiCall__server�_MultiCall__call_list)r�serverr
r
rrMs	zMultiCall.__init__cCsd|jjt|�fS)Nz<%s at %#x>)rrr>)rr
r
rr QszMultiCall.__repr__cCst|j|�S)N)r�r�)rr�r
r
rr�VszMultiCall.__getattr__cCsRg}x0|jD]%\}}|jd|d|i�qWt|jjj|��S)Nr�r�)r�rbr�r��systemZ	multicall)rZmarshalled_listr�r�r
r
rr�YszMultiCall.__call__N)	rrrrrr rr�r�r
r
r
rr�<sr�FcCs�trltrl|r$t}tj}n!|r9t}t}nt}t}tdd||t�}t|�}n6td|d|�}tr�t|�}nt	|�}||fS)z�getparser() -> parser, unmarshaller

    Create an instance of the fastest available parser, and attach it
    to an unmarshalling object.  Return both objects.
    TFr�r�)
�
FastParser�FastUnmarshallerrFrKrLrPrEr"r�rQ)r�r�Z
mkdatetimeZmkbytesrWrXr
r
r�	getparserks 	r�cCst|ttf�s!td��t|t�r9d}n3|rlt|t�rlt|�dksltd��|sxd}tr�t|�}nt||�}|j|�}|dkr�dt|�}nd}|r�|d|d|d	f}n|r|d
|df}n|Sdj	|�S)
a�data [,options] -> marshalled data

    Convert an argument tuple or a Fault instance to an XML-RPC
    request (or response, if the methodresponse option is used).

    In addition to the data object, the following options can be given
    as keyword arguments:

        methodname: the method name for a methodCall packet

        methodresponse: true to create a methodResponse packet.
        If this option is used with a tuple, the tuple must be
        a singleton (i.e. it can contain only one element).

        encoding: the packet encoding (default is UTF-8)

    All byte strings in the data structure are assumed to use the
    packet encoding.  Unicode strings are automatically converted,
    where necessary.
    z(argument must be tuple or Fault instancerz"response tuple must be a singletonzutf-8z$<?xml version='1.0' encoding='%s'?>
z<?xml version='1.0'?>
z<methodCall>
<methodName>z</methodName>
z</methodCall>
z<methodResponse>
z</methodResponse>
ra)
r+r,r"�AssertionErrorr��FastMarshallerr^rir0rd)r��
methodnameZmethodresponserYr`�mr@Z	xmlheaderr
r
rri�s6!	ricCsHtd|d|�\}}|j|�|j�|j�|j�fS)z�data -> unmarshalled data, method name

    Convert an XML-RPC packet to unmarshalled data plus a method
    name (None if not present).

    If the XML-RPC packet represents a fault condition, this function
    raises a Fault exception.
    r�r�)r�r[r]r�)r@r�r��p�ur
r
r�loads�s	

r�c	CsTtst�t�}tjddd|dd��}|j|�WdQRX|j�S)zhdata -> gzip encoded data

    Encode data using the gzip content encoding as described in RFC 1952
    �mode�wb�fileobjZ
compresslevelrN)�gzip�NotImplementedErrorr�GzipFilerB�getvalue)r@rp�gzfr
r
r�gzip_encode�s	!r�i@cCs�tst�tjdddt|���Z}y2|dkrK|j�}n|j|d�}Wntk
rtd��YnXWdQRX|dkr�t|�|kr�td��|S)	zrgzip encoded data -> unencoded data

    Decode data using the gzip content encoding as described in RFC 1952
    r��rbr�rrzinvalid dataNz#max gzipped payload length exceeded)r�r�r�r�read�OSErrorr�r�)r@Z
max_decoder�Zdecodedr
r
r�gzip_decodes!
r�c@s.eZdZdZdd�Zdd�ZdS)�GzipDecodedResponsezha file-like object to decode a response encoded with the gzip
    method, as described in RFC 1952.
    cCsDtst�t|j��|_tjj|ddd|j�dS)Nr�r�r�)r�r�rr��ior�r)r�responser
r
rr)szGzipDecodedResponse.__init__c
Cs)ztjj|�Wd|jj�XdS)N)r�r�r]r�)rr
r
rr]1szGzipDecodedResponse.closeN)rrrrrr]r
r
r
rr�%sr�c@s4eZdZdd�Zdd�Zdd�ZdS)�_MethodcCs||_||_dS)N)�
_Method__send�
_Method__name)r�sendr�r
r
rr>s	z_Method.__init__cCst|jd|j|f�S)Nz%s.%s)r�r�r�)rr�r
r
rr�Asz_Method.__getattr__cGs|j|j|�S)N)r�r�)rr�r
r
rr�Csz_Method.__call__N)rrrrr�r�r
r
r
rr�;sr�c@s�eZdZdZdeZdZdZdddd�Zddd	�Z	dd
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�	Transportz1Handles an HTTP transaction to an XML-RPC server.zPython-xmlrpc/%sTNFcCs(||_||_d|_g|_dS)N)NN)r��_use_builtin_types�_connection�_extra_headers)rr�r�r
r
rrZs			zTransport.__init__cCs�x�dD]�}y|j||||�SWqtjjk
rJ|rF�Yqtk
r�}z/|s�|jtjtjtjfkr��WYdd}~XqXqWdS)Nrr)rr)	�single_request�http�clientZRemoteDisconnectedr��errnoZ
ECONNRESETZECONNABORTEDZEPIPE)r�host�handler�request_body�verboser}�er
r
r�requestjs
zTransport.requestcCs�yM|j||||�}|j�}|jdkrL||_|j|�SWn3tk
rd�Yntk
r�|j��YnX|jdd�r�|j	�t
|||j|jt|j
����dS)N��zcontent-lengthra)�send_requestZgetresponseZstatusr��parse_responser"�	Exceptionr]�	getheaderr�r�reasonr�Z
getheaders)rr�r�r�r�Z	http_connZrespr
r
rr�ws"	



zTransport.single_requestcCstd|jd|j�S)Nr�r�)r�r�r�)rr
r
rr��szTransport.getparsercCs�i}t|t�r!|\}}tjj|�\}}|r�tjj|�}tj|�jd�}dj	|j
��}dd|fg}ng}|||fS)Nzutf-8raZ
AuthorizationzBasic )r+r,�urllib�parseZ	splituserZunquote_to_bytesrKrNrArd�split)rr��x509ZauthZ
extra_headersr
r
r�
get_host_info�szTransport.get_host_infocCsh|jr'||jdkr'|jdS|j|�\}|_}|tjj|�f|_|jdS)Nrr)r�r�r�r�r�ZHTTPConnection)rr��chostr�r
r
r�make_connection�s
zTransport.make_connectioncCs,|j\}}|r(d|_|j�dS)N)NN)r�r])rr��
connectionr
r
rr]�s	zTransport.closecCs�|j|�}|jdd�}|r5|jd�|jrjtrj|jd|dd�|jd
�n|jd|�|jd�|jd	|jf�|j||�|j	||�|S)NrZPOSTZskip_accept_encodingT�Accept-Encodingr��Content-Type�text/xmlz
User-Agent)r�r�)r�r�)
r�r�Zset_debuglevel�accept_gzip_encodingr�Z
putrequestrb�
user_agent�send_headers�send_content)rr�r�r��debugr�rr
r
rr��s

zTransport.send_requestcCs+x$|D]\}}|j||�qWdS)N)�	putheader)rr�r�key�valr
r
rr�szTransport.send_headerscCss|jdk	rF|jt|�krFtrF|jdd�t|�}|jdtt|���|j|�dS)NzContent-Encodingr�zContent-Length)�encode_thresholdr�r�rr�r0Z
endheaders)rr�r�r
r
rrszTransport.send_contentcCs�t|d�r?|jdd�dkr6t|�}qE|}n|}|j�\}}xC|jd�}|spP|jr�tdt|��|j|�qZW||k	r�|j	�|j	�|j	�S)Nr�zContent-Encodingrar�izbody:)
r2r�r�r�r�r��printrr[r])rr��streamr�r�r@r
r
rr�s"		

zTransport.parse_response)rrrr�__version__rr�rrr�r�r�r�r�r]r�rrr�r
r
r
rr�Ls

!r�cs@eZdZdZdddd�fdd�Zdd�Z�S)	�
SafeTransportz2Handles an HTTPS transaction to an XML-RPC server.F�contextNcs&t�jd|d|�||_dS)Nr�r�)�superrr)rr�r�r)rr
rr2szSafeTransport.__init__cCs�|jr'||jdkr'|jdSttjd�sEtd��|j|�\}|_}|tjj|dd|j|p�i�f|_|jdS)Nrr�HTTPSConnectionz1your version of http.client doesn't support HTTPSr)	r�r2r�r�r�r�r�rr)rr�r�r�r
r
rr�9s	!zSafeTransport.make_connection)rrrrrr�r
r
)rrr/s	rc
@s�eZdZdZdddddddddd�Zdd�Zd	d
�Zdd�ZeZd
d�Z	dd�Z
dd�Zdd�ZdS)�ServerProxya�uri [,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)

    All 8-bit strings passed to the server proxy are assumed to use
    the given encoding.
    NFrcCs�tjj|�\}	}|	d	kr0td��tjj|�\|_|_|js`d|_|dkr�|	dkr�t}
d|i}nt}
i}|
d|d||�}||_	|p�d|_
||_||_dS)
Nr��httpszunsupported XML-RPC protocolz/RPC2rr�r�zutf-8)r�r)
r�r�Z	splittyper�Z	splithost�_ServerProxy__host�_ServerProxy__handlerrr��_ServerProxy__transport�_ServerProxy__encoding�_ServerProxy__verbose�_ServerProxy__allow_none)rZuri�	transportrYr�r`r�r�rr3r�Zextra_kwargsr
r
rrns&					zServerProxy.__init__cCs|jj�dS)N)rr])rr
r
rZ__close�szServerProxy.__closecCswt||d|jd|j�j|jd�}|jj|j|j|d|j�}t	|�dkrs|d}|S)NrYr`�xmlcharrefreplacer�rr)
rirrrDrr�rrrr�)rr�r�r�r�r
r
rZ	__request�s	
zServerProxy.__requestcCsd|jj|j|jfS)Nz
<%s for %s%s>)rrrr)rr
r
rr �szServerProxy.__repr__cCst|j|�S)N)r��_ServerProxy__request)rr�r
r
rr��szServerProxy.__getattr__cCs=|dkr|jS|dkr&|jStd|f��dS)z|A workaround to get special attributes on the ServerProxy
           without interfering with the magic __getattr__
        r]rzAttribute %r not foundN)�_ServerProxy__closerr\)r�attrr
r
rr��s
zServerProxy.__call__cCs|S)Nr
)rr
r
r�	__enter__�szServerProxy.__enter__cGs|j�dS)N)r)rr�r
r
r�__exit__�szServerProxy.__exit__)
rrrrrrrr rr�r�rrr
r
r
rrXs	
r�__main__zhttp://localhost:8000ZERROR�	li���li�iD���i����i���ip���iԁ��iD���iC���iB���i����i����i����i����)TrrK�sysr-rZhttp.clientr�Zurllib.parser�Zxml.parsersrr�r�rr��ImportErrorr�versionr
rurvZPARSE_ERRORZSERVER_ERRORZAPPLICATION_ERRORZSYSTEM_ERRORZTRANSPORT_ERRORZNOT_WELLFORMED_ERRORZUNSUPPORTED_ENCODINGZINVALID_ENCODING_CHARZINVALID_XMLRPCZMETHOD_NOT_FOUNDZINVALID_METHOD_PARAMSZINTERNAL_ERRORr�rrr!r"r�r�ZBooleanZ_day0r%r'r.r/rErFrGrPr�rQr^r�r�r�r�r�r�r�r�rir�r�r�r��objectr�r�r�rrZServerrr�rZcurrentTimeZgetCurrentTimergZmultiZgetData�pow�addr�r
r
r
r�<module>�s�


K	#!��''	J%�)i