AlkantarClanX12

Your IP : 18.188.68.115


Current Path : /lib64/python3.6/xmlrpc/__pycache__/
Upload File :
Current File : //lib64/python3.6/xmlrpc/__pycache__/server.cpython-36.opt-2.pyc

3

��fK��@s�ddlmZmZmZmZmZddlmZddlZddlZ	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZyddlZWnek
r�dZYnXd)dd�Zdd�ZGd	d
�d
�ZGdd�de�ZGd
d�de
je�ZGdd�de�ZGdd�de�ZGdd�dej�ZGdd�d�ZGdd�de�ZGdd�dee�ZGdd�dee�Z e!dk�r�ddl"Z"Gdd�d�Z#ed*��~Z$e$j%e&�e$j%d"d#�d$�e$j'e#�dd%�e$j(�e)d&�e)d'�ye$j*�Wn(e+k
�r�e)d(�ej,d�YnXWdQRXdS)+�)�Fault�dumps�loads�gzip_encode�gzip_decode)�BaseHTTPRequestHandlerNTcCsJ|r|jd�}n|g}x.|D]&}|jd�r8td|��qt||�}qW|S)N�.�_z(attempt to access private attribute "%s")�split�
startswith�AttributeError�getattr)�obj�attr�allow_dotted_namesZattrs�i�r�%/usr/lib64/python3.6/xmlrpc/server.py�resolve_dotted_attribute{s


rcs�fdd�t��D�S)Ncs*g|]"}|jd�rtt�|��r|�qS)r	)r�callabler
)�.0�member)rrr�
<listcomp>�sz'list_public_methods.<locals>.<listcomp>)�dir)rr)rr�list_public_methods�src@sleZdZddd�Zddd�Zddd�Zd	d
�Zdd�Zdd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�SimpleXMLRPCDispatcherFNcCs&i|_d|_||_|pd|_||_dS)Nzutf-8)�funcs�instance�
allow_none�encoding�use_builtin_types)�selfrrr rrr�__init__�s

zSimpleXMLRPCDispatcher.__init__cCs||_||_dS)N)rr)r!rrrrr�register_instance�s!z(SimpleXMLRPCDispatcher.register_instancecCs|dkr|j}||j|<dS)N)�__name__r)r!Zfunction�namerrr�register_function�sz(SimpleXMLRPCDispatcher.register_functioncCs|jj|j|j|jd��dS)N)zsystem.listMethodszsystem.methodSignaturezsystem.methodHelp)r�update�system_listMethods�system_methodSignature�system_methodHelp)r!rrr� register_introspection_functions�s
z7SimpleXMLRPCDispatcher.register_introspection_functionscCs|jjd|ji�dS)Nzsystem.multicall)rr'�system_multicall)r!rrr�register_multicall_functions�sz3SimpleXMLRPCDispatcher.register_multicall_functionscCs�yPt||jd�\}}|dk	r(|||�}n|j||�}|f}t|d|j|jd�}Wn�tk
r�}zt||j|jd�}WYdd}~XnNtj�\}}	}
z$ttdd||	f�|j|jd�}Wdd}}	}
XYnX|j	|jd�S)N)r �)Zmethodresponserr)rrz%s:%s)rr�xmlcharrefreplace)
rr �	_dispatchrrrr�sys�exc_info�encode)r!�data�dispatch_method�path�params�method�response�fault�exc_type�	exc_value�exc_tbrrr�_marshaled_dispatch�s&z*SimpleXMLRPCDispatcher._marshaled_dispatchcCs^t|jj��}|jdk	rVt|jd�r8|t|jj��O}nt|jd�sV|tt|j��O}t|�S)N�_listMethodsr0)�setr�keysr�hasattrr?r�sorted)r!�methodsrrrr(s
z)SimpleXMLRPCDispatcher.system_listMethodscCsdS)Nzsignatures not supportedr)r!�method_namerrrr))sz-SimpleXMLRPCDispatcher.system_methodSignaturecCs�d}||jkr|j|}nX|jdk	rrt|jd�r<|jj|�St|jd�sryt|j||j�}Wntk
rpYnX|dkr~dStj|�SdS)N�_methodHelpr0�)	rrrBrFrrr�pydoc�getdoc)r!rEr8rrrr*6s"

z(SimpleXMLRPCDispatcher.system_methodHelpc
Cs�g}x�|D]�}|d}|d}y|j|j||�g�Wq
tk
rl}z|j|j|jd��WYdd}~Xq
tj�\}}}	z|jdd||fd��Wdd}}}	XYq
Xq
W|S)NZ
methodNamer7)�	faultCode�faultStringr.z%s:%s)�appendr0rrJrKr1r2)
r!Z	call_list�resultsZcallrEr7r:r;r<r=rrrr,Us$

z'SimpleXMLRPCDispatcher.system_multicallcCs�y|j|}Wntk
r"YnX|dk	r4||�Std|��|jdk	r�t|jd�rd|jj||�Syt|j||j�}Wntk
r�YnX|dk	r�||�Std|��dS)Nzmethod "%s" is not supportedr0)	r�KeyError�	ExceptionrrBr0rrr)r!r8r7�funcrrrr0ys(
z SimpleXMLRPCDispatcher._dispatch)FNF)F)N)NN)r$�
__module__�__qualname__r"r#r&r+r-r>r(r)r*r,r0rrrrr�s	

$

)
$rc@sbeZdZdZdZdZdZejdej	ej
B�Zdd�Zd	d
�Z
dd�Zd
d�Zdd�Zddd�ZdS)�SimpleXMLRPCRequestHandler�/�/RPC2ixr.Tz�
                            \s* ([^\s;]+) \s*            #content-coding
                            (;\s* q \s*=\s* ([0-9\.]+))? #q
                            cCsbi}|jjdd�}xJ|jd�D]<}|jj|�}|r|jd�}|rHt|�nd}|||jd�<qW|S)NzAccept-EncodingrG�,�g�?r.)�headers�getr
�	aepattern�match�group�float)r!�rZae�er[�vrrr�accept_encodings�s
z+SimpleXMLRPCRequestHandler.accept_encodingscCs|jr|j|jkSdSdS)NT)�	rpc_pathsr6)r!rrr�is_rpc_path_valid�sz,SimpleXMLRPCRequestHandler.is_rpc_path_validcCs�|j�s|j�dSy�d}t|jd�}g}x>|rjt||�}|jj|�}|sNP|j|�|t|d�8}q.Wdj	|�}|j
|�}|dkr�dS|jj|t
|dd�|j�}Wn�tk
�r6}zp|jd�t|jd�o�|jj�r|jd	t|��tj�}	t|	jd
d�d
�}	|jd|	�|jd
d�|j�WYdd}~Xn�X|jd�|jdd�|jdk	�r�t|�|jk�r�|j�jdd�}
|
�r�yt|�}|jdd�Wntk
�r�YnX|jd
tt|���|j�|jj|�dS)N�
izcontent-lengthr.�r0i��_send_traceback_headerzX-exception�ASCII�backslashreplacezX-tracebackzContent-length�0��zContent-typeztext/xml�gziprzContent-Encodingi(i����) rc�
report_404�intrX�minZrfile�readrL�len�join�decode_request_content�serverr>r
r6rO�
send_responserBrf�send_header�str�	traceback�
format_excr3�end_headers�encode_thresholdrarYr�NotImplementedError�wfile�write)r!Zmax_chunk_sizeZsize_remaining�LZ
chunk_size�chunkr4r9r_Ztrace�qrrr�do_POST�sX






z"SimpleXMLRPCRequestHandler.do_POSTcCs�|jjdd�j�}|dkr|S|dkrtyt|�Stk
rR|jdd|�Yq�tk
rp|jdd�Yq�Xn|jdd|�|jdd	�|j�dS)
Nzcontent-encodingZidentityrki�zencoding %r not supportedi�zerror decoding gzip contentzContent-lengthri)	rXrY�lowerrr|ru�
ValueErrorrvrz)r!r4rrrrrssz1SimpleXMLRPCRequestHandler.decode_request_contentcCsF|jd�d}|jdd�|jdtt|���|j�|jj|�dS)Ni�sNo such pagezContent-typez
text/plainzContent-length)rurvrwrqrzr}r~)r!r9rrrrm/s
z%SimpleXMLRPCRequestHandler.report_404�-cCs|jjrtj|||�dS)N)rt�logRequestsr�log_request)r!�code�sizerrrr�8sz&SimpleXMLRPCRequestHandler.log_requestN)rTrUrl)r�r�)r$rQrRrbr{ZwbufsizeZdisable_nagle_algorithm�re�compile�VERBOSE�
IGNORECASErZrarcr�rsrmr�rrrrrS�s	G	rSc@s*eZdZdZdZedddddfdd�ZdS)�SimpleXMLRPCServerTFNcCs,||_tj||||�tjj||||�dS)N)r�rr"�socketserver�	TCPServer)r!�addr�requestHandlerr�rr�bind_and_activater rrrr"QszSimpleXMLRPCServer.__init__)r$rQrRZallow_reuse_addressrfrSr"rrrrr�>s
r�c@s<eZdZedddddfdd�Zdd�Zdd	�Zdd
d�ZdS)
�MultiPathXMLRPCServerTFNc	Cs2tj||||||||�i|_||_|p*d|_dS)Nzutf-8)r�r"�dispatchersrr)r!r�r�r�rrr�r rrrr"bs

zMultiPathXMLRPCServer.__init__cCs||j|<|S)N)r�)r!r6Z
dispatcherrrr�add_dispatcherls
z$MultiPathXMLRPCServer.add_dispatchercCs
|j|S)N)r�)r!r6rrr�get_dispatcherpsz$MultiPathXMLRPCServer.get_dispatchercCs|y|j|j|||�}Wn^tj�dd�\}}z2ttdd||f�|j|jd�}|j|jd�}Wdd}}XYnX|S)N�r.z%s:%s)rrr/)	r�r>r1r2rrrrr3)r!r4r5r6r9r;r<rrrr>ss
z)MultiPathXMLRPCServer._marshaled_dispatch)NN)r$rQrRrSr"r�r�r>rrrrr�Zsr�c@s0eZdZddd�Zdd�Zdd�Zdd	d
�ZdS)
�CGIXMLRPCRequestHandlerFNcCstj||||�dS)N)rr")r!rrr rrrr"�sz CGIXMLRPCRequestHandler.__init__cCsP|j|�}td�tdt|��t�tjj�tjjj|�tjjj�dS)NzContent-Type: text/xmlzContent-Length: %d)r>�printrqr1�stdout�flush�bufferr~)r!�request_textr9rrr�
handle_xmlrpc�s

z%CGIXMLRPCRequestHandler.handle_xmlrpccCs�d}tj|\}}tjj|||d�}|jd�}td||f�tdtjj�tdt|��t�t	j
j�t	j
jj
|�t	j
jj�dS)Ni�)r��message�explainzutf-8z
Status: %d %szContent-Type: %szContent-Length: %d)rZ	responses�httprtZDEFAULT_ERROR_MESSAGEr3r�ZDEFAULT_ERROR_CONTENT_TYPErqr1r�r�r�r~)r!r�r�r�r9rrr�
handle_get�s


z"CGIXMLRPCRequestHandler.handle_getcCsz|dkr$tjjdd�dkr$|j�nRyttjjdd��}Wnttfk
rVd}YnX|dkrltjj	|�}|j
|�dS)NZREQUEST_METHODZGETZCONTENT_LENGTHr.rl)�os�environrYr�rnr��	TypeErrorr1�stdinrpr�)r!r�Zlengthrrr�handle_request�s

z&CGIXMLRPCRequestHandler.handle_request)FNF)N)r$rQrRr"r�r�r�rrrrr��s
r�c@s:eZdZdiiifdd�Zdiiidfdd�Zdd�ZdS)�
ServerHTMLDocNcCs^|p|j}g}d}tjd�}�x|j||�}	|	s2P|	j�\}
}|j||||
���|	j�\}}
}}}}|
r�||�jdd�}|jd||f�n�|r�dt|�}|jd|||�f�n~|r�dt|�}|jd|||�f�nV|||d�d	k�r|j|j	||||��n(|�r$|jd
|�n|j|j	||��|}q W|j|||d���dj
|�S)NrzM\b((http|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?((?:\w|\.)+))\b�"z&quot;z<a href="%s">%s</a>z'http://www.rfc-editor.org/rfc/rfc%d.txtz(http://www.python.org/dev/peps/pep-%04d/r.�(zself.<strong>%s</strong>rG)�escaper�r��search�spanrL�groups�replacernZnamelinkrr)r!�textr�r�classesrDrM�here�patternr[�start�end�all�schemeZrfcZpepZselfdotr%Zurlrrr�markup�s8

zServerHTMLDoc.markupcCs$|r
|jpdd|}d}	d|j|�|j|�f}
tj|�rrtj|�}tj|jdd�|j|j|j	|j
|jd�}n<tj|�r�tj|�}tj|j|j|j|j	|j
|jd�}nd}t
|t�r�|dp�|}|dp�d}
n
tj|�}
|
||	o�|jd|	�}|j|
|j|||�}|�od	|}d
||fS)NrGr�z$<a name="%s"><strong>%s</strong></a>r.)�annotations�formatvaluez(...)rz'<font face="helvetica, arial">%s</font>z<dd><tt>%s</tt></dd>z<dl><dt>%s</dt>%s</dl>
)r$r��inspectZismethodZgetfullargspecZ
formatargspec�argsZvarargsZvarkwZdefaultsr�r�Z
isfunction�
isinstance�tuplerHrIZgreyr��	preformat)r!�objectr%�modrr�rDZclZanchorZnote�titler�ZargspecZ	docstringZdecl�docrrr�
docroutine�s<





zServerHTMLDoc.docroutinecCs�i}x,|j�D] \}}d|||<||||<qW|j|�}d|}|j|dd�}|j||j|�}	|	old|	}	|d|	}g}
t|j��}x&|D]\}}|
j|j|||d��q�W||jddd	d
j	|
��}|S)Nz#-z)<big><big><strong>%s</strong></big></big>z#ffffffz#7799eez<tt>%s</tt>z
<p>%s</p>
)rZMethodsz#eeaa77rG)
�itemsr�Zheadingr�r�rCrLr�Z
bigsectionrr)r!�server_nameZpackage_documentationrDZfdict�key�value�head�resultr��contentsZmethod_itemsrrr�	docserver$s"
zServerHTMLDoc.docserver)r$rQrRr�r�r�rrrrr��s),r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�XMLRPCDocGeneratorcCsd|_d|_d|_dS)NzXML-RPC Server DocumentationzGThis server exports the following methods through the XML-RPC protocol.)r��server_documentation�server_title)r!rrrr"DszXMLRPCDocGenerator.__init__cCs
||_dS)N)r�)r!r�rrr�set_server_titleLsz#XMLRPCDocGenerator.set_server_titlecCs
||_dS)N)r�)r!r�rrr�set_server_nameQsz"XMLRPCDocGenerator.set_server_namecCs
||_dS)N)r�)r!r�rrr�set_server_documentationVsz+XMLRPCDocGenerator.set_server_documentationcCs�i}x�|j�D]�}||jkr(|j|}n�|jdk	r�ddg}t|jd�rV|jj|�|d<t|jd�rr|jj|�|d<t|�}|dkr�|}q�t|jd�s�yt|j|�}Wq�tk
r�|}Yq�Xq�|}n|||<qWt	�}|j
|j|j|�}|j
tj|j�|�S)N�_get_method_argstringrrFr.r0)NN)r(rrrBr�rFr�rrr�r�r�r�Zpage�htmlr�r�)r!rDrEr8Zmethod_infoZ
documenterZ
documentationrrr�generate_html_documentation[s8


z.XMLRPCDocGenerator.generate_html_documentationN)r$rQrRr"r�r�r�r�rrrrr�=s
r�c@seZdZdd�ZdS)�DocXMLRPCRequestHandlercCsf|j�s|j�dS|jj�jd�}|jd�|jdd�|jdtt|���|j	�|j
j|�dS)Nzutf-8rjzContent-typez	text/htmlzContent-length)rcrmrtr�r3rurvrwrqrzr}r~)r!r9rrr�do_GET�s
zDocXMLRPCRequestHandler.do_GETN)r$rQrRr�rrrrr��s
r�c@s"eZdZedddddfdd�ZdS)�DocXMLRPCServerTFNc	Cs&tj||||||||�tj|�dS)N)r�r"r�)r!r�r�r�rrr�r rrrr"�szDocXMLRPCServer.__init__)r$rQrRr�r"rrrrr��sr�c@seZdZdd�Zdd�ZdS)�DocCGIXMLRPCRequestHandlercCsT|j�jd�}td�tdt|��t�tjj�tjjj|�tjjj�dS)Nzutf-8zContent-Type: text/htmlzContent-Length: %d)	r�r3r�rqr1r�r�r�r~)r!r9rrrr��s
z%DocCGIXMLRPCRequestHandler.handle_getcCstj|�tj|�dS)N)r�r"r�)r!rrrr"�s
z#DocCGIXMLRPCRequestHandler.__init__N)r$rQrRr�r"rrrrr��sr��__main__c@s"eZdZdd�ZGdd�d�ZdS)�ExampleServicecCsdS)NZ42r)r!rrr�getData�szExampleService.getDatac@seZdZedd��ZdS)zExampleService.currentTimecCs
tjj�S)N)�datetimeZnowrrrr�getCurrentTime�sz)ExampleService.currentTime.getCurrentTimeN)r$rQrR�staticmethodr�rrrr�currentTime�sr�N)r$rQrRr�r�rrrrr��sr��	localhost�@cCs||S)Nr)�x�yrrr�<lambda>�sr��add)rz&Serving XML-RPC on localhost port 8000zKIt is advisable to run this example server within a secure, closed network.z&
Keyboard interrupt received, exiting.)T)r�r�)-Z
xmlrpc.clientrrrrrZhttp.serverrr�r�r�r1r�r�rHr�rxZfcntl�ImportErrorrrrrSr�r�r�r�ZHTMLDocr�r�r�r�r�r$r�r�rtr&�powr#r-r�Z
serve_forever�KeyboardInterrupt�exitrrrr�<module>ks^

,ErQ