AlkantarClanX12

Your IP : 18.227.0.57


Current Path : /lib64/python3.8/xmlrpc/__pycache__/
Upload File :
Current File : //lib64/python3.8/xmlrpc/__pycache__/server.cpython-38.opt-1.pyc

U

e5d9��	@sdZddlmZmZmZmZmZddlmZddl	m
Z
ddlmZddl
Z
ddlZddlZddlZddlZddlZddlZddlZzddlZWnek
r�dZYnXd+dd	�Zd
d�ZGdd
�d
�ZGdd�de�ZGdd�deje�ZGdd�de�ZGdd�de�ZGdd�dej�Z Gdd�d�Z!Gdd�de�Z"Gdd�dee!�Z#Gdd�dee!�Z$e%d k�rddl&Z&Gd!d"�d"�Z'ed#��~Z(e(�)e*�e(�)d$d%�d&�e(j+e'�dd'�e(�,�e-d(�e-d)�ze(�.�Wn(e/k
�re-d*�e�0d�YnXW5QRXdS),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)�BaseHTTPRequestHandler)�partial)�	signatureNTcCsF|r|�d�}n|g}|D]&}|�d�r6td|��qt||�}q|S)aGresolve_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.8/xmlrpc/server.py�resolve_dotted_attribute|s

�rcs�fdd�t��D�S)zkReturns a list of attribute strings, found in the specified
    object, which represent callable attributescs(g|] }|�d�stt�|��r|�qS)r)r
�callabler)�.0�member�rrr�
<listcomp>�s
�z'list_public_methods.<locals>.<listcomp>)�dirrrrr�list_public_methods�src@speZdZdZddd�Zddd�Zddd	�Zd
d�Zdd
�Zddd�Z	dd�Z
dd�Zdd�Zdd�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
    FNcCs&i|_d|_||_|pd|_||_dS�N�utf-8)�funcs�instance�
allow_none�encoding�use_builtin_types��selfr#r$r%rrr�__init__�s

zSimpleXMLRPCDispatcher.__init__cCs||_||_dS)aRegisters 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"rrrr�register_instance�s!z(SimpleXMLRPCDispatcher.register_instancecCs2|dkrt|j|d�S|dkr$|j}||j|<|S)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�register_function�__name__r!)r'Zfunctionr*rrrr+�s
z(SimpleXMLRPCDispatcher.register_functioncCs|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'rrr� register_introspection_functions�s
�z7SimpleXMLRPCDispatcher.register_introspection_functionscCs|j�d|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_multicallr1rrr�register_multicall_functions�sz3SimpleXMLRPCDispatcher.register_multicall_functionscCs�zPt||jd�\}}|dk	r(|||�}n|�||�}|f}t|d|j|jd�}Wn�tk
r�}zt||j|jd�}W5d}~XYnNt��\}}	}
z$ttdd||	f�|j|jd�}W5d}}	}
XYnX|�	|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$�%s:%s�r$r#�xmlcharrefreplace)
rr%�	_dispatchrr#r$r�sys�exc_info�encode)r'�data�dispatch_method�path�params�method�response�fault�exc_type�	exc_value�exc_tbrrr�_marshaled_dispatch�s0�
��
z*SimpleXMLRPCDispatcher._marshaled_dispatchcCs^t|j���}|jdk	rVt|jd�r8|t|j���O}nt|jd�sV|tt|j��O}t|�S)zwsystem.listMethods() => ['add', 'subtract', 'multiple']

        Returns a list of the methods supported by the server.N�_listMethodsr9)�setr!�keysr"�hasattrrHr�sorted)r'�methodsrrrr.s
z)SimpleXMLRPCDispatcher.system_listMethodscCsdS)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_namerrrr//sz-SimpleXMLRPCDispatcher.system_methodSignaturecCs�d}||jkr|j|}nX|jdk	rrt|jd�r<|j�|�St|jd�srzt|j||j�}Wntk
rpYnX|dkr~dSt�|�SdS)z�system.methodHelp('add') => "Adds two integers together"

        Returns a string containing documentation for the specified method.N�_methodHelpr9�)	r!r"rKrOrrr�pydoc�getdoc)r'rNrArrrr0<s$

�z(SimpleXMLRPCDispatcher.system_methodHelpc
Cs�g}|D]�}|d}|d}z|�|�||�g�Wqtk
rj}z|�|j|jd��W5d}~XYqt��\}}}	z|�dd||fd��W5d}}}	XYqXq|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
methodNamer@)�	faultCode�faultStringNr5r6)�appendr9rrSrTr:r;)
r'Z	call_list�resultsZcallrNr@rCrDrErFrrrr3[s,
��
��z'SimpleXMLRPCDispatcher.system_multicallcCs�z|j|}Wntk
r"YnX|dk	r4||�Std|��|jdk	r�t|jd�rd|j�||�Szt|j||j�}Wntk
r�YnX|dk	r�||�Std|��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 supportedr9)	r!�KeyError�	Exceptionr"rKr9rrr)r'rAr@�funcrrrr9s*
�z SimpleXMLRPCDispatcher._dispatch)FNF)F)NN)NN)r,�
__module__�__qualname__�__doc__r(r)r+r2r4rGr.r/r0r3r9rrrrr�s�

$

)
$rc@sfeZdZdZdZdZdZdZe�	dej
ejB�Zdd�Z
d	d
�Zdd�Zd
d�Zdd�Zddd�ZdS)�SimpleXMLRPCRequestHandlerz�Simple XML-RPC request handler class.

    Handles all HTTP POST requests and attempts to decode them as
    XML-RPC requests.
    )�/z/RPC2ix���Tz�
                            \s* ([^\s;]+) \s*            #content-coding
                            (;\s* q \s*=\s* ([0-9\.]+))? #q
                            cCs^i}|j�dd�}|�d�D]<}|j�|�}|r|�d�}|rFt|�nd}|||�d�<q|S)NzAccept-EncodingrP�,�g�?r5)�headers�getr�	aepattern�match�group�float)r'�rZae�ere�vrrr�accept_encodings�s
z+SimpleXMLRPCRequestHandler.accept_encodingscCs|jr|j|jkSdSdS)NT)�	rpc_pathsr?r1rrr�is_rpc_path_valid�sz,SimpleXMLRPCRequestHandler.is_rpc_path_validc
Cs�|��s|��dSz�d}t|jd�}g}|rht||�}|j�|�}|sLqh|�|�|t|d�8}q,d�	|�}|�
|�}|dkr�WdS|j�|t
|dd�|j�}Wn�tk
�r6}zp|�d�t|jd��r|jj�r|�d	t|��t��}	t|	�d
d�d
�}	|�d|	�|�d
d�|��W5d}~XYn�X|�d�|�dd�|jdk	�r�t|�|jk�r�|���dd�}
|
�r�zt|�}|�dd�Wntk
�r�YnX|�d
tt|���|��|j�|�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.
        Ni�zcontent-lengthr_�r9i��_send_traceback_headerzX-exception�ASCII�backslashreplacezX-traceback�Content-length�0���Content-typeztext/xml�gziprzContent-Encoding) rm�
report_404�intrb�minZrfile�readrU�len�join�decode_request_content�serverrGrr?rX�
send_responserKro�send_header�str�	traceback�
format_excr<�end_headers�encode_thresholdrkrcr�NotImplementedError�wfile�write)r'Zmax_chunk_sizeZsize_remaining�LZ
chunk_size�chunkr=rBriZtrace�qrrr�do_POST�s`




�
�
z"SimpleXMLRPCRequestHandler.do_POSTcCs�|j�dd���}|dkr|S|dkrvz
t|�WStk
rT|�dd|�Yq�tk
rr|�dd�Yq�Xn|�dd|�|�dd	�|��dS)
Nzcontent-encodingZidentityrvi�zencoding %r not supported�zerror decoding gzip contentrrrs)	rbrc�lowerrr�r�
ValueErrorr�r�)r'r=r$rrrr}$s
z1SimpleXMLRPCRequestHandler.decode_request_contentcCsF|�d�d}|�dd�|�dtt|���|��|j�|�dS)Ni�sNo such pageruz
text/plainrr)rr�r�r{r�r�r��r'rBrrrrw5s
z%SimpleXMLRPCRequestHandler.report_404�-cCs|jjrt�|||�dS)z$Selectively log an accepted request.N)r~�logRequestsr�log_request)r'�code�sizerrrr�>sz&SimpleXMLRPCRequestHandler.log_requestN)r�r�)r,rZr[r\rlr�ZwbufsizeZdisable_nagle_algorithm�re�compile�VERBOSE�
IGNORECASErdrkrmr�r}rwr�rrrrr]�s
�G	r]c@s.eZdZdZdZdZedddddfdd�ZdS)�SimpleXMLRPCServeragSimple 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.
    TFNcCs,||_t�||||�tj�||||�dS�N)r�rr(�socketserver�	TCPServer�r'ZaddrZrequestHandlerr�r#r$Zbind_and_activater%rrrr(WszSimpleXMLRPCServer.__init__)r,rZr[r\Zallow_reuse_addressror]r(rrrrr�Ds	�r�c@s@eZdZdZedddddfdd�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
Cs2t�||||||||�i|_||_|p*d|_dSr)r�r(�dispatchersr#r$r�rrrr(hs�zMultiPathXMLRPCServer.__init__cCs||j|<|Sr��r�)r'r?�
dispatcherrrr�add_dispatcherrs
z$MultiPathXMLRPCServer.add_dispatchercCs
|j|Sr�r�)r'r?rrr�get_dispatchervsz$MultiPathXMLRPCServer.get_dispatchercCs|z|j|�|||�}Wn^t��dd�\}}z2ttdd||f�|j|jd�}|�|jd�}W5d}}XYnX|S)N�r5r6r7r8)	r�rGr:r;rrr$r#r<)r'r=r>r?rBrDrErrrrGys"
��z)MultiPathXMLRPCServer._marshaled_dispatch)NN)	r,rZr[r\r]r(r�r�rGrrrrr�`s�

r�c@s4eZdZdZddd�Zdd�Zdd	�Zd
d
d�ZdS)�CGIXMLRPCRequestHandlerz3Simple handler for XML-RPC data passed through CGI.FNcCst�||||�dSr�)rr(r&rrrr(�sz CGIXMLRPCRequestHandler.__init__cCsP|�|�}td�tdt|��t�tj��tjj�|�tjj��dS)zHandle a single XML-RPC requestzContent-Type: text/xml�Content-Length: %dN)rG�printr{r:�stdout�flush�bufferr�)r'�request_textrBrrr�
handle_xmlrpc�s

z%CGIXMLRPCRequestHandler.handle_xmlrpccCs�d}tj|\}}tjj|||d�}|�d�}td||f�tdtjj�tdt|��t�t	j
��t	j
j�
|�t	j
j��dS)z�Handle a single HTTP GET request.

        Default implementation indicates an error because
        XML-RPC uses the POST method.
        r�)r��message�explainr z
Status: %d %szContent-Type: %sr�N)rZ	responses�httpr~ZDEFAULT_ERROR_MESSAGEr<r�ZDEFAULT_ERROR_CONTENT_TYPEr{r:r�r�r�r�)r'r�r�r�rBrrr�
handle_get�s ��

z"CGIXMLRPCRequestHandler.handle_getc	Csz|dkr$tj�dd�dkr$|��nRzttj�dd��}Wnttfk
rVd}YnX|dkrltj�	|�}|�
|�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_)�os�environrcr�rxr��	TypeErrorr:�stdinrzr�)r'r�Zlengthrrr�handle_request�s�

z&CGIXMLRPCRequestHandler.handle_request)FNF)N)r,rZr[r\r(r�r�r�rrrrr��s

r�c@s>eZdZdZdiiifdd�Zdiiidfdd�Zdd�ZdS)	�
ServerHTMLDocz7Class used to generate pydoc HTML document for a serverNcCsZ|p|j}g}d}t�d�}|�||�}	|	s0�q:|	��\}
}|�||||
���|	��\}}
}}}}|
r�||��dd�}|�d||f�n�|r�dt|�}|�d|||�f�n~|r�dt|�}|�d|||�f�nV|||d�d	k�r|�|�	||||��n(|�r"|�d
|�n|�|�	||��|}q|�|||d���d�
|�S)
z�Mark up some plain text, given a context of symbols to look for.
        Each context dictionary maps object names to anchor names.rzM\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/r5�(zself.<strong>%s</strong>NrP)�escaper�r��search�spanrU�groups�replacerxZnamelinkr|)r'�textr�r!�classesrMrV�here�patternre�start�end�allZschemeZrfcZpepZselfdotr*Zurlrrr�markup�s6

zServerHTMLDoc.markupcCs�|r
|jpdd|}d}	d|�|�|�|�f}
t|�rHtt|��}nd}t|t�rp|dp`|}|dpld}n
t�|�}|
||	o�|�	d|	�}
|�
||j|||�}|o�d|}d	|
|fS)
z;Produce HTML documentation for a function or method object.rPr�z$<a name="%s"><strong>%s</strong></a>z(...)rr5z'<font face="helvetica, arial">%s</font>z<dd><tt>%s</tt></dd>z<dl><dt>%s</dt>%s</dl>
)r,r�rr�r	�
isinstance�tuplerQrRZgreyr��	preformat)r'�objectr*�modr!r�rMZclZanchorZnote�titleZargspecZ	docstringZdecl�docrrr�
docroutine�s2�

��zServerHTMLDoc.docroutinec	Cs�i}|��D] \}}d|||<||||<q|�|�}d|}|�|dd�}|�||j|�}	|	ohd|	}	|d|	}g}
t|���}|D]\}}|
�|j|||d��q�||�ddd	d
�	|
��}|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#eeaa77rP)
�itemsr�Zheadingr�r�rLrUr�Z
bigsectionr|)r'�server_nameZpackage_documentationrMZfdict�key�value�head�resultr��contentsZmethod_itemsrrr�	docservers*
�zServerHTMLDoc.docserver)r,rZr[r\r�r�r�rrrrr��s)�
r�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�XMLRPCDocGeneratorz�Generates documentation for an XML-RPC server.

    This class is designed as mix-in and should not
    be constructed directly.
    cCsd|_d|_d|_dS)NzXML-RPC Server DocumentationzGThis server exports the following methods through the XML-RPC protocol.)r��server_documentation�server_titler1rrrr(:s�zXMLRPCDocGenerator.__init__cCs
||_dS)z8Set the HTML title of the generated server documentationN)r�)r'r�rrr�set_server_titleBsz#XMLRPCDocGenerator.set_server_titlecCs
||_dS)z7Set the name of the generated HTML server documentationN)r�)r'r�rrr�set_server_nameGsz"XMLRPCDocGenerator.set_server_namecCs
||_dS)z3Set the documentation string for the entire server.N)r�)r'r�rrr�set_server_documentationLsz+XMLRPCDocGenerator.set_server_documentationc	Cs�i}|��D]�}||jkr&|j|}n�|jdk	r�ddg}t|jd�rT|j�|�|d<t|jd�rp|j�|�|d<t|�}|dkr�|}q�t|jd�s�zt|j|�}Wq�tk
r�|}Yq�Xq�|}n|||<qt	�}|�
|j|j|�}|�
t�|j�|�S)agenerate_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_argstringrrOr5)NNr9)r.r!r"rKr�rOr�rrr�r�r�r�Zpage�htmlr�r�)r'rMrNrAZmethod_infoZ
documenterZ
documentationrrr�generate_html_documentationQs<

�
�z.XMLRPCDocGenerator.generate_html_documentationN)	r,rZr[r\r(r�r�r�r�rrrrr�3sr�c@seZdZdZdd�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.
    cCsf|��s|��dS|j���d�}|�d�|�dd�|�dtt|���|�	�|j
�|�dS)�}Handles the HTTP GET request.

        Interpret all HTTP GET requests as requests for server
        documentation.
        Nr rtruz	text/htmlrr)rmrwr~r�r<rr�r�r{r�r�r�r�rrr�do_GET�s
zDocXMLRPCRequestHandler.do_GETN)r,rZr[r\r�rrrrr��s	r�c@s&eZdZdZedddddfdd�ZdS)�DocXMLRPCServerz�XML-RPC and HTML documentation server.

    Adds the ability to serve server documentation to the capabilities
    of SimpleXMLRPCServer.
    TFNc
Cs&t�||||||||�t�|�dSr�)r�r(r�r�rrrr(�s�zDocXMLRPCServer.__init__)r,rZr[r\r�r(rrrrr��s�r�c@s eZdZdZdd�Zdd�ZdS)�DocCGIXMLRPCRequestHandlerzJHandler for XML-RPC data and documentation requests passed through
    CGIcCsT|���d�}td�tdt|��t�tj��tjj�|�tjj��dS)r�r zContent-Type: text/htmlr�N)	r�r<r�r{r:r�r�r�r�r�rrrr��s
z%DocCGIXMLRPCRequestHandler.handle_getcCst�|�t�|�dSr�)r�r(r�r1rrrr(�s
z#DocCGIXMLRPCRequestHandler.__init__N)r,rZr[r\r�r(rrrrr��sr��__main__c@s"eZdZdd�ZGdd�d�ZdS)�ExampleServicecCsdS)NZ42rr1rrr�getData�szExampleService.getDatac@seZdZedd��ZdS)zExampleService.currentTimecCs
tj��Sr�)�datetimeZnowrrrr�getCurrentTime�sz)ExampleService.currentTime.getCurrentTimeN)r,rZr[�staticmethodr�rrrr�currentTime�sr�N)r,rZr[r�r�rrrrr��sr�)Z	localhosti@cCs||Sr�r)�x�yrrr�<lambda>�rnr��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)1r\Z
xmlrpc.clientrrrrrZhttp.serverr�	functoolsr�inspectr	r�r�r�r:r�r�rQr�Zfcntl�ImportErrorrrrr]r�r�r�r�ZHTMLDocr�r�r�r�r�r,r�r�r~r+�powr)r4r�Z
serve_forever�KeyboardInterrupt�exitrrrr�<module>shj

�,EbQ��