Your IP : 3.133.124.80


Current Path : /opt/alt/python310/lib64/python3.10/xmlrpc/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/xmlrpc/__pycache__/client.cpython-310.pyc

o

6��f��
@sjdZddlZddlZddlZddlmZddlmZddlZddl	Z
ddlmZddl
Z
ddlmZzddlZWneyCdZYnwdd�Zd	ejdd
�ZdZdZd
ZdZdZdZdZd
ZdZdZdZdZ dZ!dZ"Gdd�de#�Z$Gdd�de$�Z%Gdd�de$�Z&Gdd�de$�Z'e(Z)Z*eddd�Z+d d!�Z,e,d"�r�d#d$�Z-n
e,d%�r�d&d$�Z-nd'd$�Z-[+[,d(d)�Z.Gd*d+�d+�Z/d,d-�Z0d.d/�Z1Gd0d1�d1�Z2d2d3�Z3e/e2fZ4Gd4d5�d5�Z5Gd6d7�d7�Z6Gd8d9�d9�Z7Gd:d;�d;�Z8Gd<d=�d=�Z9Gd>d?�d?�Z:dZ;Z<Z=dZdAdB�Z>		@d[dCdD�Z?dZdEdF�Z@dGdH�ZAd\dJdK�ZBGdLdM�dMe�r*ejCneD�ZEGdNdO�dO�ZFGdPdQ�dQ�ZGGdRdS�dSeG�ZHGdTdU�dU�ZIeIZJeKdVk�r�eIdW�ZLz	eMeLjN�O��Wne$�yvZPzeMdXeP�WYdZP[PndZP[Pwwe:eL�ZQeQ�R�eQ�Sd
dY�eQ�Tdd
�zeQ�D]ZUeMeU��q�WdSe$�y�ZPzeMdXeP�WYdZP[PdSdZP[PwwdS)]a�
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)�Decimal)�expat)�BytesIOcCs$|�dd�}|�dd�}|�dd�S)N�&z&amp;�<z&lt;�>z&gt;)�replace)�s�r�4/opt/alt/python310/lib64/python3.10/xmlrpc/client.py�escape�sr
z%d.%d�i���i�iD���i����i���ip���iԁ��iC���iB���i����i����i����c@seZdZdZejZdS)�ErrorzBase class for client errors.N)�__name__�
__module__�__qualname__�__doc__�object�__str__rrrrr�s
rc@� eZdZdZdd�Zdd�ZdS)�
ProtocolErrorz!Indicates an HTTP protocol error.cCs&t�|�||_||_||_||_dS�N)r�__init__�url�errcode�errmsg�headers)�selfrrrrrrrr�s


zProtocolError.__init__cCsd|jj|j|j|jfS)Nz<%s for %s: %s %s>)�	__class__rrrr�rrrr�__repr__�s��zProtocolError.__repr__N�rrrrrr!rrrrr�src@seZdZdZdS)�
ResponseErrorz$Indicates a broken response package.N)rrrrrrrrr#�sr#c@r)�Faultz#Indicates an XML-RPC fault package.cKst�|�||_||_dSr)rr�	faultCode�faultString)rr%r&Zextrarrrr��

zFault.__init__cC�d|jj|j|jfS)Nz<%s %s: %r>)rrr%r&r rrrr!�s�zFault.__repr__Nr"rrrrr$�sr$�cCs&zt�|�dkWStyYdSw)NZ0001F)�_day0�strftime�
ValueError)Zfmtrrr�_trys
�r-z%YcC�
|�d�S�N�%Y%m%dT%H:%M:%S�r+��valuerrr�_iso8601_format�
r4z%4YcCr.)Nz%4Y%m%dT%H:%M:%Sr1r2rrrr4r5cCs|�d��d�S)Nr0�)r+�zfillr2rrrr4�cCsLt|t�r	t|�St|ttjf�s|dkrt��}t�|�}d|dd�S)Nrz%04d%02d%02dT%02d:%02d:%02d�)�
isinstancerr4�tuple�time�struct_time�	localtimer2rrr�	_strftimes

r?c@sreZdZdZddd�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
||_dSt|�|_dSr)r:�strr3r?)rr3rrrr.s

zDateTime.__init__cCs�t|t�r|j}|j}||fSt|t�r|j}t|�}||fSt|t�r-|j}|}||fSt|d�r>|��}|��}||fS|}t}||fS)N�	timetuple)	r:r@r3rr4rA�hasattrrB�NotImplemented�r�otherr
�orrr�make_comparable4s&

�

�
��zDateTime.make_comparablecCs"|�|�\}}|tur
tS||kSr�rHrDrErrr�__lt__F�zDateTime.__lt__cCs"|�|�\}}|tur
tS||kSrrIrErrr�__le__LrKzDateTime.__le__cCs"|�|�\}}|tur
tS||kSrrIrErrr�__gt__RrKzDateTime.__gt__cCs"|�|�\}}|tur
tS||kSrrIrErrr�__ge__XrKzDateTime.__ge__cCs"|�|�\}}|tur
tS||kSrrIrErrr�__eq__^rKzDateTime.__eq__cCst�|jd�Sr/)r<�strptimer3r rrrrBd�zDateTime.timetuplecC�|jSrr2r rrrrl�zDateTime.__str__cCsd|jj|jt|�fS)Nz<%s %r at %#x>)rrr3�idr rrrr!oszDateTime.__repr__cCst|���|_dSr)rA�stripr3�r�datarrr�decoder�zDateTime.decodecCs$|�d�|�|j�|�d�dS�Nz<value><dateTime.iso8601>z</dateTime.iso8601></value>
)�writer3)r�outrrr�encodeus
zDateTime.encodeN)r)rrrrrrHrJrLrMrNrOrBrr!rXr]rrrrr@(s
r@cC�t�}|�|�|Sr)r@rX�rWr3rrr�	_datetimez�
r`cCst�|d�Sr/)rrP)rWrrr�_datetime_type��rbc@s:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�BinaryzWrapper for binary data.NcCs>|durd}nt|ttf�std|jj��t|�}||_dS)N�z#expected bytes or bytearray, not %s)r:�bytes�	bytearray�	TypeErrorrrrWrVrrrr�s�
zBinary.__init__cCst|jd�S)Nzlatin-1)rArWr rrrr�rczBinary.__str__cCst|t�r|j}|j|kSr)r:rdrW)rrFrrrrO�r'z
Binary.__eq__cCst�|�|_dSr)�base64�decodebytesrWrVrrrrX�r8z
Binary.decodecCs4|�d�t�|j�}|�|�d��|�d�dS�Nz<value><base64>
�asciiz</base64></value>
)r[ri�encodebytesrWrX)rr\�encodedrrrr]�s
z
Binary.encoder)	rrrrrrrOrXr]rrrrrd�s
rdcCr^r)rdrXr_rrr�_binary�raroc@�$eZdZdd�Zdd�Zdd�ZdS)�ExpatParsercCsDt�dd�|_}||_|j|_|j|_|j|_	d}|�
|d�dSr)rZParserCreate�_parser�_target�startZStartElementHandler�endZEndElementHandlerrWZCharacterDataHandler�xml)r�target�parser�encodingrrrr�szExpatParser.__init__cCs|j�|d�dS�NF)rr�ParserVrrr�feed�rYzExpatParser.feedcCs8z|j}Wn
tyYdSw|`|`|�dd�dS)NreT)rr�AttributeErrorrsr{)rrxrrr�close�s
�zExpatParser.closeN)rrrrr|r~rrrrrq�s	rqc@s�eZdZdZddd�ZiZdd�Zdd	�Zd
d�Zeee	d�<dd
�Z
e
ee<dd�Zeee
<eZdd�Zeee<efdd�Zeee<dd�Zeee<eee<dd�Zeee<eee<efdd�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.
    NFcCsi|_d|_||_||_dSr)�memorWry�
allow_none)rryr�rrrr�s
zMarshaller.__init__cCs�g}|j}|j}t|t�r |d�||j|jd�|�|d�n|d�|D]}|d�|||�|d�q&|d�d�|�}|S)	Nz<fault>
)r%r&z	</fault>
z	<params>
z<param>
z	</param>
z
</params>
�)�append�_Marshaller__dumpr:r$r%r&�join)r�valuesr\r[�dump�v�resultrrr�dumps�s&
��



zMarshaller.dumpscCs�z	|jt|�}Wn2ty;t|d�stdt|���t|�jD]}||j��vr3tdt|���q"|jd}Ynw||||�dS)N�__dict__zcannot marshal %s objects�_arbitrary_instance)�dispatch�type�KeyErrorrCrh�__mro__�keys)rr3r[�fZtype_rrrZ__dumps
��
zMarshaller.__dumpcCs|jstd��|d�dS)Nz0cannot marshal None unless allow_none is enabledz<value><nil/></value>)r�rh�rr3r[rrr�dump_nilszMarshaller.dump_nilcCs$|d�||r	dp
d�|d�dS)Nz<value><boolean>�1�0z</boolean></value>
rr�rrr�	dump_bool szMarshaller.dump_boolcCs<|tks|tkrtd��|d�|tt|���|d�dS)Nzint exceeds XML-RPC limitsz<value><int>z</int></value>
)�MAXINT�MININT�
OverflowErrorrA�intr�rrr�	dump_long&s
zMarshaller.dump_longcC� |d�|t|��|d�dS)Nz<value><double>z</double></value>
)�reprr�rrr�dump_double1�zMarshaller.dump_doublecCs |d�|||��|d�dS)Nz<value><string>z</string></value>
r)rr3r[r
rrr�dump_unicode7r�zMarshaller.dump_unicodecCs,|d�t�|�}||�d��|d�dSrk)rirmrX)rr3r[rnrrr�
dump_bytes=s
zMarshaller.dump_bytescCsZt|�}||jvr
td��d|j|<|j}|d�|D]}|||�q|d�|j|=dS)Nz"cannot marshal recursive sequencesz<value><array><data>
z</data></array></value>
)rTr�rhr�)rr3r[�ir�r�rrr�
dump_arrayEs

zMarshaller.dump_arraycCs�t|�}||jvr
td��d|j|<|j}|d�|��D]"\}}|d�t|t�s.td��|d||��|||�|d�q|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>
)rTr�rhr��itemsr:rA)rr3r[r
r�r��kr�rrr�dump_structSs




zMarshaller.dump_structcCr�rZ)r?r�rrr�
dump_datetimeer�zMarshaller.dump_datetimecCs4|jtvr||_|�|�|`dS|�|j|�dSr)r�WRAPPERSr[r]r�r�r�rrr�
dump_instanceks


zMarshaller.dump_instancer�rz)!rrrrrr�r�r�r�r�r��boolr�r�Zdump_intr��floatr
r�rAr�rfrgr�r;�listr��dictr�rr�r@rdrrrrr�s>
	rc@sneZdZdZdEdd�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<eed<eed<eed <d!d"�Zeed#<eed$<d%d&�Zeed'<d(d)�Zeed*<eed+<d,d-�Zeed.<d/d0�Zeed1<d2d3�Zeed4<d5d6�Zeed7<d8d9�Zeed:<d;d<�Zeed=<d>d?�Zeed@<dAdB�ZeedC<dDS)F�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).
    FcCsHd|_g|_g|_g|_d|_d|_d|_|jj|_|p||_||_	dS)NF�utf-8)
�_type�_stack�_marks�_data�_value�_methodname�	_encodingr��
_use_datetime�
_use_bytes)r�use_datetime�use_builtin_typesrrrr�s


zUnmarshaller.__init__cCs>|jdus|jrt��|jdkrtdi|jd���t|j�S)N�faultrr)r�r�r#r$r�r;r rrrr~�s


zUnmarshaller.closecCrRr)r�r rrr�
getmethodname�rSzUnmarshaller.getmethodnamecC�
||_dSr)r�)rryZ
standalonerrrrv�r5zUnmarshaller.xmlcCshd|vr|�d�d}|dks|dkr|j�t|j��g|_|jr-||jvr-td|��|dk|_dS)N�:����array�structzunknown tag %rr3)	�splitr�r��lenr�r�r�r�r#)r�tagZattrsrrrrt�szUnmarshaller.startcCs|j�|�dSr)r�r�)r�textrrrrW�r8zUnmarshaller.datacCsrz|j|}Wn(ty/d|vrYdSz|j|�d�d}Wnty,YYdSwYnw||d�|j��S)Nr�r�r�)r�r�r�r�r�)rr�r�rrrru�s���zUnmarshaller.endcCsjz|j|}Wn(ty/d|vrYdSz|j|�d�d}Wnty,YYdSwYnw|||�S)Nr�r�)r�r�r�)rr�rWr�rrr�end_dispatch�s���
zUnmarshaller.end_dispatchcCs|�d�d|_dS�Nr)r�r�rVrrr�end_nil�s

zUnmarshaller.end_nilZnilcCs:|dkr
|�d�n|dkr|�d�ntd��d|_dS)Nr�Fr�Tzbad boolean valuer)r�rhr�rVrrr�end_boolean�s
zUnmarshaller.end_boolean�booleancC�|�t|��d|_dSr�)r�r�r�rVrrr�end_int��
zUnmarshaller.end_intZi1Zi2Zi4Zi8r�Z
bigintegercCr�r�)r�r�r�rVrrr�
end_double�r�zUnmarshaller.end_doubleZdoubler�cCr�r�)r�rr�rVrrr�end_bigdecimal�r�zUnmarshaller.end_bigdecimalZ
bigdecimalcCs&|jr	|�|j�}|�|�d|_dSr�)r�rXr�r�rVrrr�
end_string�s

zUnmarshaller.end_string�string�namecCs.|j��}|j|d�g|j|d�<d|_dSr�)r��popr�r�)rrW�markrrr�	end_arrays

zUnmarshaller.end_arrayr�cCs`|j��}i}|j|d�}tdt|�d�D]}||d|||<q|g|j|d�<d|_dS)Nrrr))r�r�r��ranger�r�)rrWr�r�r�r�rrr�
end_structs

zUnmarshaller.end_structr�cCs6t�}|�|�d��|jr|j}|�|�d|_dS)Nrlr)rdrXr]r�rWr�r��rrWr3rrr�
end_base64s

zUnmarshaller.end_base64ricCs,t�}|�|�|jrt|�}|�|�dSr)r@rXr�rbr�r�rrr�end_dateTime s

zUnmarshaller.end_dateTimezdateTime.iso8601cCs|jr
|�|�dSdSr)r�r�rVrrr�	end_value(s�zUnmarshaller.end_valuer3cC�
d|_dS)N�params�r�rVrrr�
end_params/r5zUnmarshaller.end_paramsr�cCr�)Nr�r�rVrrr�	end_fault3r5zUnmarshaller.end_faultr�cCs"|jr	|�|j�}||_d|_dS)N�
methodName)r�rXr�r�rVrrr�end_methodName7s
zUnmarshaller.end_methodNamer�N�FF)rrrrrr~r�rvrtrWrur�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�s\
	r�c@rp)�_MultiCallMethodcC�||_||_dSr)�_MultiCallMethod__call_list�_MultiCallMethod__name)rZ	call_listr�rrrrD�
z_MultiCallMethod.__init__cC�t|jd|j|f�S�Nz%s.%s)r�r�r��rr�rrr�__getattr__G�z_MultiCallMethod.__getattr__cGs|j�|j|f�dSr)r�r�r��r�argsrrr�__call__Ir�z_MultiCallMethod.__call__N�rrrrr�r�rrrrr�A�r�c@r)�MultiCallIteratorzaIterates over the results of a multicall. Exceptions are
    raised in response to xmlrpc faults.cCr�r)�results)rr�rrrrPr5zMultiCallIterator.__init__cCsL|j|}t|�ti�krt|d|d��t|�tg�kr"|dStd��)Nr%r&rz#unexpected type in multicall result)r�r�r$r,)rr��itemrrr�__getitem__Ss
zMultiCallIterator.__getitem__N)rrrrrr�rrrrr�Lsr�c@s0eZdZdZdd�Zdd�Zdd�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|_dSr)�_MultiCall__server�_MultiCall__call_list)r�serverrrrrmr�zMultiCall.__init__cCsd|jjt|�fS)Nz<%s at %#x>)rrrTr rrrr!qszMultiCall.__repr__cC�t|j|�Sr)r�r�r�rrrr�trczMultiCall.__getattr__cCs6g}|jD]\}}|�||d��qt|jj�|��S)N)r�r�)r�r�r�r��systemZ	multicall)rZmarshalled_listr�r�rrrr�wszMultiCall.__call__N)rrrrrr!r�r�rrrrr�\sr�FcCs~tr'tr'|rt}tj}n|rt}t}nt}t}tdd||t�}t|�}||fSt||d�}tr7t|�}||fSt	|�}||fS)z�getparser() -> parser, unmarshaller

    Create an instance of the fastest available parser, and attach it
    to an unmarshalling object.  Return both objects.
    TF�r�r�)
�
FastParser�FastUnmarshallerrbrirjror`r$r�rq)r�r�Z
mkdatetimeZmkbytesrwrxrrr�	getparser�s$��rcCs�t|ttf�sJd��t|t�rd}n|r$t|t�r$t|�dks$Jd��|s(d}tr/t|�}nt||�}|�|�}|dkrDdt|�}nd}|rQ|d|d|d	f}n|rZ|d
|df}n|Sd�|�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 instancer)z"response tuple must be a singletonr�z$<?xml version='1.0' encoding='%s'?>
z<?xml version='1.0'?>
z<methodCall>
<methodName>z</methodName>
z</methodCall>
z<methodResponse>
z</methodResponse>
r�)	r:r;r$r��FastMarshallerrr�rAr�)r��
methodnameZmethodresponseryr��mrWZ	xmlheaderrrrr��s:



��
r�cCs2t||d�\}}|�|�|��|��|��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�)rr|r~r�)rWr�r��p�urrr�loads�s	
rcCsVtst�t�}tjd|dd��}|�|�Wd�|��S1s"wY|��S)zhdata -> gzip encoded data

    Encode data using the gzip content encoding as described in RFC 1952
    �wbr))�mode�fileobjZ
compresslevelN)�gzip�NotImplementedErrorr�GzipFiler[�getvalue)rWr��gzfrrr�gzip_encodes
��r�@c	Cs�tst�tjdt|�d��&}z|dkr|��}n|�|d�}Wnty+td��wWd�n1s6wY|dkrIt|�|krItd��|S)zrgzip encoded data -> unencoded data

    Decode data using the gzip content encoding as described in RFC 1952
    �rb�r	r
rr)zinvalid dataNz#max gzipped payload length exceeded)rrr
r�read�OSErrorr,r�)rWZ
max_decoderZdecodedrrr�gzip_decode)s 
����rc@r)�GzipDecodedResponsezha file-like object to decode a response encoded with the gzip
    method, as described in RFC 1952.
    cCs.tst�t|���|_tjj|d|jd�dS)Nrr)rrrr�ior
r)r�responserrrrGszGzipDecodedResponse.__init__cCs*ztj�|�W|j��dS|j��wr)rr
r~rr rrrr~OszGzipDecodedResponse.closeN)rrrrrr~rrrrrCsrc@rp)�_MethodcCr�r��
_Method__send�
_Method__name)r�sendr�rrrr\r�z_Method.__init__cCr�r�)rrrr�rrrr�_r�z_Method.__getattr__cGs|�|j|�Srrr�rrrr�arQz_Method.__call__Nr�rrrrrYr�rc@s�eZdZdZdeZdZdZddd�dd	�Zdd
d�Z	ddd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS) �	Transportz1Handles an HTTP transaction to an XML-RPC server.zPython-xmlrpc/%sTNFr)rcCs&||_||_d|_t|�|_g|_dS�N)NN)r��_use_builtin_types�_connectionr��_headers�_extra_headers)rr�r�rrrrrxs


zTransport.__init__cCs~dD]:}z|�||||�WStjjy|r�Yqty<}z|s1|jtjtjtjfvr2�WYd}~qd}~wwdS)N)rr))	�single_request�http�clientZRemoteDisconnectedr�errnoZ
ECONNRESETZECONNABORTEDZEPIPE)r�host�handler�request_body�verboser��errr�request�s ������zTransport.requestcCs�z|�||||�}|��}|jdkr||_|�|�WSWnty$�ty/|���w|�dd�r:|�	�t
|||j|jt|�
����)N��zcontent-lengthr�)�send_requestZgetresponseZstatusr,�parse_responser$�	Exceptionr~�	getheaderrr�reasonr�Z
getheaders)rr)r*r+r,Z	http_connZresprrrr%�s(
��
�zTransport.single_requestcCst|j|jd�S)Nr�)rr�r!r rrrr�s�zTransport.getparsercCsri}t|t�r|\}}tj�|�\}}|r2tj�|�}t�|��d�}d�	|�
��}dd|fg}ng}|||fS)Nr�r�Z
AuthorizationzBasic )r:r;�urllib�parseZ
_splituserZunquote_to_bytesrirmrXr�r�)rr)�x509ZauthZ
extra_headersrrr�
get_host_info�s

�
zTransport.get_host_infocCsL|jr||jdkr|jdS|�|�\}|_}|tj�|�f|_|jdS)Nrr))r"r8r$r&r'ZHTTPConnection�rr)Zchostr7rrr�make_connection�s


zTransport.make_connectioncCs$|j\}}|rd|_|��dSdSr )r"r~)rr)�
connectionrrrr~�s

�zTransport.closecCs�|�|�}|j|j}|r|�d�|jr%tr%|jd|dd�|�d�n|�d|�|�d�|�d|jf�|�	||�|�
||�|S)Nr)ZPOSTT)Zskip_accept_encoding)zAccept-Encodingr)zContent-Typeztext/xmlz
User-Agent)r:r#r$Zset_debuglevel�accept_gzip_encodingrZ
putrequestr��
user_agent�send_headers�send_content)rr)r*r+�debugr;rrrrr0�s



zTransport.send_requestcCs|D]
\}}|�||�qdSr)�	putheader)rr;r�key�valrrrr>s�zTransport.send_headerscCsR|jdur|jt|�krtr|�dd�t|�}|�dtt|���|�|�dS)N�Content-EncodingrzContent-Length)�encode_thresholdr�rrArrAZ
endheaders)rr;r+rrrr? s
�zTransport.send_contentcCs�t|d�r|�dd�dkrt|�}n|}n|}|��\}}	|�d�}|s&n|jr0tdt|��|�|�q||ur>|�	�|�	�|�	�S)Nr3rDr�rr)izbody:)
rCr3rrrr,�printr�r|r~)rr�streamrrrWrrrr11s$



�zTransport.parse_responser�)F)rrrr�__version__r=r<rErr.r%rr8r:r~r0r>r?r1rrrrrjs$�


!rcs2eZdZdZd
ddd��fdd�Zdd	�Z�ZS)�
SafeTransportz2Handles an HTTPS transaction to an XML-RPC server.FrN�r�contextcst�j|||d�||_dS)N�r�r�r)�superrrK)rr�r�rrK�rrrrRs
�
zSafeTransport.__init__cCst|jr||jdkr|jdSttjd�std��|�|�\}|_}|tjj|dfd|ji|p0i��f|_|jdS)Nrr)�HTTPSConnectionz1your version of http.client doesn't support HTTPSrK)	r"rCr&r'rr8r$rOrKr9rrrr:[s
�
��
�
zSafeTransport.make_connectionr�)rrrrrr:�
__classcell__rrrNrrIOs�	rIc@s^eZdZdZ		dddd�dd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�ZdS)�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.
    NFrrJc
Cs�tj�|�}
|
jdvrtd��|
j|_tj�ddg|
dd���|_|js(d|_|durG|
jdkr8t	}d|	i}nt
}i}|d
|||d�|��}||_|pMd	|_||_
||_dS)N)r&�httpszunsupported XML-RPC protocolr�rz/RPC2rRrKrLr�r)r5r6ZurlsplitZschemerZnetloc�_ServerProxy__hostZ
urlunsplit�_ServerProxy__handlerrIr�_ServerProxy__transport�_ServerProxy__encoding�_ServerProxy__verbose�_ServerProxy__allow_none)
rZuri�	transportryr,r�r�r�rrKrr*Zextra_kwargsrrrr�s.


��

zServerProxy.__init__cCs|j��dSr)rUr~r rrrZ__close�rQzServerProxy.__closecCsPt|||j|jd��|jd�}|jj|j|j||jd�}t	|�dkr&|d}|S)N)ryr��xmlcharrefreplace)r,r)r)
r�rVrXr]rUr.rSrTrWr�)rrr�r.rrrrZ	__request�s
�
��zServerProxy.__requestcCr()Nz
<%s for %s%s>)rrrSrTr rrrr!�s��zServerProxy.__repr__cCr�r)r�_ServerProxy__requestr�rrrr��szServerProxy.__getattr__cCs*|dkr|jS|dkr|jStd|f��)z|A workaround to get special attributes on the ServerProxy
           without interfering with the magic __getattr__
        r~rYzAttribute %r not found)�_ServerProxy__closerUr})r�attrrrrr��s
zServerProxy.__call__cCs|Srrr rrr�	__enter__�szServerProxy.__enter__cGs|��dSr)r\r�rrr�__exit__�rczServerProxy.__exit__)NNFFFF)rrrrrr\r[r!r�r�r^r_rrrrrQzs��
rQ�__main__zhttp://localhost:8000ZERROR�	r�)NNNF)r)Vrri�sysr<rZdecimalrZhttp.clientr&Zurllib.parser5Zxml.parsersrr(rrr�ImportErrorr
�version_inforHr�r�ZPARSE_ERRORZSERVER_ERRORZAPPLICATION_ERRORZSYSTEM_ERRORZTRANSPORT_ERRORZNOT_WELLFORMED_ERRORZUNSUPPORTED_ENCODINGZINVALID_ENCODING_CHARZINVALID_XMLRPCZMETHOD_NOT_FOUNDZINVALID_METHOD_PARAMSZINTERNAL_ERRORr2rrr#r$r�r�ZBooleanr*r-r4r?r@r`rbrdror�rqrr�r�r�r�rr�rrr�rrrr
rrrrrIrQZServerrr�rFZcurrentTimeZgetCurrentTimer�ZmultiZgetData�pow�addrrrrr�<module>s�X*�


R	#!(C%
'
�
K
f+i
��
����

?>