ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/xmlrpc/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/xmlrpc/__pycache__/client.cpython-34.pyo

�
e f���&@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�qAWWq�e"k
r�ZNzeKdUeN�WYddZN[NXq�XndS)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/python34/lib64/python3.4/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__cCsd|j|j|jfS)Nz<ProtocolError for %s: %s %s>)rrr)rr
r
r�__repr__�szProtocolError.__repr__N)rrrrrrr
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|j|jfS)Nz<Fault %s: %r>)r"r#)rr
r
rr�szFault.__repr__N)rrrrrrr
r
r
rr!�sr!z%YZ0001cCs
|jd�S)Nz%Y%m%dT%H:%M:%S)�strftime)�valuer
r
r�_iso8601_formatsr&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&scCspt|t�rt|�St|ttjf�s^|dkrLtj�}ntj|�}nd|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�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�	timetuple�	__class__zCan't compare %s and %s)r*r.r%rr&r/�hasattrr0r1r�type�	TypeError)r�otherr	�oZotyper
r
r�make_comparable-s$				zDateTime.make_comparablecCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__lt__BszDateTime.__lt__cCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__le__FszDateTime.__le__cCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__gt__JszDateTime.__gt__cCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__ge__NszDateTime.__ge__cCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__eq__RszDateTime.__eq__cCs|j|�\}}||kS)N)r7)rr5r	r6r
r
r�__ne__VszDateTime.__ne__cCstj|jd�S)Nz%Y%m%dT%H:%M:%S)r,�strptimer%)rr
r
rr0ZszDateTime.timetuplecCs|jS)N)r%)rr
r
rrbszDateTime.__str__cCsd|jt|�fS)Nz<DateTime %r at %x>)r%�id)rr
r
rreszDateTime.__repr__cCst|�j�|_dS)N)r/�stripr%)r�datar
r
r�decodehszDateTime.decodecCs.|jd�|j|j�|jd�dS)Nz<value><dateTime.iso8601>z</dateTime.iso8601></value>
)�writer%)r�outr
r
r�encodeks
zDateTime.encodeN)rrrrrr7r8r9r:r;r<r=r0rrrBrEr
r
r
rr.!sr.cCst�}|j|�|S)N)r.rB)rAr%r
r
r�	_datetimeps	
rFcCstj|d�S)Nz%Y%m%dT%H:%M:%S)rr>)rAr
r
r�_datetime_typevsrGc@saeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�BinaryzWrapper for binary data.NcCs\|dkrd}n:t|ttf�sCtd|jj��nt|�}||_dS)N�z#expected bytes or bytearray, not %s)r*�bytes�	bytearrayr4r1rrA)rrAr
r
rr�s	zBinary.__init__cCst|jd�S)Nzlatin-1)r/rA)rr
r
rr�szBinary.__str__cCs(t|t�r|j}n|j|kS)N)r*rHrA)rr5r
r
rr<�sz
Binary.__eq__cCs(t|t�r|j}n|j|kS)N)r*rHrA)rr5r
r
rr=�sz
Binary.__ne__cCstj|�|_dS)N)�base64�decodebytesrA)rrAr
r
rrB�sz
Binary.decodecCsF|jd�tj|j�}|j|jd��|jd�dS)Nz<value><base64>
�asciiz</base64></value>
)rCrL�encodebytesrArB)rrD�encodedr
r
rrE�s
z
Binary.encode)
rrrrrrr<r=rBrEr
r
r
rrHsrHcCst�}|j|�|S)N)rHrB)rAr%r
r
r�_binary�s	
rQc@s4eZdZdd�Zdd�Zdd�ZdS)�ExpatParsercCs`tjdd�|_}||_|j|_|j|_|j|_	d}|j
|d�dS)N)rZParserCreate�_parser�_target�startZStartElementHandler�endZEndElementHandlerrAZCharacterDataHandler�xml)r�target�parser�encodingr
r
rr�s	zExpatParser.__init__cCs|jj|d�dS)Nr)rS�Parse)rrAr
r
r�feed�szExpatParser.feedcCsBy
|j}Wntk
r!YnX|`|`|jdd�dS)NrIT)rS�AttributeErrorrTr[)rrYr
r
r�close�s

zExpatParser.closeN)rrrrr\r^r
r
r
rrR�s	rRc@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)�memorArZ�
allow_none)rrZrar
r
rr�s			zMarshaller.__init__cCs�g}|j}|j}t|t�r_|d�|i|jd6|jd6|�|d�nF|d�x/|D]'}|d�|||�|d�qpW|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�valuesrDrC�dump�v�resultr
r
r�dumps�s"		







zMarshaller.dumpscCs�y|jt|�}Wn�tk
r�t|d�sOtdt|���nxEt|�jD]4}||jj�kr_tdt|���q_q_W|jd}YnX||||�dS)N�__dict__zcannot marshal %s objects�_arbitrary_instance)�dispatchr3�KeyErrorr2r4�__mro__�keys)rr%rC�fZtype_r
r
rZ__dumps
zMarshaller.__dumpcCs&|jstd��n|d�dS)Nz0cannot marshal None unless allow_none is enabledz<value><nil/></value>)rar4)rr%rCr
r
r�dump_nils	zMarshaller.dump_nilcCs.|d�||rdpd�|d�dS)Nz<value><boolean>�1�0z</boolean></value>
r
)rr%rCr
r
r�	dump_bools
zMarshaller.dump_boolcCsU|tks|tkr'td��n|d�|tt|���|d�dS)Nzint exceeds XML-RPC limitsz<value><int>z</int></value>
)�MAXINT�MININT�
OverflowErrorr/�int)rr%rCr
r
r�	dump_long!s

zMarshaller.dump_longcCs(|d�|t|��|d�dS)Nz<value><double>z</double></value>
)r)rr%rCr
r
r�dump_double,s
zMarshaller.dump_doublecCs(|d�|||��|d�dS)Nz<value><string>z</string></value>
r
)rr%rCrr
r
r�dump_unicode2s
zMarshaller.dump_unicodecCs:|d�tj|�}||jd��|d�dS)Nz<value><base64>
rNz</base64></value>
)rLrOrB)rr%rCrPr
r
r�
dump_bytes8s
zMarshaller.dump_bytescCs�t|�}||jkr*td��nd|j|<|j}|d�x|D]}|||�qQW|d�|j|=dS)Nz"cannot marshal recursive sequencesz<value><array><data>
z</data></array></value>
)r?r`r4rd)rr%rC�irgrhr
r
r�
dump_array@s
	


zMarshaller.dump_arraycCs�t|�}||jkr*td��nd|j|<|j}|d�xm|j�D]_\}}|d�t|t�s�td��n|d||��|||�|d�qWW|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`r4rd�itemsr*r/)rr%rCrr~rg�krhr
r
r�dump_structNs
	



zMarshaller.dump_structcCs(|d�|t|��|d�dS)Nz<value><dateTime.iso8601>z</dateTime.iso8601></value>
)r-)rr%rCr
r
r�
dump_datetime`s
zMarshaller.dump_datetimecCsE|jtkr.||_|j|�|`n|j|j|�dS)N)r1�WRAPPERSrCrEr�rk)rr%rCr
r
r�
dump_instancefs
	
	zMarshaller.dump_instancerl)!rrrrrrmrjrdrrr3ru�boolrzryZdump_intr{�floatrr|r/r}rJrKrr+�listr��dictr�rr�r.rHr
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).
    FcCsad|_g|_g|_g|_d|_d|_|jj|_|pN||_||_dS)Nzutf-8)	�_type�_stack�_marks�_data�_methodname�	_encodingrc�
_use_datetime�
_use_bytes)r�use_datetime�use_builtin_typesr
r
rr�s						zUnmarshaller.__init__cCsV|jdks|jr$t��n|jdkrIt|jd��nt|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�)rrZZ
standaloner
r
rrW�szUnmarshaller.xmlcCsP|dks|dkr4|jjt|j��ng|_|dk|_dS)N�array�structr%)r�rc�lenr�r��_value)r�tagZattrsr
r
rrU�s	zUnmarshaller.startcCs|jj|�dS)N)r�rc)r�textr
r
rrA�szUnmarshaller.datacCsCy|j|}Wntk
r%YnX||dj|j��SdS)Nrb)rmrnrer�)rr�rqr
r
rrV�s

zUnmarshaller.endcCs7y|j|}Wntk
r%YnX|||�SdS)N)rmrn)rr�rArqr
r
r�end_dispatch�s

zUnmarshaller.end_dispatchcCs|jd�d|_dS)Nr)rcr�)rrAr
r
r�end_nil�s
zUnmarshaller.end_nilZnilcCsQ|dkr|jd�n(|dkr8|jd�ntd��d|_dS)NrtFrsTzbad boolean valuer)rcr4r�)rrAr
r
r�end_boolean�szUnmarshaller.end_boolean�booleancCs |jt|��d|_dS)Nr)rcryr�)rrAr
r
r�end_int�szUnmarshaller.end_intZi4Zi8rycCs |jt|��d|_dS)Nr)rcr�r�)rrAr
r
r�
end_double�szUnmarshaller.end_doubleZdoublecCs8|jr|j|j�}n|j|�d|_dS)Nr)r�rBrcr�)rrAr
r
r�
end_string�s	
zUnmarshaller.end_string�string�namecCs?|jj�}|j|d�g|j|d�<d|_dS)Nr)r��popr�r�)rrA�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�)rrAr�r�r�r~r
r
r�
end_struct�szUnmarshaller.end_structr�cCsNt�}|j|jd��|jr4|j}n|j|�d|_dS)NrNr)rHrBrEr�rArcr�)rrAr%r
r
r�
end_base64�s		
zUnmarshaller.end_base64rLcCs?t�}|j|�|jr.t|�}n|j|�dS)N)r.rBr�rGrc)rrAr%r
r
r�end_dateTimes
	
	zUnmarshaller.end_dateTimezdateTime.iso8601cCs|jr|j|�ndS)N)r�r�)rrAr
r
r�	end_value
s	zUnmarshaller.end_valuer%cCs
d|_dS)N�params)r�)rrAr
r
r�
end_paramsszUnmarshaller.end_paramsr�cCs
d|_dS)Nr�)r�)rrAr
r
r�	end_faultszUnmarshaller.end_faultr�cCs4|jr|j|j�}n||_d|_dS)N�
methodName)r�rBr�r�)rrAr
r
r�end_methodNames		zUnmarshaller.end_methodNamer�N)rrrrrr^r�rWrUrArVr�rmr�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr�zsN








	





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�rcr�)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
rr5szMultiCallIterator.__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__8s
zMultiCallIterator.__getitem__N)rrrrrr�r
r
r
rr�1s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
rrRs	zMultiCall.__init__cCsdt|�S)Nz<MultiCall at %x>)r?)rr
r
rrVszMultiCall.__repr__cCst|j|�S)N)r�r�)rr�r
r
rr�[szMultiCall.__getattr__cCsTg}x2|jD]'\}}|ji|d6|d6�qWt|jjj|��S)Nr�r�)r�rcr�r��systemZ	multicall)rZmarshalled_listr�r�r
r
rr�^szMultiCall.__call__N)	rrrrrrrr�r�r
r
r
rr�As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�FastUnmarshallerrGrLrMrQrFr!r�rR)r�r�Z
mkdatetimeZmkbytesrXrYr
r
r�	getparserps 	r�cCst|t�rd}n|r0t|t�r0n|s?d}ntrTt|�}nt||�}|j|�}|dkr�dt|�}nd}|r�t|t�s�|j|�}n|d|d|df}n|r�|d|d	f}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.
    rzutf-8z$<?xml version='1.0' encoding='%s'?>
z<?xml version='1.0'?>
z<methodCall>
<methodName>z</methodName>
z</methodCall>
z<methodResponse>
z</methodResponse>
rb)	r*r!r+�FastMarshallerr_rjr/rEre)r��
methodnameZmethodresponserZra�mrAZ	xmlheaderr
r
rrj�s8		rjcCsHtd|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�)rAr�r��p�ur
r
r�loads�s	

r�cCsgtst�nt�}tjddd|dd�}|j|�|j�|j�}|j�|S)zhdata -> gzip encoded data

    Encode data using the gzip content encoding as described in RFC 1952
    �mode�wb�fileobjZ
compresslevelr)�gzip�NotImplementedErrorr�GzipFilerCr^�getvalue)rArq�gzfrPr
r
r�gzip_encode�s		


r�i@cCs�tst�nt|�}tjddd|�}y2|dkrQ|j�}n|j|d�}Wntk
r�td��YnX|j�|j�|dkr�t|�|kr�td��n|S)zrgzip encoded data -> unencoded data

    Decode data using the gzip content encoding as described in RFC 1952
    r��rbr�rrzinvalid dataz#max gzipped payload length exceeded)	r�r�rr��read�OSErrorr�r^r�)rAZ
max_decoderqr�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.
    cCsGtst�nt|j��|_tjj|ddd|j�dS)Nr�r�r�)r�r�rr��ior�r)r�responser
r
rr6s	zGzipDecodedResponse.__init__c
Cs)ztjj|�Wd|jj�XdS)N)r�r�r^r�)rr
r
rr^>szGzipDecodedResponse.closeN)rrrrrr^r
r
r
rr�2sr�c@s4eZdZdd�Zdd�Zdd�ZdS)�_MethodcCs||_||_dS)N)�
_Method__send�
_Method__name)r�sendr�r
r
rrKs	z_Method.__init__cCst|jd|j|f�S)Nz%s.%s)r�r�r�)rr�r
r
rr�Nsz_Method.__getattr__cGs|j|j|�S)N)r�r�)rr�r
r
rr�Psz_Method.__call__N)rrrrr�r�r
r
r
rr�Hs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
rrgs			zTransport.__init__cCs�x�dD]�}y|j||||�SWqtk
r{}z2|sc|jtjtjtjfkri�nWYdd}~Xqtjjk
r�|r��nYqXqWdS)Nrr)rr)	�single_requestr��errnoZ
ECONNRESETZECONNABORTEDZEPIPE�http�clientZ
BadStatusLine)r�host�handler�request_body�verboser~�er
r
r�requestws
zTransport.requestcCs�yM|j||||�}|j�}|jdkrL||_|j|�SWn3tk
rd�Yntk
r�|j��YnX|jdd�r�|j	�nt
|||j|jt|j
����dS)N��zcontent-lengthrb)�send_requestZgetresponseZstatusr��parse_responser!�	Exceptionr^�	getheaderr�r�reasonr�Z
getheaders)rr�r�r�r�Z	http_connZrespr
r
rr��s"	



zTransport.single_requestcCstd|jd|j�S)Nr�r�)r�r�r�)rr
r
rr��szTransport.getparsercCs�i}t|t�r$|\}}ntjj|�\}}|r�tjj|�}tj|�jd�}dj	|j
��}dd|fg}ng}|||fS)Nzutf-8rbZ
AuthorizationzBasic )r*r+�urllib�parseZ	splituserZunquote_to_bytesrLrOrBre�split)rr��x509ZauthZ
extra_headersr
r
r�
get_host_info�szTransport.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�ndS)N)NN)r�r^)rr��
connectionr
r
rr^�s	zTransport.closecCs�|j|�}|jdd�}|r8|jd�n|jrmtrm|jd|dd�|jd
�n|jd|�|jd�|jd	|jf�|j||�|j	||�|S)NrZPOSTZskip_accept_encodingT�Accept-Encodingr��Content-Type�text/xmlz
User-Agent)r�zgzip)r�r�)
r�r�Zset_debuglevel�accept_gzip_encodingr�Z
putrequestrc�
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
rrszTransport.send_headerscCsv|jdk	rI|jt|�krItrI|jdd�t|�}n|jdtt|���|j|�dS)NzContent-Encodingr�zContent-Length)�encode_thresholdr�r�rr�r/Z
endheaders)rr�r�r
r
rr
szTransport.send_contentcCs�t|d�r?|jdd�dkr6t|�}qE|}n|}|j�\}}xI|jd�}|ssPn|jr�tdt|��n|j|�qZW||k	r�|j	�n|j	�|j	�S)Nr�zContent-Encodingrbr�izbody:)
r2r�r�r�r�r��printrr\r^)rr��streamr�r�rAr
r
rr�s"		

zTransport.parse_response)rrrr�__version__rr�rrr�r�r�r�r�r^r�rrr�r
r
r
rr�Ys

!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)r1r
rr?szSafeTransport.__init__cCs�|jr'||jdkr'|jdSttjd�sHtd��n|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�Fs!zSafeTransport.make_connection)rrrrrr�r
r
)r1rr<s	rc
@s|eZdZdZdddddddddd�Zdd�Zd	d
�Zdd�ZeZd
d�Z	dd�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	kr3td��ntjj|�\|_|_|jsfd|_n|dkr�|	dkr�t}
i|d6}nt}
i}|
d|d||�}n||_	|p�d|_
||_||_dS)
Nr��httpszunsupported XML-RPC protocolz/RPC2rr�r�zutf-8)zhttpr)
r�r�Z	splittyper�Z	splithost�_ServerProxy__host�_ServerProxy__handlerrr��_ServerProxy__transport�_ServerProxy__encoding�_ServerProxy__verbose�_ServerProxy__allow_none)rZuri�	transportrZr�rar�r�rr3r�Zextra_kwargsr
r
rr{s&			zServerProxy.__init__cCs|jj�dS)N)rr^)rr
r
rZ__close�szServerProxy.__closecCswt||d|jd|j�j|j�}|jj|j|j|d|j�}t	|�dkrs|d}n|S)NrZrar�rr)
rjrrrErr�rrrr�)rr�r�r�r�r
r
rZ	__request�s	
zServerProxy.__requestcCsd|j|jfS)Nz<ServerProxy for %s%s>)rr)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__)rrrrrrrrrr�r�r
r
r
rres	r�__main__zhttp://localhost:8000ZERROR�	li���li�iD���i����i���ip���iԁ��iD���iC���iB���i����i����i����i����)TrrL�sysr,rZhttp.clientr�Zurllib.parser�Zxml.parsersrr�r�rr��ImportErrorr�versionr
rvrwZPARSE_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.rFrGrHrQr�rRr_r�r�r�r�r�r�r�r�rjr�r�r�r��objectr�r�r�rrZServerrr�rZcurrentTimeZgetCurrentTimerhZmultiZgetData�pow�addr�r
r
r
r�<module>�s�


O	(!��''	L%�)c 


Zerion Mini Shell 1.0