當前位置: 首頁>>代碼示例>>Python>>正文


Python SimpleXMLRPCServer.SimpleXMLRPCServer方法代碼示例

本文整理匯總了Python中SimpleXMLRPCServer.SimpleXMLRPCServer方法的典型用法代碼示例。如果您正苦於以下問題:Python SimpleXMLRPCServer.SimpleXMLRPCServer方法的具體用法?Python SimpleXMLRPCServer.SimpleXMLRPCServer怎麽用?Python SimpleXMLRPCServer.SimpleXMLRPCServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SimpleXMLRPCServer的用法示例。


在下文中一共展示了SimpleXMLRPCServer.SimpleXMLRPCServer方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_basic

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def test_basic(self):
        # check that flag is false by default
        flagval = SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header
        self.assertEqual(flagval, False)

        # enable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        # test a call that shouldn't fail just as a smoke test
        try:
            p = xmlrpclib.ServerProxy(URL)
            self.assertEqual(p.pow(6,8), 6**8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:test_xmlrpc.py

示例2: test_fail_with_info

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def test_fail_with_info(self):
        # use the broken message class
        SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass

        # Check that errors in the server send back exception/traceback
        # info when flag is set
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        try:
            p = xmlrpclib.ServerProxy(URL)
            p.pow(6,8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e) and hasattr(e, "headers"):
                # We should get error info in the response
                expected_err = "invalid literal for int() with base 10: 'I am broken'"
                self.assertEqual(e.headers.get("x-exception"), expected_err)
                self.assertTrue(e.headers.get("x-traceback") is not None) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:20,代碼來源:test_xmlrpc.py

示例3: _Open

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def _Open(self, hostname, port):
    """Opens the RPC communication channel for clients.

    Args:
      hostname (str): hostname or IP address to connect to for requests.
      port (int): port to connect to for requests.

    Returns:
      bool: True if the communication channel was successfully opened.
    """
    try:
      self._xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer(
          (hostname, port), logRequests=False, allow_none=True)
    except SocketServer.socket.error as exception:
      logger.warning((
          'Unable to bind a RPC server on {0:s}:{1:d} with error: '
          '{2!s}').format(hostname, port, exception))
      return False

    self._xmlrpc_server.register_function(
        self._callback, self._RPC_FUNCTION_NAME)
    return True 
開發者ID:log2timeline,項目名稱:plaso,代碼行數:24,代碼來源:plaso_xmlrpc.py

示例4: main

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def main():
    autoWait()
    ea = ScreenEA()

    server = SimpleXMLRPCServer(("localhost", 9000))
    server.register_function(is_connected, "is_connected")

    server.register_function(wrapper_get_raw, "get_raw")
    server.register_function(wrapper_get_function, "get_function")
    server.register_function(wrapper_Heads, "Heads")
    server.register_function(wrapper_Functions, "Functions")

    server.register_instance(IDAWrapper())

    server.register_function(wrapper_quit, "quit")
    server.serve_forever()

    qexit(0) 
開發者ID:DroidTest,項目名稱:TimeMachine,代碼行數:20,代碼來源:idawrapper.py

示例5: main

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def main() :
    autoWait()
    ea = ScreenEA()

    server = SimpleXMLRPCServer(("localhost", 9000))
    server.register_function(is_connected, "is_connected")
    
    server.register_function(wrapper_get_raw, "get_raw")
    server.register_function(wrapper_get_function, "get_function")
    server.register_function(wrapper_Heads, "Heads")
    server.register_function(wrapper_Functions, "Functions")
    
    server.register_instance(IDAWrapper())
    
    server.register_function(wrapper_quit, "quit")
    server.serve_forever()

    qexit(0) 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:20,代碼來源:idawrapper.py

示例6: start_lobotomy

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def start_lobotomy(bv):
    """
    Start the lobotomy service
    """
    # Locals
    HOST = "127.0.0.1"
    PORT = 6666
    rpc = None

    try:
        # Create a new SimpleXMLRPCServer instance with the
        # LobotomyRequestHandler
        rpc = SimpleXMLRPCServer((HOST, PORT),
                                 requestHandler=LobotomyRequestHandler,
                                 logRequests=False,
                                 allow_none=True)
        # Register the Lobotomy class
        rpc.register_instance(Lobotomy(rpc, bv))
        print("[*] Started lobotomy service (!)")
        while True:
            # Handle inbound requests
            rpc.handle_request()
    except Exception as e:
        ExceptionHandler(e) 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:26,代碼來源:binja_lobotomy.py

示例7: start_xmlrpc_server

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def start_xmlrpc_server():
    """
    Initialize the XMLRPC thread
    """
    print("[+] Starting XMLRPC server: {}:{}".format(HOST, PORT))
    server = SimpleXMLRPCServer((HOST, PORT),
                                requestHandler=RequestHandler,
                                logRequests=False,
                                allow_none=True)
    server.register_introspection_functions()
    server.register_instance( Gef(server) )
    print("[+] Registered {} functions.".format( len(server.system_listMethods()) ))
    while True:
        if hasattr(server, "shutdown") and server.shutdown==True:
            break
        server.handle_request()

    return 
開發者ID:gatieme,項目名稱:GdbPlugins,代碼行數:20,代碼來源:ida_gef.py

示例8: listen

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def listen(self, addr):
        """Starts the RPC server on the addrress.

        Args:
            addr: The tuple of listening address and port.

        Raises:
            RuntimeError: If the server is already running.
        """
        if not self.__done:
            raise RuntimeError('server is already running')

        self.__done = False
        # SimpleXMLRPCServer, by default, is IPv4 only. So we do some surgery.
        SocketServer.TCPServer.address_family = self.__ip_mode
        server = SimpleXMLRPCServer.SimpleXMLRPCServer(addr, allow_none=True)
        server.register_instance(self)
        while not self.__done:
            server.handle_request() 
開發者ID:google,項目名稱:transperf,代碼行數:21,代碼來源:recv.py

示例9: setUp

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def setUp(self):
        # enable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        self.evt = threading.Event()
        # start server thread to handle requests
        serv_args = (self.evt, self.request_count, self.requestHandler)
        threading.Thread(target=self.threadFunc, args=serv_args).start()

        # wait for the server to be ready
        self.evt.wait(10)
        self.evt.clear() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:14,代碼來源:test_xmlrpc.py

示例10: tearDown

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def tearDown(self):
        # wait on the server thread to terminate
        self.evt.wait(10)

        # disable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = False

# NOTE: The tests in SimpleServerTestCase will ignore failures caused by
# "temporarily unavailable" exceptions raised in SimpleXMLRPCServer.  This
# condition occurs infrequently on some platforms, frequently on others, and
# is apparently caused by using SimpleXMLRPCServer with a non-blocking socket
# If the server class is updated at some point in the future to handle this
# situation more gracefully, these tests should be modified appropriately. 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_xmlrpc.py

示例11: test_introspection4

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def test_introspection4(self):
        # the SimpleXMLRPCServer doesn't support signatures, but
        # at least check that we can try making the call
        try:
            p = xmlrpclib.ServerProxy(URL)
            divsig = p.system.methodSignature('div')
            self.assertEqual(divsig, 'signatures not supported')
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:14,代碼來源:test_xmlrpc.py

示例12: test_dotted_attribute

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def test_dotted_attribute(self):
        # Raises an AttributeError because private methods are not allowed.
        self.assertRaises(AttributeError,
                          SimpleXMLRPCServer.resolve_dotted_attribute, str, '__add')

        self.assertTrue(SimpleXMLRPCServer.resolve_dotted_attribute(str, 'title'))
        # Get the test to run faster by sending a request with test_simple1.
        # This avoids waiting for the socket timeout.
        self.test_simple1() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_xmlrpc.py

示例13: test_fail_no_info

# 需要導入模塊: import SimpleXMLRPCServer [as 別名]
# 或者: from SimpleXMLRPCServer import SimpleXMLRPCServer [as 別名]
def test_fail_no_info(self):
        # use the broken message class
        SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass

        try:
            p = xmlrpclib.ServerProxy(URL)
            p.pow(6,8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e) and hasattr(e, "headers"):
                # The two server-side error headers shouldn't be sent back in this case
                self.assertTrue(e.headers.get("X-exception") is None)
                self.assertTrue(e.headers.get("X-traceback") is None) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_xmlrpc.py


注:本文中的SimpleXMLRPCServer.SimpleXMLRPCServer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。