Beispiel #1
0
    def _marshaled_dispatch(self, data, dispatch_method=None):
        """override SimpleXMLRPCDispatcher._marshaled_dispatch() fault string"""

        try:
            import xmlrpc.client as client
            from xmlrpc.client import Fault
        except ImportError:
            import xmlrpclib as client
            from xmlrpclib import Fault

        params, method = client.loads(data)

        # generate response
        try:
            if dispatch_method is not None:
                response = dispatch_method(method, params)
            else:
                response = self._dispatch(method, params)
            # wrap response in a singleton tuple
            response = (response, )
            response = client.dumps(response, methodresponse=1)
        except Fault as fault:  # breaks 2.5 compatibility
            fault.faultString = print_exc_info()
            response = client.dumps(fault)
        except:
            # report exception back to server
            response = client.dumps(client.Fault(1, "\n%s" % print_exc_info()))

        return _b(response)
Beispiel #2
0
    def _marshaled_dispatch(self, data, dispatch_method=None):
        """override SimpleXMLRPCDispatcher._marshaled_dispatch() fault string"""

        try:
            import xmlrpc.client as client
            from xmlrpc.client import Fault
        except ImportError:
            import xmlrpclib as client
            from xmlrpclib import Fault

        params, method = client.loads(data)

        # generate response
        try:
            if dispatch_method is not None:
                response = dispatch_method(method, params)
            else:
                response = self._dispatch(method, params)
            # wrap response in a singleton tuple
            response = (response,)
            response = client.dumps(response, methodresponse=1)
        except Fault as fault: # breaks 2.5 compatibility
            fault.faultString = print_exc_info()
            response = client.dumps(fault)
        except:
            # report exception back to server
            response = client.dumps(
                client.Fault(1, "\n%s" % print_exc_info())
                )

        return _b(response)
Beispiel #3
0
 def onChild(pid, fromparent, toparent):
     try:
         response = self._server._marshaled_dispatch(data)
         self._sendResponse(response)
         line = _str(fromparent.readline())
         toparent.write(_b('done\n'))
         toparent.flush()
     except:
         logger(name='pathos.xmlrpc', level=30).error(print_exc_info())
     os._exit(0)
Beispiel #4
0
 def onChild(pid, fromparent, toparent):
     try:
         response = self._server._marshaled_dispatch(data)
         self._sendResponse(response)
         line = _str(fromparent.readline())
         toparent.write(_b('done\n'))
         toparent.flush()
     except:
         logger(name='pathos.xmlrpc', level=30).error(print_exc_info())
     os._exit(0)
Beispiel #5
0
    def _sendResponse(self, response):
        """ Write the XML-RPC response """

        response = _b(response)
        self.send_response(200)
        self.send_header("Content-type", "text/xml")
        self.send_header("Content-length", str(len(response)))
        self.end_headers()
        self.wfile.write(response)
        self.wfile.flush()
        self.connection.shutdown(1)
Beispiel #6
0
    def _sendResponse(self, response):
        """ Write the XML-RPC response """

        response = _b(response)
        self.send_response(200)
        self.send_header("Content-type", "text/xml")
        self.send_header("Content-length", str(len(response)))
        self.end_headers()
        self.wfile.write(response)
        self.wfile.flush()
        self.connection.shutdown(1)
Beispiel #7
0
 def onParent(pid, fromchild, tochild):
     self._server._registerChild(pid, fromchild)
     tochild.write(_b('done\n'))
     tochild.flush()
Beispiel #8
0
 def onParent(pid, fromchild, tochild):
     self._server._registerChild(pid, fromchild)
     tochild.write(_b('done\n'))
     tochild.flush()
Beispiel #9
0
 def onChild(pid, fromparent, toparent):
     toparent.write(_b('hello dad\n'))
     toparent.flush()
     s = _str(fromparent.readline())
     print(s, end='')
     os._exit(0)
Beispiel #10
0
 def onParent(pid, fromchild, tochild):
     s = _str(fromchild.readline())
     print(s, end='')
     tochild.write(_b('hello son\n'))
     tochild.flush()
     os.wait()
Beispiel #11
0
 def onChild(pid, fromparent, toparent):
     toparent.write(_b('hello dad\n'))
     toparent.flush()
     s = _str(fromparent.readline())
     print(s, end='')
     os._exit(0)
Beispiel #12
0
 def onParent(pid, fromchild, tochild):
     s = _str(fromchild.readline())
     print(s, end='')
     tochild.write(_b('hello son\n'))
     tochild.flush()
     os.wait()