Your IP : 13.59.183.77


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



���]v��@s�ddlmZmZmZmZmZddlmZddlZddlZ	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZyddlZWnek
r�dZYnXddd�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!dkr�ddl"Z"Gdd�d�Z#ed d!f�Z$e$j%e&�e$j%d"d#�d$�e$j'e#�d%d�e$j(�e)d&�e)d'�ye$j*�Wn3e+k
r�e)d(�e$j,�ej-d�YnXdS))�)�Fault�dumps�loads�gzip_encode�gzip_decode)�BaseHTTPRequestHandlerNTcCsg|r|jd�}n	|g}x?|D]7}|jd�rPtd|��q(t||�}q(W|S)N�.�_z(attempt to access private attribute "%s")�split�
startswith�AttributeError�getattr)�obj�attr�allow_dotted_namesZattrs�i�r�+/opt/alt/python35/lib64/python3.5/server.py�resolve_dotted_attribute{s
	
rcs�fdd�t��D�S)Ncs;g|]1}|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@s�eZdZddddd�Zddd�Zddd�Zd	d
�Zdd�Zddd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�SimpleXMLRPCDispatcherFNcCs7i|_d|_||_|p$d|_||_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!�function�namerrr�register_function�s	z(SimpleXMLRPCDispatcher.register_functioncCs/|jjd|jd|jd|ji�dS)Nzsystem.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"y|t|d|j�\}}|dk	r<|||�}n|j||�}|f}t|ddd|jd|j�}Wn�tk
r�}z#t|d|jd|j�}WYdd}~XnNtj�\}}	}
ttdd||	f�d|jd|j�}YnX|j	|jd�S)Nr Zmethodresponse�rrz%s:%s�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	r}t|jd�rR|t|jj��O}n+t|jd�s}|tt|j��O}t|�S)N�_listMethodsr1)�setr�keysr�hasattrr@r�sorted)r!�methodsrrrr)sz)SimpleXMLRPCDispatcher.system_listMethodscCsdS)Nzsignatures not supportedr)r!�method_namerrrr*%sz-SimpleXMLRPCDispatcher.system_methodSignaturecCs�d}||jkr%|j|}nt|jdk	r�t|jd�rV|jj|�St|jd�s�yt|j||j�}Wntk
r�YnX|dkr�dStj|�SdS)N�_methodHelpr1�)	rrrCrGrrr�pydoc�getdoc)r!rFr9rrrr+2s"
z(SimpleXMLRPCDispatcher.system_methodHelpc
Cs�g}x�|D]�}|d}|d}y |j|j||�g�Wq
tk
r�}z$|jd|jd|ji�WYdd}~Xq
tj�\}}}	|jdddd||fi�Yq
Xq
W|S)NZ
methodNamer8�	faultCode�faultStringr/z%s:%s)�appendr1rrKrLr2r3)
r!Z	call_list�results�callrFr8r;r<r=r>rrrr-Qs 



 	" z'SimpleXMLRPCDispatcher.system_multicallcCs�y|j|}Wntk
r%Yn'X|dk	r<||�Std|��|jdk	r�t|jd�r�|jj||�Syt|j||j�}Wntk
r�YnX|dk	r�||�Std|��dS)Nzmethod "%s" is not supportedr1)	r�KeyError�	ExceptionrrCr1rrr)r!r9r8�funcrrrr1qs(



z SimpleXMLRPCDispatcher._dispatch)r$�
__module__�__qualname__r"r#r'r,r.r?r)r*r+r-r1rrrrr�s	$%
 rc@s�eZdZdZdZdZdZejdej	ej
B�Zdd�Zd	d
�Z
dd�Zd
d�Zdd�Zdddd�ZdS)�SimpleXMLRPCRequestHandler�/�/RPC2ixr/Tz�
                            \s* ([^\s;]+) \s*            #content-coding
                            (;\s* q \s*=\s* ([0-9\.]+))? #q
                            cCs�i}|jjdd�}xi|jd�D]X}|jj|�}|r+|jd�}|rjt|�nd}|||jd�<q+W|S)NzAccept-EncodingrH�,�g�?r/)�headers�getr
�	aepattern�match�group�float)r!�rZae�er]�vrrr�accept_encodings�sz+SimpleXMLRPCRequestHandler.accept_encodingscCs!|jr|j|jkSdSdS)NT)�	rpc_pathsr7)r!rrr�is_rpc_path_valid�s	z,SimpleXMLRPCRequestHandler.is_rpc_path_validcCsp|j�s|j�dSy�d}t|jd�}g}xS|r�t||�}|jj|�}|smP|j|�|t|d�8}q?Wdj	|�}|j
|�}|dkr�dS|jj|t
|dd�|j�}Wn�tk
r�}z�|jd�t|jd�ru|jjru|jd	t|��tj�}	t|	jd
d�d
�}	|jd|	�|jd
d�|j�WYdd}~Xn�X|jd�|jdd�|jdk	r6t|�|jkr6|j�jdd�}
|
r6y t|�}|jdd�Wntk
r5YnX|jd
tt|���|j�|jj|�dS)N�
izcontent-lengthr/�r1i��_send_traceback_headerzX-exception�ASCII�backslashreplacezX-tracebackzContent-length�0��zContent-typeztext/xml�gziprzContent-Encodingi(i����) re�
report_404�intrZ�minZrfile�readrM�len�join�decode_request_content�serverr?r
r7rQ�
send_responserCrh�send_header�str�	traceback�
format_excr4�end_headers�encode_thresholdrcr[r�NotImplementedError�wfile�write)r!Zmax_chunk_sizeZsize_remaining�LZ
chunk_size�chunkr5r:raZtrace�qrrr�do_POST�sX
	
	"



z"SimpleXMLRPCRequestHandler.do_POSTcCs�|jjdd�j�}|dkr+|S|dkr�yt|�SWq�tk
rm|jdd|�Yq�tk
r�|jdd�Yq�Xn|jdd|�|jdd	�|j�dS)
Nzcontent-encoding�identityrmi�zencoding %r not supportedi�zerror decoding gzip contentzContent-lengthrk)	rZr[�lowerrr~rw�
ValueErrorrxr|)r!r5rrrrrus

z1SimpleXMLRPCRequestHandler.decode_request_contentcCs]|jd�d}|jdd�|jdtt|���|j�|jj|�dS)Ni�sNo such pagezContent-typez
text/plainzContent-length)rwrxryrsr|rr�)r!r:rrrro's

z%SimpleXMLRPCRequestHandler.report_404�-cCs#|jjrtj|||�dS)N)rv�logRequestsr�log_request)r!�code�sizerrrr�0sz&SimpleXMLRPCRequestHandler.log_requestN)rVrWrn)r$rSrTrdr}ZwbufsizeZdisable_nagle_algorithm�re�compile�VERBOSE�
IGNORECASEr\rcrer�ruror�rrrrrU�s	G	rUc@s:eZdZdZdZeddddddd�ZdS)�SimpleXMLRPCServerTFNcCs<||_tj||||�tjj||||�dS)N)r�rr"�socketserver�	TCPServer)r!�addr�requestHandlerr�rr�bind_and_activater rrrr"Is	zSimpleXMLRPCServer.__init__)r$rSrTZallow_reuse_addressrhrUr"rrrrr�6s
	r�c@sXeZdZeddddddd�Zdd�Zdd	�Zddd
d�ZdS)�MultiPathXMLRPCServerTFNc	CsGtj||||||||�i|_||_|p=d|_dS)Nzutf-8)r�r"�dispatchersrr)r!r�r�r�rrr�r rrrr"Zs

		zMultiPathXMLRPCServer.__init__cCs||j|<|S)N)r�)r!r7Z
dispatcherrrr�add_dispatcherds
z$MultiPathXMLRPCServer.add_dispatchercCs|j|S)N)r�)r!r7rrr�get_dispatcherhsz$MultiPathXMLRPCServer.get_dispatchercCs�y |j|j|||�}Wnjtj�dd�\}}ttdd||f�d|jd|j�}|j|jd�}YnX|S)N�r/z%s:%srrr0)	r�r?r2r3rrrrr4)r!r5r6r7r:r<r=rrrr?ks
z)MultiPathXMLRPCServer._marshaled_dispatch)r$rSrTrUr"r�r�r?rrrrr�Rs	r�c@sLeZdZddddd�Zdd�Zdd�Zdd	d
�ZdS)�CGIXMLRPCRequestHandlerFNcCstj||||�dS)N)rr")r!rrr rrrr"}sz CGIXMLRPCRequestHandler.__init__cCsh|j|�}td�tdt|��t�tjj�tjjj|�tjjj�dS)NzContent-Type: text/xmlzContent-Length: %d)r?�printrsr2�stdout�flush�bufferr�)r!�request_textr:rrr�
handle_xmlrpc�s

z%CGIXMLRPCRequestHandler.handle_xmlrpccCs�d}tj|\}}tjjd|d|d|i}|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�httprvZDEFAULT_ERROR_MESSAGEr4r�ZDEFAULT_ERROR_CONTENT_TYPErsr2r�r�r�r�)r!r�r�r�r:rrr�
handle_get�s	

z"CGIXMLRPCRequestHandler.handle_getcCs�|dkr4tjjdd�dkr4|j�nkyttjjdd��}Wnttfk
rsd}YnX|dkr�tjj	|�}|j
|�dS)NZREQUEST_METHOD�GETZCONTENT_LENGTHr/rn)�os�environr[r�rpr��	TypeErrorr2�stdinrrr�)r!r��lengthrrr�handle_request�s
z&CGIXMLRPCRequestHandler.handle_request)r$rSrTr"r�r�r�rrrrr�zsr�c@sOeZdZdiiidd�Zdiiiddd�Zdd�ZdS)�
ServerHTMLDocNcCs�|p|j}g}d}tjd�}x�|j||�}	|	sFP|	j�\}
}|j||||
���|	j�\}}
}}}}|
r�||�jdd�}|jd||f�n�|rdt|�}|jd|||�f�n�|r7dt|�}|jd|||�f�no|||d�d	krs|j|j	||||��n3|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>rH)�escaper�r��search�spanrM�groups�replacerpZnamelinkrt)r!�textr�r�classesrErN�here�patternr]�start�end�all�schemeZrfcZpepZselfdotr&Zurlrrr�markup�s8  "
zServerHTMLDoc.markupc	Cs�|r|jpdd|}d}	d|j|�|j|�f}
tj|�r�tj|�}tj|jdd�|j|j|j	d|j
d|j�}n]tj|�r�tj|�}tj|j|j|j|j	d|j
d|j�}nd}t
|t�r5|dp|}|dp/d}
ntj|�}
|
||	oa|jd	|	�}|j|
|j|||�}|o�d
|}d||fS)NrHr�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�argsZvarargsZvarkw�defaultsr�r�Z
isfunction�
isinstance�tuplerIrJZgreyr��	preformat)r!�objectr&�modrr�rEZclZanchorZnote�titler�ZargspecZ	docstringZdecl�docrrr�
docroutine�s<			zServerHTMLDoc.docroutinecCsi}x6|j�D](\}}d|||<||||<qW|j|�}d|}|j|dd�}|j||j|�}	|	o�d|	}	|d|	}g}
t|j��}x3|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#eeaa77rH)
�itemsr��headingr�r�rDrMr�Z
bigsectionrt)r!�server_nameZpackage_documentationrEZfdict�key�value�head�resultr��contentsZmethod_itemsrrr�	docservers"
#	zServerHTMLDoc.docserver)r$rSrTr�r�r�rrrrr��s),r�c@sLeZdZdd�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"8s		zXMLRPCDocGenerator.__init__cCs
||_dS)N)r�)r!r�rrr�set_server_title@sz#XMLRPCDocGenerator.set_server_titlecCs
||_dS)N)r�)r!r�rrr�set_server_nameEsz"XMLRPCDocGenerator.set_server_namecCs
||_dS)N)r�)r!r�rrr�set_server_documentationJsz+XMLRPCDocGenerator.set_server_documentationcCsai}x|j�D]
}||jkr8|j|}n�|jdk	rddg}t|jd�r{|jj|�|d<t|jd�r�|jj|�|d<t|�}|dkr�|}qt|jd�s
yt|j|�}Wqtk
r|}YqXq|}n|||<qWt	�}|j
|j|j|�}|j
tj|j�|�S)N�_get_method_argstringrrGr/r1)NN)r)rrrCr�rGr�rrr�r�r�r�Zpage�htmlr�r�)r!rErFr9Zmethod_infoZ
documenterZ
documentationrrr�generate_html_documentationOs8	

			z.XMLRPCDocGenerator.generate_html_documentationN)r$rSrTr"r�r�r�r�rrrrr�1s
r�c@seZdZdd�ZdS)�DocXMLRPCRequestHandlercCs�|j�s|j�dS|jj�jd�}|jd�|jdd�|jdtt|���|j	�|j
j|�dS)Nzutf-8rlzContent-typez	text/htmlzContent-length)rerorvr�r4rwrxryrsr|rr�)r!r:rrr�do_GET�s


zDocXMLRPCRequestHandler.do_GETN)r$rSrTr�rrrrr��s
r�c@s.eZdZeddddddd�ZdS)�DocXMLRPCServerTFNc	Cs3tj||||||||�tj|�dS)N)r�r"r�)r!r�r�r�rrr�r rrrr"�s	zDocXMLRPCServer.__init__)r$rSrTr�r"rrrrr��s	r�c@s(eZdZdd�Zdd�ZdS)�DocCGIXMLRPCRequestHandlercCsn|j�jd�}td�tdt|��t�tjj�tjjj|�tjjj�dS)Nzutf-8zContent-Type: text/htmlzContent-Length: %d)	r�r4r�rsr2r�r�r�r�)r!r:rrrr��s

z%DocCGIXMLRPCRequestHandler.handle_getcCstj|�tj|�dS)N)r�r"r�)r!rrrr"�s
z#DocCGIXMLRPCRequestHandler.__init__N)r$rSrTr�r"rrrrr��sr��__main__c@s/eZdZdd�ZGdd�d�ZdS)�ExampleServicecCsdS)NZ42r)r!rrr�getData�szExampleService.getDatac@s"eZdZedd��ZdS)zExampleService.currentTimecCs
tjj�S)N)�datetimeZnowrrrr�getCurrentTime�sz)ExampleService.currentTime.getCurrentTimeN)r$rSrT�staticmethodr�rrrr�currentTime�sr�N)r$rSrTr�r�rrrrr��sr��	localhosti@cCs||S)Nr)�x�yrrr�<lambda>�sr��addrz&Serving XML-RPC on localhost port 8000zKIt is advisable to run this example server within a secure, closed network.z&
Keyboard interrupt received, exiting.).�
xmlrpc.clientrrrrrZhttp.serverrr�r�r�r2r�r�rIr�rzZfcntl�ImportErrorrrrrUr�r�r�r�ZHTMLDocr�r�r�r�r�r$r�r�rvr'�powr#r.r�Z
serve_forever�KeyboardInterruptZserver_close�exitrrrr�<module>ks\(
�
�	(ErQ			








?>