%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python3.6/xmlrpc/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib64/python3.6/xmlrpc/__pycache__/client.cpython-36.pyc

3


 \\��&@sjdZddlZddlZddlZddlmZddlmZddlZddl	Z
ddlmZddl
Z
ddlmZyddlZWnek
r�dZYnXdd�Zd	ejdd
�ZdYZd[Zd\Zd]Zd^Zd_Zd`ZdaZdbZdcZddZdeZ dfZ!dgZ"Gdd�de#�Z$Gdd�de$�Z%Gdd�de$�Z&Gdd�de$�Z'e(Z)Z*eddd�Z+e+j,d�d k�rJd!d"�Z-n"e+j,d#�d k�rdd$d"�Z-nd%d"�Z-[+d&d'�Z.Gd(d)�d)�Z/d*d+�Z0d,d-�Z1Gd.d/�d/�Z2d0d1�Z3e/e2fZ4Gd2d3�d3�Z5Gd4d5�d5�Z6Gd6d7�d7�Z7Gd8d9�d9�Z8Gd:d;�d;�Z9Gd<d=�d=�Z:dZ;Z<Z=dhd?d@�Z>didAdB�Z?djdCdD�Z@dEdF�ZAdkdHdI�ZBGdJdK�dKe�rXejCneD�ZEGdLdM�dM�ZFGdNdO�dO�ZGGdPdQ�dQeG�ZHGdRdS�dS�ZIeIZJeKdTk�rfeIdU�ZLyeMeLjNjO��Wn.e$k
�r�ZPzeMdVeP�WYddZP[PXnXe:eL�ZQeQjR�eQjSd
dW�eQjTdd
�yxeQ�D]ZUeMeU��q"WWn.e$k
�rdZPzeMdVeP�WYddZP[PXnXdS)la�
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$|jdd�}|jdd�}|jdd�S)N�&z&amp;�<z&lt;�>z&gt;)�replace)�s�r�%/usr/lib64/python3.6/xmlrpc/client.py�escape�sr
z%d.%d���i�iXi�~i�~i,~i�i�iYiZi[c@seZdZdZdd�ZdS)�ErrorzBase class for client errors.cCst|�S)N)�repr)�selfrrr�__str__�sz
Error.__str__N)�__name__�
__module__�__qualname__�__doc__rrrrrr�src@s eZdZdZdd�Zdd�ZdS)�
ProtocolErrorz!Indicates an HTTP protocol error.cCs&tj|�||_||_||_||_dS)N)r�__init__�url�errcode�errmsg�headers)rrrrrrrrr�s

zProtocolError.__init__cCsd|jj|j|j|jfS)Nz<%s for %s: %s %s>)�	__class__rrrr)rrrr�__repr__�szProtocolError.__repr__N)rrrrrr rrrrr�src@seZdZdZdS)�
ResponseErrorz$Indicates a broken response package.N)rrrrrrrrr!�sr!c@s eZdZdZdd�Zdd�ZdS)�Faultz#Indicates an XML-RPC fault package.cKstj|�||_||_dS)N)rr�	faultCode�faultString)rr#r$Zextrarrrr�s
zFault.__init__cCsd|jj|j|jfS)Nz<%s %s: %r>)rrr#r$)rrrrr �szFault.__repr__N)rrrrrr rrrrr"�sr"z%YZ0001cCs
|jd�S)Nz%Y%m%dT%H:%M:%S)�strftime)�valuerrr�_iso8601_format
sr'z%4YcCs
|jd�S)Nz%4Y%m%dT%H:%M:%S)r%)r&rrrr'scCs|jd�jd�S)Nz%Y%m%dT%H:%M:%S�)r%�zfill)r&rrrr'scCsLt|t�rt|�St|ttjf�s<|dkr2tj�}tj|�}d|dd�S)Nrz%04d%02d%02dT%02d:%02d:%02d�)�
isinstancerr'�tuple�timeZstruct_timeZ	localtime)r&rrr�	_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||_n
t|�|_dS)N)r+�strr&r.)rr&rrrr)s
zDateTime.__init__cCs�t|t�r|j}|j}nzt|t�r2|j}t|�}n`t|t�rH|j}|}nJt|d�rd|j�}|j�}n.t|d�rv|jj	p|t
|�}td|jj	|f��||fS)N�	timetuplerzCan't compare %s and %s)r+r/r&rr'r0�hasattrr1rr�type�	TypeError)r�otherr
�oZotyperrr�make_comparable/s$






zDateTime.make_comparablecCs|j|�\}}||kS)N)r7)rr5r
r6rrr�__lt__DszDateTime.__lt__cCs|j|�\}}||kS)N)r7)rr5r
r6rrr�__le__HszDateTime.__le__cCs|j|�\}}||kS)N)r7)rr5r
r6rrr�__gt__LszDateTime.__gt__cCs|j|�\}}||kS)N)r7)rr5r
r6rrr�__ge__PszDateTime.__ge__cCs|j|�\}}||kS)N)r7)rr5r
r6rrr�__eq__TszDateTime.__eq__cCstj|jd�S)Nz%Y%m%dT%H:%M:%S)r-�strptimer&)rrrrr1XszDateTime.timetuplecCs|jS)N)r&)rrrrr`szDateTime.__str__cCsd|jj|jt|�fS)Nz<%s %r at %#x>)rrr&�id)rrrrr cszDateTime.__repr__cCst|�j�|_dS)N)r0�stripr&)r�datarrr�decodefszDateTime.decodecCs$|jd�|j|j�|jd�dS)Nz<value><dateTime.iso8601>z</dateTime.iso8601></value>
)�writer&)r�outrrr�encodeis
zDateTime.encodeN)r)rrrrrr7r8r9r:r;r<r1rr rArDrrrrr/#s
r/cCst�}|j|�|S)N)r/rA)r@r&rrr�	_datetimens
rEcCstj|d�S)Nz%Y%m%dT%H:%M:%S)rr=)r@rrr�_datetime_typetsrFc@s:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�BinaryzWrapper for binary data.NcCs>|dkrd}n&t|ttf�s,td|jj��t|�}||_dS)N�z#expected bytes or bytearray, not %s)r+�bytes�	bytearrayr4rrr@)rr@rrrr�szBinary.__init__cCst|jd�S)Nzlatin-1)r0r@)rrrrr�szBinary.__str__cCst|t�r|j}|j|kS)N)r+rGr@)rr5rrrr<�s
z
Binary.__eq__cCstj|�|_dS)N)�base64�decodebytesr@)rr@rrrrA�sz
Binary.decodecCs4|jd�tj|j�}|j|jd��|jd�dS)Nz<value><base64>
�asciiz</base64></value>
)rBrK�encodebytesr@rA)rrC�encodedrrrrD�s
z
Binary.encode)N)	rrrrrrr<rArDrrrrrG}s
rGcCst�}|j|�|S)N)rGrA)r@r&rrr�_binary�s
rPc@s$eZdZdd�Zdd�Zdd�ZdS)�ExpatParsercCsDtjdd�|_}||_|j|_|j|_|j|_	d}|j
|d�dS)N)rZParserCreate�_parser�_target�startZStartElementHandler�endZEndElementHandlerr@ZCharacterDataHandler�xml)r�target�parser�encodingrrrr�szExpatParser.__init__cCs|jj|d�dS)Nr)rR�Parse)rr@rrr�feed�szExpatParser.feedcCs8y
|j}Wntk
rYnX|`|`|jdd�dS)NrHT)rR�AttributeErrorrSrZ)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|_||_||_dS)N)�memor@rY�
allow_none)rrYr`rrrr�szMarshaller.__init__cCs�g}|j}|j}t|t�r@|d�||j|jd�|�|d�n8|d�x&|D]}|d�|||�|d�qNW|d�dj|�}|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�resultrrr�dumps�s"




zMarshaller.dumpscCs�y|jt|�}Wnjtk
r|t|d�s<tdt|���x0t|�jD]"}||jj�krHtdt|���qHW|jd}YnX||||�dS)N�__dict__zcannot marshal %s objects�_arbitrary_instance)�dispatchr3�KeyErrorr2r4�__mro__�keys)rr&rB�fZtype_rrrZ__dump�s
zMarshaller.__dumpcCs|jstd��|d�dS)Nz0cannot marshal None unless allow_none is enabledz<value><nil/></value>)r`r4)rr&rBrrr�dump_nilszMarshaller.dump_nilcCs$|d�||rdpd�|d�dS)Nz<value><boolean>�1�0z</boolean></value>
r)rr&rBrrr�	dump_boolszMarshaller.dump_boolcCs<|tks|tkrtd��|d�|tt|���|d�dS)Nzint exceeds XML-RPC limitsz<value><int>z</int></value>
)�MAXINT�MININT�
OverflowErrorr0�int)rr&rBrrr�	dump_longs
zMarshaller.dump_longcCs |d�|t|��|d�dS)Nz<value><double>z</double></value>
)r)rr&rBrrr�dump_double%szMarshaller.dump_doublecCs |d�|||��|d�dS)Nz<value><string>z</string></value>
r)rr&rBr
rrr�dump_unicode+szMarshaller.dump_unicodecCs,|d�tj|�}||jd��|d�dS)Nz<value><base64>
rMz</base64></value>
)rKrNrA)rr&rBrOrrr�
dump_bytes1s
zMarshaller.dump_bytescCs^t|�}||jkrtd��d|j|<|j}|d�x|D]}|||�q8W|d�|j|=dS)Nz"cannot marshal recursive sequencesz<value><array><data>
z</data></array></value>
)r>r_r4rc)rr&rB�irfrgrrr�
dump_array9s


zMarshaller.dump_arraycCs�t|�}||jkrtd��d|j|<|j}|d�xP|j�D]D\}}|d�t|t�s^td��|d||��|||�|d�q<W|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�krgrrr�dump_structGs



zMarshaller.dump_structcCs |d�|t|��|d�dS)Nz<value><dateTime.iso8601>z</dateTime.iso8601></value>
)r.)rr&rBrrr�
dump_datetimeYszMarshaller.dump_datetimecCs2|jtkr ||_|j|�|`n|j|j|�dS)N)r�WRAPPERSrBrDr�rj)rr&rBrrr�
dump_instance_s


zMarshaller.dump_instancerk)NF)!rrrrrrlrircrqr3rt�boolryrxZdump_intrz�floatr
r{r0r|rIrJr~r,�listr��dictr�rr�r/rGrrrrr^�s<
	r^c@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)NFzutf-8)
�_type�_stack�_marks�_data�_value�_methodname�	_encodingrb�
_use_datetime�
_use_bytes)r�use_datetime�use_builtin_typesrrrrs

zUnmarshaller.__init__cCs:|jdks|jrt��|jdkr0tf|jd��t|j�S)N�faultr)r�r�r!r"r�r,)rrrrr]�s

zUnmarshaller.closecCs|jS)N)r�)rrrr�
getmethodname�szUnmarshaller.getmethodnamecCs
||_dS)N)r�)rrYZ
standalonerrrrV�szUnmarshaller.xmlcCshd|kr|jd�d}|dks&|dkr8|jjt|j��g|_|jrZ||jkrZtd|��|dk|_dS)N�:r�array�structzunknown tag %rr&���)	�splitr�rb�lenr�r�r�rlr!)r�tagZattrsrrrrT�szUnmarshaller.startcCs|jj|�dS)N)r�rb)r�textrrrr@�szUnmarshaller.datacCspy|j|}WnNtk
r\d|kr*dSy|j|jd�d}Wntk
rVdSXYnX||dj|j��S)Nr�rrar�)rlrmr�rdr�)rr�rprrrrU�szUnmarshaller.endcCshy|j|}WnNtk
r\d|kr*dSy|j|jd�d}Wntk
rVdSXYnX|||�S)Nr�rr�)rlrmr�)rr�r@rprrr�end_dispatch�szUnmarshaller.end_dispatchcCs|jd�d|_dS)Nr)rbr�)rr@rrr�end_nil�s
zUnmarshaller.end_nilZnilcCs:|dkr|jd�n|dkr(|jd�ntd��d|_dS)NrsFrrTzbad boolean valuer)rbr4r�)rr@rrr�end_boolean�szUnmarshaller.end_boolean�booleancCs|jt|��d|_dS)Nr)rbrxr�)rr@rrr�end_int�szUnmarshaller.end_intZi1Zi2Zi4Zi8rxZ
bigintegercCs|jt|��d|_dS)Nr)rbr�r�)rr@rrr�
end_double�szUnmarshaller.end_doubleZdoubler�cCs|jt|��d|_dS)Nr)rbrr�)rr@rrr�end_bigdecimal�szUnmarshaller.end_bigdecimalZ
bigdecimalcCs&|jr|j|j�}|j|�d|_dS)Nr)r�rArbr�)rr@rrr�
end_string�s
zUnmarshaller.end_string�string�namecCs.|jj�}|j|d�g|j|d�<d|_dS)Nr)r��popr�r�)rr@�markrrr�	end_array�s
zUnmarshaller.end_arrayr�cCsd|jj�}i}|j|d�}x,tdt|�d�D]}||d|||<q.W|g|j|d�<d|_dS)Nrrr)r�r�r��ranger�r�)rr@r�r�rr}rrr�
end_structs
zUnmarshaller.end_structr�cCs6t�}|j|jd��|jr"|j}|j|�d|_dS)NrMr)rGrArDr�r@rbr�)rr@r&rrr�
end_base64s
zUnmarshaller.end_base64rKcCs,t�}|j|�|jrt|�}|j|�dS)N)r/rAr�rFrb)rr@r&rrr�end_dateTimes

zUnmarshaller.end_dateTimezdateTime.iso8601cCs|jr|j|�dS)N)r�r�)rr@rrr�	end_valueszUnmarshaller.end_valuer&cCs
d|_dS)N�params)r�)rr@rrr�
end_params#szUnmarshaller.end_paramsr�cCs
d|_dS)Nr�)r�)rr@rrr�	end_fault'szUnmarshaller.end_faultr�cCs"|jr|j|j�}||_d|_dS)N�
methodName)r�rAr�r�)rr@rrr�end_methodName+szUnmarshaller.end_methodNamer�N)FF)rrrrrr]r�rVrTr@rUr�rlr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�ssZ
	r�c@s$eZdZdd�Zdd�Zdd�ZdS)�_MultiCallMethodcCs||_||_dS)N)�_MultiCallMethod__call_list�_MultiCallMethod__name)rZ	call_listr�rrrr8sz_MultiCallMethod.__init__cCst|jd|j|f�S)Nz%s.%s)r�r�r�)rr�rrr�__getattr__;sz_MultiCallMethod.__getattr__cGs|jj|j|f�dS)N)r�rbr�)r�argsrrr�__call__=sz_MultiCallMethod.__call__N)rrrrr�r�rrrrr�5sr�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�rrrrDszMultiCallIterator.__init__cCsR|j|}t|�ti�kr.t|d|d��n t|�tg�krF|dStd��dS)Nr#r$rz#unexpected type in multicall result)r�r3r"�
ValueError)rr}�itemrrr�__getitem__Gs
zMultiCallIterator.__getitem__N)rrrrrr�rrrrr�@sr�c@s4eZdZdZdd�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�serverrrrraszMultiCall.__init__cCsd|jjt|�fS)Nz<%s at %#x>)rrr>)rrrrr eszMultiCall.__repr__cCst|j|�S)N)r�r�)rr�rrrr�jszMultiCall.__getattr__cCs:g}x"|jD]\}}|j||d��qWt|jjj|��S)N)r�r�)r�rbr�r��systemZ	multicall)rZmarshalled_listr�r�rrrr�mszMultiCall.__call__N)	rrrrrr rr�r�rrrrr�Psr�FcCsrtrHtrH|rt}tj}n|r&t}t}nt}t}tdd||t�}t|�}n"t||d�}trbt|�}nt	|�}||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�FastUnmarshallerrFrKrLrPrEr"r�rQ)r�r�Z
mkdatetimeZmkbytesrWrXrrr�	getparsers 

r�cCs�t|ttf�std��t|t�r&d}n"|rHt|t�rHt|�dksHtd��|sPd}tr^t|�}n
t||�}|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	xmlheaderrrrri�s6



ricCs2t||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�urrr�loads�s	
r�c	Cs<tst�t�}tjd|dd��}|j|�WdQRX|j�S)zhdata -> gzip encoded data

    Encode data using the gzip content encoding as described in RFC 1952
    �wbr)�mode�fileobjZ
compresslevelN)�gzip�NotImplementedErrorr�GzipFilerB�getvalue)r@rp�gzfrrr�gzip_encodesr��@cCs�tst�tjdt|�d��H}y$|dkr0|j�}n|j|d�}Wntk
r\td��YnXWdQRX|dkr�t|�|kr�td��|S)zrgzip encoded data -> unencoded data

    Decode data using the gzip content encoding as described in RFC 1952
    �rb)r�r�rrzinvalid dataNz#max gzipped payload length exceeded)r�r�r�r�read�OSErrorr�r�)r@Z
max_decoder�Zdecodedrrr�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.
    cCs.tst�t|j��|_tjj|d|jd�dS)Nr�)r�r�)r�r�rr��ior�r)r�responserrrr=szGzipDecodedResponse.__init__c
Cs"ztjj|�Wd|jj�XdS)N)r�r�r]r�)rrrrr]EszGzipDecodedResponse.closeN)rrrrrr]rrrrr�9sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�_MethodcCs||_||_dS)N)�
_Method__send�
_Method__name)r�sendr�rrrrRsz_Method.__init__cCst|jd|j|f�S)Nz%s.%s)r�r�r�)rr�rrrr�Usz_Method.__getattr__cGs|j|j|�S)N)r�r�)rr�rrrr�Wsz_Method.__call__N)rrrrr�r�rrrrr�Osr�c@s~eZdZdZdeZdZdZddd�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�rrrrnszTransport.__init__cCs~xxdD]p}y|j||||�Stjjk
r8|r4�Yqtk
rt}z"|sb|jtjtjtjfkrd�WYdd}~XqXqWdS)Nrr)rr)	�single_request�http�clientZRemoteDisconnectedr��errnoZ
ECONNRESETZECONNABORTEDZEPIPE)r�host�handler�request_body�verboser}�errr�request~s

zTransport.requestcCs�y6|j||||�}|j�}|jdkr4||_|j|�SWn2tk
rL�Yntk
rh|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_connZresprrrr��s"
zTransport.single_requestcCst|j|jd�S)N)r�r�)r�r�r�)rrrrr��szTransport.getparsercCsri}t|t�r|\}}tjj|�\}}|rdtjj|�}tj|�jd�}dj	|j
��}dd|fg}ng}|||fS)Nzutf-8raZ
AuthorizationzBasic )r+r,�urllib�parseZ	splituserZunquote_to_bytesrKrNrArdr�)rr��x509ZauthZ
extra_headersrrr�
get_host_info�s
zTransport.get_host_infocCsL|jr||jdkr|jdS|j|�\}|_}|tjj|�f|_|jdS)Nrr)r�r�r�r�r�ZHTTPConnection)rr��chostr�rrr�make_connection�s

zTransport.make_connectioncCs |j\}}|rd|_|j�dS)N)NN)r�r])rr��
connectionrrrr]�s
zTransport.closecCs�|j|�}|jdd�}|r&|jd�|jrLtrL|jd|dd�|jd
�n|jd|�|jd�|jd	|jf�|j||�|j	||�|S)NrZPOSTT)Zskip_accept_encoding�Accept-Encodingr��Content-Type�text/xmlz
User-Agent)rr�)rr)
r�r�Zset_debuglevel�accept_gzip_encodingr�Z
putrequestrb�
user_agent�send_headers�send_content)rr�r�r��debugr�rrrrr��s



zTransport.send_requestcCs"x|D]\}}|j||�qWdS)N)�	putheader)rr�r�key�valrrrr	szTransport.send_headerscCsR|jdk	r0|jt|�kr0tr0|jdd�t|�}|jdtt|���|j|�dS)NzContent-Encodingr�zContent-Length)�encode_thresholdr�r�rr�r0Z
endheaders)rr�r�rrrrs
zTransport.send_contentcCs�t|d�r*|jdd�dkr$t|�}q.|}n|}|j�\}}x2|jd�}|sLP|jr`tdt|��|j|�q<W||k	r~|j	�|j	�|j	�S)Nr�zContent-Encodingrar�izbody:)
r2r�r�r�r�r��printrr[r])rr��streamr�r�r@rrrr�%s"


zTransport.parse_response)FF)F)F)rrrr�__version__rrrrr�r�r�r�r�r]r�rrr�rrrrr�`s


!r�cs0eZdZdZd	dd��fdd�Zdd�Z�ZS)
�
SafeTransportz2Handles an HTTPS transaction to an XML-RPC server.FN)�contextcst�j||d�||_dS)N)r�r�)�superrr)rr�r�r)rrrrFszSafeTransport.__init__cCst|jr||jdkr|jdSttjd�s2td��|j|�\}|_}|tjj|dfd|ji|p`i��f|_|jdS)Nrr�HTTPSConnectionz1your version of http.client doesn't support HTTPSr)	r�r2r�r�r�r�r�rr)rr�r�r�rrrr�Ms

zSafeTransport.make_connection)FF)rrrrrr��
__classcell__rr)rrrCsrc@s\eZdZdZddd�dd�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.
    NF)rcCs�tjj|�\}	}|	dkr td��tjj|�\|_|_|js@d|_|dkrz|	dkr^t}
d|i}nt}
i}|
f||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�rr3r�Zextra_kwargsrrrr�s&

zServerProxy.__init__cCs|jj�dS)N)rr])rrrrZ__close�szServerProxy.__closecCsPt|||j|jd�j|jd�}|jj|j|j||jd�}t	|�dkrL|d}|S)N)rYr`�xmlcharrefreplace)r�rr)
rirrrDrr�rrrr�)rr�r�r�r�rrrZ	__request�s

zServerProxy.__requestcCsd|jj|j|jfS)Nz
<%s for %s%s>)rrrr)rrrrr �szServerProxy.__repr__cCst|j|�S)N)r��_ServerProxy__request)rr�rrrr��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�attrrrrr��s
zServerProxy.__call__cCs|S)Nr)rrrr�	__enter__�szServerProxy.__enter__cGs|j�dS)N)r)rr�rrr�__exit__�szServerProxy.__exit__)NNFFFF)
rrrrrrrr rr�r�r!r"rrrrrls
r�__main__zhttp://localhost:8000ZERROR�	li���li�iD���i����i���ip���iԁ��iD���iC���iB���i����i����i����i����)FF)NNNF)FF)r�)VrrK�sysr-r�decimalrZhttp.clientr�Zurllib.parser�Zxml.parsersrr�r�rr��ImportErrorr
�version_inforrurvZPARSE_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�rZcurrentTimeZgetCurrentTimergZmultiZgetData�pow�addr�rrrr�<module>�s�



K	#!(C'
'
J

d)i


Zerion Mini Shell 1.0