OwlCyberSecurity - MANAGER
Edit File: server.cpython-36.pyc
3 �QgK�������������������@���s��d�Z�ddlmZmZmZmZmZ�ddlmZ�ddl Z ddlZ ddlZddlZddl Z ddlZddlZddlZddlZyddlZW�n�ek r����dZY�nX�d*dd�Zdd ��ZG�d d��d�ZG�dd ��d e�ZG�dd��deje�ZG�dd��de�ZG�dd��de�ZG�dd��dej�ZG�dd��d�ZG�dd��de�ZG�dd��dee�Z G�dd��dee�Z!e"dk�r�ddl#Z#G�dd ��d �Z$ed+��~Z%e%j&e'��e%j&d#d$��d%��e%j(e$��dd&��e%j)���e*d'��e*d(��ye%j+���W�n(�e,k �r����e*d)��ej-d��Y�nX�W�dQ�R�X�dS�),a��XML-RPC Servers. This module can be used to create simple XML-RPC servers by creating a server and either installing functions, a class instance, or by extending the SimpleXMLRPCServer class. It can also be used to handle XML-RPC requests in a CGI environment using CGIXMLRPCRequestHandler. The Doc* classes can be used to create XML-RPC servers that serve pydoc-style documentation in response to HTTP GET requests. This documentation is dynamically generated based on the functions and methods registered with the server. A list of possible usage patterns follows: 1. Install functions: server = SimpleXMLRPCServer(("localhost", 8000)) server.register_function(pow) server.register_function(lambda x,y: x+y, 'add') server.serve_forever() 2. Install an instance: class MyFuncs: def __init__(self): # make all of the sys functions available through sys.func_name import sys self.sys = sys def _listMethods(self): # implement this method so that system.listMethods # knows to advertise the sys methods return list_public_methods(self) + \ ['sys.' + method for method in list_public_methods(self.sys)] def pow(self, x, y): return pow(x, y) def add(self, x, y) : return x + y server = SimpleXMLRPCServer(("localhost", 8000)) server.register_introspection_functions() server.register_instance(MyFuncs()) server.serve_forever() 3. Install an instance with custom dispatch method: class Math: def _listMethods(self): # this method must be present for system.listMethods # to work return ['add', 'pow'] def _methodHelp(self, method): # this method must be present for system.methodHelp # to work if method == 'add': return "add(2,3) => 5" elif method == 'pow': return "pow(x, y[, z]) => number" else: # By convention, return empty # string if no help is available return "" def _dispatch(self, method, params): if method == 'pow': return pow(*params) elif method == 'add': return params[0] + params[1] else: raise ValueError('bad method') server = SimpleXMLRPCServer(("localhost", 8000)) server.register_introspection_functions() server.register_instance(Math()) server.serve_forever() 4. Subclass SimpleXMLRPCServer: class MathServer(SimpleXMLRPCServer): def _dispatch(self, method, params): try: # We are forcing the 'export_' prefix on methods that are # callable through XML-RPC to prevent potential security # problems func = getattr(self, 'export_' + method) except AttributeError: raise Exception('method "%s" is not supported' % method) else: return func(*params) def export_add(self, x, y): return x + y server = MathServer(("localhost", 8000)) server.serve_forever() 5. CGI script: server = CGIXMLRPCRequestHandler() server.register_function(pow) server.handle_request() �����)�Fault�dumps�loads�gzip_encode�gzip_decode)�BaseHTTPRequestHandlerNTc�������������C���sJ���|r|j�d�}n|g}x.|D�]&}|jd�r8td|���qt|�|�}�qW�|�S�)aG��resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a '_'. If the optional allow_dotted_names argument is false, dots are not supported and this function operates similar to getattr(obj, attr). �.�_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���� r���c����������������s�����fdd�t����D��S�)zkReturns a list of attribute strings, found in the specified object, which represent callable attributesc����������������s*���g�|�]"}|j�d���rtt��|��r|�qS�)r ���)r����callabler ���)�.0�member)r���r���r���� <listcomp>����s����z'list_public_methods.<locals>.<listcomp>)�dir)r���r���)r���r����list_public_methods����s����r���c���������������@���sp���e�Zd�ZdZddd�Zddd�Zddd �Zd d��Zdd ��Zddd�Z dd��Z dd��Zdd��Zdd��Z dd��ZdS�)�SimpleXMLRPCDispatchera&��Mix-in class that dispatches XML-RPC requests. This class is used to register XML-RPC method handlers and then to dispatch them. This class doesn't need to be instanced directly when used by SimpleXMLRPCServer but it can be instanced when used by the MultiPathXMLRPCServer FNc�������������C���s&���i�|�_�d�|�_||�_|pd|�_||�_d�S�)Nzutf-8)�funcs�instance� allow_none�encoding�use_builtin_types)�selfr���r���r ���r���r���r����__init__����s ���� zSimpleXMLRPCDispatcher.__init__c�������������C���s���||�_�||�_dS�)a��Registers an instance to respond to XML-RPC requests. Only one instance can be installed at a time. If the registered instance has a _dispatch method then that method will be called with the name of the XML-RPC method and its parameters as a tuple e.g. instance._dispatch('add',(2,3)) If the registered instance does not have a _dispatch method then the instance will be searched to find a matching method and, if found, will be called. Methods beginning with an '_' are considered private and will not be called by SimpleXMLRPCServer. If a registered function matches an XML-RPC request, then it will be called instead of the registered instance. If the optional allow_dotted_names argument is true and the instance does not have a _dispatch method, method names containing dots are supported and resolved, as long as none of the name segments start with an '_'. *** SECURITY WARNING: *** Enabling the allow_dotted_names options allows intruders to access your module's global variables and may allow intruders to execute arbitrary code on your machine. Only use this option on a secure, closed network. N)r���r���)r!���r���r���r���r���r����register_instance����s����!z(SimpleXMLRPCDispatcher.register_instancec�������������C���s���|dkr|j�}||�j|<�dS�)z�Registers a function to respond to XML-RPC requests. The optional name argument can be used to set a Unicode name for the function. N)�__name__r���)r!���Zfunction�namer���r���r����register_function����s����z(SimpleXMLRPCDispatcher.register_functionc�������������C���s���|�j�j|�j|�j|�jd���dS�)z�Registers the XML-RPC introspection methods in the system namespace. see http://xmlrpc.usefulinc.com/doc/reserved.html )zsystem.listMethodszsystem.methodSignaturezsystem.methodHelpN)r����update�system_listMethods�system_methodSignature�system_methodHelp)r!���r���r���r���� register_introspection_functions����s���� z7SimpleXMLRPCDispatcher.register_introspection_functionsc�������������C���s���|�j�jd|�ji��dS�)z�Registers the XML-RPC multicall method in the system namespace. see http://www.xmlrpc.com/discuss/msgReader$1208zsystem.multicallN)r���r'����system_multicall)r!���r���r���r����register_multicall_functions����s����z3SimpleXMLRPCDispatcher.register_multicall_functionsc�������������C���s����yPt�||�jd�\}}|dk r(|||�}n|�j||�}|f}t|d|�j|�jd�}W�n��tk r��}�zt||�j|�jd�}W�Y�dd}~X�nN���tj��\}} } z$ttdd|| f��|�j|�jd�}W�dd�}�} } X�Y�nX�|j |�jd�S�) a���Dispatches an XML-RPC method from marshalled (XML) data. XML-RPC methods are dispatched from the marshalled (XML) data using the _dispatch method and the result is returned as marshalled data. For backwards compatibility, a dispatch function can be provided as an argument (see comment in SimpleXMLRPCRequestHandler.do_POST) but overriding the existing method through subclassing is the preferred means of changing method dispatch behavior. )r ���N����)Zmethodresponser���r���)r���r���z%s:%s)r���r����xmlcharrefreplace) r���r ���� _dispatchr���r���r���r����sys�exc_info�encode)r!����data�dispatch_method�path�params�method�response�fault�exc_type� exc_value�exc_tbr���r���r����_marshaled_dispatch����s&����z*SimpleXMLRPCDispatcher._marshaled_dispatchc�������������C���s^���t�|�jj���}|�jdk rVt|�jd�r8|t�|�jj���O�}nt|�jd�sV|t�t|�j��O�}t|�S�)zwsystem.listMethods() => ['add', 'subtract', 'multiple'] Returns a list of the methods supported by the server.N�_listMethodsr0���)�setr����keysr����hasattrr?���r����sorted)r!����methodsr���r���r���r(�����s���� z)SimpleXMLRPCDispatcher.system_listMethodsc�������������C���s���dS�)a#��system.methodSignature('add') => [double, int, int] Returns a list describing the signature of the method. In the above example, the add method takes two integers as arguments and returns a double result. This server does NOT support system.methodSignature.zsignatures not supportedr���)r!����method_namer���r���r���r)���)��s����z-SimpleXMLRPCDispatcher.system_methodSignaturec�������������C���s����d}||�j�kr|�j�|�}nX|�jdk rrt|�jd�r<|�jj|�S�t|�jd�sryt|�j||�j�}W�n�tk rp���Y�nX�|dkr~dS�tj|�S�dS�)z�system.methodHelp('add') => "Adds two integers together" Returns a string containing documentation for the specified method.N�_methodHelpr0�����) r���r���rB���rF���r���r���r����pydoc�getdoc)r!���rE���r8���r���r���r���r*���6��s"���� z(SimpleXMLRPCDispatcher.system_methodHelpc������� ������C���s����g�}x�|D�]�}|d�}|d�}y|j�|�j||�g��W�q �tk rl�}�z|j�|j|jd���W�Y�dd}~X�q ���tj��\}}} z|j�dd||f�d���W�dd�}�}} X�Y�q X�q W�|S�)z�system.multicall([{'methodName': 'add', 'params': [2, 2]}, ...]) => [[4], ...] Allows the caller to package multiple XML-RPC calls into a single request. See http://www.xmlrpc.com/discuss/msgReader$1208 Z methodNamer7���)� faultCode�faultStringNr.���z%s:%s)�appendr0���r���rJ���rK���r1���r2���) r!���Z call_list�resultsZcallrE���r7���r:���r;���r<���r=���r���r���r���r,���U��s$���� z'SimpleXMLRPCDispatcher.system_multicallc�������������C���s����y|�j�|�}W�n�tk r"���Y�nX�|dk r4||��S�td|���|�jdk r�t|�jd�rd|�jj||�S�yt|�j||�j�}W�n�tk r����Y�nX�|dk r�||��S�td|���dS�)a���Dispatches the XML-RPC method. XML-RPC calls are forwarded to a registered function that matches the called XML-RPC method name. If no such function exists then the call is forwarded to the registered instance, if available. If the registered instance has a _dispatch method then that method will be called with the name of the XML-RPC method and its parameters as a tuple e.g. instance._dispatch('add',(2,3)) If the registered instance does not have a _dispatch method then the instance will be searched to find a matching method and, if found, will be called. Methods beginning with an '_' are considered private and will not be called. Nzmethod "%s" is not supportedr0���) r����KeyError� Exceptionr���rB���r0���r���r���r���)r!���r8���r7����funcr���r���r���r0���y��s(���� z SimpleXMLRPCDispatcher._dispatch)FNF)F)N)NN)r$���� __module__�__qualname__�__doc__r"���r#���r&���r+���r-���r>���r(���r)���r*���r,���r0���r���r���r���r���r�������s���� $ ) $r���c���������������@���sf���e�Zd�ZdZdZdZdZdZej dej ejB��Zdd ��Z d d��Zdd ��Zdd��Zdd��Zddd�ZdS�)�SimpleXMLRPCRequestHandlerz�Simple XML-RPC request handler class. Handles all HTTP POST requests and attempts to decode them as XML-RPC requests. �/�/RPC2ix��r.���Tz� \s* ([^\s;]+) \s* #content-coding (;\s* q \s*=\s* ([0-9\.]+))? #q c�������������C���sb���i�}|�j�jdd�}xJ|jd�D�]<}|�jj|�}|r|jd�}|rHt|�nd}|||jd�<�qW�|S�)NzAccept-EncodingrG����,����g�������?r.���)�headers�getr ���� aepattern�match�group�float)r!����rZae�er\����vr���r���r����accept_encodings���s���� z+SimpleXMLRPCRequestHandler.accept_encodingsc�������������C���s���|�j�r|�j|�j�kS�dS�d�S�)NT)� rpc_pathsr6���)r!���r���r���r����is_rpc_path_valid���s����z,SimpleXMLRPCRequestHandler.is_rpc_path_validc�������������C���s���|�j���s|�j���dS�y�d}t|�jd��}g�}x>|rjt||�}|�jj|�}|sNP�|j|��|t|d��8�}q.W�dj |�}|�j |�}|dkr�dS�|�jj|t |�dd�|�j�}W�n��tk �r6�}�zp|�jd��t|�jd �o�|�jj�r|�jd t|���tj��} t| jdd�d�} |�jd | ��|�jdd��|�j���W�Y�dd}~X�n�X�|�jd��|�jdd��|�jdk �r�t|�|�jk�r�|�j��jdd�} | �r�yt|�}|�jdd��W�n�tk �r����Y�nX�|�jdtt|����|�j���|�jj|��dS�)z�Handles the HTTP POST request. Attempts to interpret all HTTP POST requests as XML-RPC calls, which are forwarded to the server's _dispatch method for handling. N� ���i���zcontent-lengthr.��������r0���i����_send_traceback_headerzX-exception�ASCII�backslashreplacezX-tracebackzContent-length�0�����zContent-typeztext/xml�gzipr���zContent-Encodingi�(��i�������) rd���� report_404�intrY����minZrfile�readrL����len�join�decode_request_content�serverr>���r ���r6���rO���� send_responserB���rg����send_header�str� traceback� format_excr3����end_headers�encode_thresholdrb���rZ���r����NotImplementedError�wfile�write)r!���Zmax_chunk_sizeZsize_remaining�LZ chunk_size�chunkr4���r9���r`���Ztrace�qr���r���r����do_POST���sX���� z"SimpleXMLRPCRequestHandler.do_POSTc�������������C���s����|�j�jdd�j��}|dkr|S�|dkrtyt|�S��tk rR���|�jdd|���Y�q��tk rp���|�jdd��Y�q�X�n|�jdd|���|�jdd ��|�j���d�S�) Nzcontent-encodingZidentityrl���i���zencoding %r not supportedi���zerror decoding gzip contentzContent-lengthrj���) rY���rZ����lowerr���r}���rv���� ValueErrorrw���r{���)r!���r4���r���r���r���r���rt�����s����z1SimpleXMLRPCRequestHandler.decode_request_contentc�������������C���sF���|�j�d��d}|�jdd��|�jdtt|����|�j���|�jj|��d�S�)Ni���s���No such pagezContent-typez text/plainzContent-length)rv���rw���rx���rr���r{���r~���r���)r!���r9���r���r���r���rn���/��s���� z%SimpleXMLRPCRequestHandler.report_404�-c�������������C���s���|�j�jrtj|�||��dS�)z$Selectively log an accepted request.N)ru����logRequestsr����log_request)r!����code�sizer���r���r���r����8��s����z&SimpleXMLRPCRequestHandler.log_requestN)rU���rV���rm���)r����r����)r$���rQ���rR���rS���rc���r|���ZwbufsizeZdisable_nagle_algorithm�re�compile�VERBOSE� IGNORECASEr[���rb���rd���r����rt���rn���r����r���r���r���r���rT������s���G rT���c���������������@���s.���e�Zd�ZdZdZdZedddddfdd�ZdS�)�SimpleXMLRPCServerag��Simple XML-RPC server. Simple XML-RPC server that allows functions and a single instance to be installed to handle requests. The default implementation attempts to dispatch XML-RPC calls to the functions or instance installed in the server. Override the _dispatch method inherited from SimpleXMLRPCDispatcher to change this behavior. TFNc�������������C���s,���||�_�tj|�|||��tjj|�|||��d�S�)N)r����r���r"����socketserver� TCPServer)r!����addr�requestHandlerr����r���r����bind_and_activater ���r���r���r���r"���Q��s����zSimpleXMLRPCServer.__init__)r$���rQ���rR���rS���Zallow_reuse_addressrg���rT���r"���r���r���r���r���r����>��s��� r����c���������������@���s@���e�Zd�ZdZedddddfdd�Zdd��Zd d ��Zd dd�ZdS�)�MultiPathXMLRPCServera\��Multipath XML-RPC Server This specialization of SimpleXMLRPCServer allows the user to create multiple Dispatcher instances and assign them to different HTTP request paths. This makes it possible to run two or more 'virtual XML-RPC servers' at the same port. Make sure that the requestHandler accepts the paths in question. TFNc���������� ���C���s2���t�j|�|||||||��i�|�_||�_|p*d|�_d�S�)Nzutf-8)r����r"����dispatchersr���r���)r!���r����r����r����r���r���r����r ���r���r���r���r"���b��s ���� zMultiPathXMLRPCServer.__init__c�������������C���s���||�j�|<�|S�)N)r����)r!���r6���Z dispatcherr���r���r����add_dispatcherl��s���� z$MultiPathXMLRPCServer.add_dispatcherc�������������C���s ���|�j�|�S�)N)r����)r!���r6���r���r���r����get_dispatcherp��s����z$MultiPathXMLRPCServer.get_dispatcherc�������������C���s|���y|�j�|�j|||�}W�n^���tj��d�d��\}}z2ttdd||f��|�j|�jd�}|j|�jd�}W�d�d��}}X�Y�nX�|S�)N����r.���z%s:%s)r���r���r/���) r����r>���r1���r2���r���r���r���r���r3���)r!���r4���r5���r6���r9���r;���r<���r���r���r���r>���s��s���� z)MultiPathXMLRPCServer._marshaled_dispatch)NN) r$���rQ���rR���rS���rT���r"���r����r����r>���r���r���r���r���r����Z��s���r����c���������������@���s4���e�Zd�ZdZddd�Zdd��Zdd ��Zd d d�ZdS�)�CGIXMLRPCRequestHandlerz3Simple handler for XML-RPC data passed through CGI.FNc�������������C���s���t�j|�|||��d�S�)N)r���r"���)r!���r���r���r ���r���r���r���r"������s����z CGIXMLRPCRequestHandler.__init__c�������������C���sP���|�j�|�}td��tdt|����t���tjj���tjjj|��tjjj���dS�)zHandle a single XML-RPC requestzContent-Type: text/xmlzContent-Length: %dN)r>����printrr���r1����stdout�flush�bufferr���)r!����request_textr9���r���r���r���� handle_xmlrpc���s���� z%CGIXMLRPCRequestHandler.handle_xmlrpcc�������������C���s����d}t�j|�\}}tjj|||d��}|jd�}td||f���tdtjj���tdt|����t���t j j���t j jj |��t j jj���dS�)z�Handle a single HTTP GET request. Default implementation indicates an error because XML-RPC uses the POST method. i���)r�����message�explainzutf-8z Status: %d %szContent-Type: %szContent-Length: %dN)r���Z responses�httpru���ZDEFAULT_ERROR_MESSAGEr3���r����ZDEFAULT_ERROR_CONTENT_TYPErr���r1���r����r����r����r���)r!���r����r����r����r9���r���r���r���� handle_get���s���� z"CGIXMLRPCRequestHandler.handle_getc�������������C���sz���|dkr$t�jjdd�dkr$|�j���nRytt�jjdd��}W�n�ttfk rV���d}Y�nX�|dkrltjj |�}|�j |��dS�)z�Handle a single XML-RPC request passed through a CGI post method. If no XML data is given then it is read from stdin. The resulting XML-RPC response is printed to stdout along with the correct HTTP headers. NZREQUEST_METHODZGETZCONTENT_LENGTHr.���rm���)�os�environrZ���r����ro���r����� TypeErrorr1����stdinrq���r����)r!���r����Zlengthr���r���r����handle_request���s���� z&CGIXMLRPCRequestHandler.handle_request)FNF)N)r$���rQ���rR���rS���r"���r����r����r����r���r���r���r���r�������s ��� r����c���������������@���s>���e�Zd�ZdZdi�i�i�fdd�Zdi�i�i�dfdd�Zdd��ZdS�) � ServerHTMLDocz7Class used to generate pydoc HTML document for a serverNc�������������C���s^��|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�) z�Mark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.r���zM\b((http|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?((?:\w|\.)+))\b�"z"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>NrG���)�escaper����r�����search�spanrL����groups�replacero���Znamelinkrs���)r!����textr����r����classesrD���rM����here�patternr\����start�end�all�schemeZrfcZpepZselfdotr%���Zurlr���r���r����markup���s8���� �zServerHTMLDoc.markupc�������������C���s$��|r |j�pdd�|�}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�|d�p�|}|d�p�d} n tj|�} | |�| o�|�jd | ���}|�j| |�j|||�}|�od |�}d||f�S�)z;Produce HTML documentation for a function or method object.rG���r����z$<a name="%s"><strong>%s</strong></a>r.���N)�annotations�formatvaluez(...)r���z'<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�tuplerH���rI���Zgreyr����� preformat)r!����objectr%����modr���r����rD���ZclZanchorZnote�titler����ZargspecZ docstringZdecl�docr���r���r���� docroutine���s<���� zServerHTMLDoc.docroutinec�������������C���s����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�)z1Produce HTML documentation for an XML-RPC server.z#-z)<big><big><strong>%s</strong></big></big>z#ffffffz#7799eez<tt>%s</tt>z <p>%s</p> )r���ZMethodsz#eeaa77rG���) �itemsr����Zheadingr����r����rC���rL���r����Z bigsectionrs���)r!����server_nameZpackage_documentationrD���Zfdict�key�value�head�resultr�����contentsZmethod_itemsr���r���r���� docserver$��s"���� zServerHTMLDoc.docserver)r$���rQ���rR���rS���r����r����r����r���r���r���r���r�������s ���),r����c���������������@���s8���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zd d��ZdS�) �XMLRPCDocGeneratorz�Generates documentation for an XML-RPC server. This class is designed as mix-in and should not be constructed directly. c�������������C���s���d|�_�d|�_d|�_d�S�)NzXML-RPC Server DocumentationzGThis server exports the following methods through the XML-RPC protocol.)r�����server_documentation�server_title)r!���r���r���r���r"���D��s����zXMLRPCDocGenerator.__init__c�������������C���s ���||�_�dS�)z8Set the HTML title of the generated server documentationN)r����)r!���r����r���r���r����set_server_titleL��s����z#XMLRPCDocGenerator.set_server_titlec�������������C���s ���||�_�dS�)z7Set the name of the generated HTML server documentationN)r����)r!���r����r���r���r����set_server_nameQ��s����z"XMLRPCDocGenerator.set_server_namec�������������C���s ���||�_�dS�)z3Set the documentation string for the entire server.N)r����)r!���r����r���r���r����set_server_documentationV��s����z+XMLRPCDocGenerator.set_server_documentationc�������������C���s ��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|�}W�q��tk r����|}Y�q�X�q�|}nds�t d��|||<�qW�t ��}|j|�j|�j |�}|jtj|�j�|�S�) a��generate_html_documentation() => html documentation for the server Generates HTML documentation for the server using introspection for installed functions and instances that do not implement the _dispatch method. Alternatively, instances can choose to implement the _get_method_argstring(method_name) method to provide the argument string used in the documentation and the _methodHelp(method_name) method to provide the help text used in the documentation.N�_get_method_argstringr���rF���r.���r0���zACould not find method in self.functions and no instance installed)NN)r(���r���r���rB���r����rF���r����r���r����AssertionErrorr����r����r����r����Zpage�htmlr����r����)r!���rD���rE���r8���Zmethod_infoZ documenterZ documentationr���r���r����generate_html_documentation[��s:���� z.XMLRPCDocGenerator.generate_html_documentationN) r$���rQ���rR���rS���r"���r����r����r����r����r���r���r���r���r����=��s���r����c���������������@���s���e�Zd�ZdZdd��ZdS�)�DocXMLRPCRequestHandlerz�XML-RPC and documentation request handler class. Handles all HTTP POST requests and attempts to decode them as XML-RPC requests. Handles all HTTP GET requests and interprets them as requests for documentation. c�������������C���sf���|�j���s|�j���dS�|�jj��jd�}|�jd��|�jdd��|�jdtt|����|�j ���|�j j|��dS�)z}Handles the HTTP GET request. Interpret all HTTP GET requests as requests for server documentation. Nzutf-8rk���zContent-typez text/htmlzContent-length)rd���rn���ru���r����r3���rv���rw���rx���rr���r{���r~���r���)r!���r9���r���r���r����do_GET���s���� zDocXMLRPCRequestHandler.do_GETN)r$���rQ���rR���rS���r����r���r���r���r���r�������s���r����c���������������@���s&���e�Zd�ZdZedddddfdd�ZdS�)�DocXMLRPCServerz�XML-RPC and HTML documentation server. Adds the ability to serve server documentation to the capabilities of SimpleXMLRPCServer. TFNc���������� ���C���s&���t�j|�|||||||��tj|���d�S�)N)r����r"���r����)r!���r����r����r����r���r���r����r ���r���r���r���r"������s����zDocXMLRPCServer.__init__)r$���rQ���rR���rS���r����r"���r���r���r���r���r�������s���r����c���������������@���s ���e�Zd�ZdZdd��Zdd��ZdS�)�DocCGIXMLRPCRequestHandlerzJHandler for XML-RPC data and documentation requests passed through CGIc�������������C���sT���|�j���jd�}td��tdt|����t���tjj���tjjj|��tjjj���dS�)z}Handles the HTTP GET request. Interpret all HTTP GET requests as requests for server documentation. zutf-8zContent-Type: text/htmlzContent-Length: %dN) r����r3���r����rr���r1���r����r����r����r���)r!���r9���r���r���r���r�������s���� z%DocCGIXMLRPCRequestHandler.handle_getc�������������C���s���t�j|���tj|���d�S�)N)r����r"���r����)r!���r���r���r���r"������s���� z#DocCGIXMLRPCRequestHandler.__init__N)r$���rQ���rR���rS���r����r"���r���r���r���r���r�������s���r�����__main__c���������������@���s"���e�Zd�Zdd��ZG�dd��d�ZdS�)�ExampleServicec�������������C���s���dS�)NZ42r���)r!���r���r���r����getData���s����zExampleService.getDatac���������������@���s���e�Zd�Zedd���ZdS�)zExampleService.currentTimec���������������C���s ���t�j�j��S�)N)�datetimeZnowr���r���r���r����getCurrentTime���s����z)ExampleService.currentTime.getCurrentTimeN)r$���rQ���rR����staticmethodr����r���r���r���r����currentTime���s���r����N)r$���rQ���rR���r����r����r���r���r���r���r�������s���r����� localhost�@��c�������������C���s���|�|�S�)Nr���)�x�yr���r���r����<lambda>���s����r�����add)r���z&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����).rS���Z xmlrpc.clientr���r���r���r���r���Zhttp.serverr���r����r����r����r1���r����r����rH���r����ry���Zfcntl�ImportErrorr���r���r���rT���r����r����r����r����ZHTMLDocr����r����r����r����r����r$���r����r����ru���r&����powr#���r-���r����Z serve_forever�KeyboardInterrupt�exitr���r���r���r����<module>f���s`��� ���,ErQ