当前位置: 首页>>代码示例>>Python>>正文


Python server.SimpleXMLRPCServer方法代码示例

本文整理汇总了Python中xmlrpc.server.SimpleXMLRPCServer方法的典型用法代码示例。如果您正苦于以下问题:Python server.SimpleXMLRPCServer方法的具体用法?Python server.SimpleXMLRPCServer怎么用?Python server.SimpleXMLRPCServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpc.server的用法示例。


在下文中一共展示了server.SimpleXMLRPCServer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _Open

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server 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

示例2: main

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def main(args=None):
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--address', '-a', default='0.0.0.0', help='the '
                        'address on which the server is listening (e.g., '
                        '"127.0.0.1", default "0.0.0.0").')
    parser.add_argument('--port', '-p', type=int, default=9002, help='the port'
                        ' on which the server is listening (default "9002").')
    args = parser.parse_args(args)

    logging.basicConfig(format="%(asctime)s %(levelname)s "
                               "%(filename)s:%(lineno)d %(message)s")

    LOG.setLevel(logging.INFO)

    LOG.info("psutil version %s at %s", psutil.__version__, psutil.__file__)

    server = SimpleXMLRPCServer((args.address, args.port))
    LOG.info("serving on %s:%d", args.address, args.port)
    server.register_introspection_functions()
    server.register_instance(MonHelperRPCInterface())
    server.serve_forever() 
开发者ID:GambitResearch,项目名称:suponoff,代码行数:23,代码来源:suponoff-monhelper.py

示例3: __init__

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def __init__(self, local=LOCAL, localport=LOCALPORT):
        self._local = local
        self._localport = localport
        LOG.debug("ServerThread.__init__")
        threading.Thread.__init__(self)

        # Create proxies to interact with CCU / Homegear
        LOG.debug("__init__: Registering RPC methods")
        self._rpcfunctions = RPCFunctions()

        # Setup server to handle requests from CCU / Homegear
        LOG.debug("ServerThread.__init__: Setting up server")
        self.server = SimpleXMLRPCServer((self._local, self._localport),
                                         requestHandler=RequestHandler,
                                         logRequests=False)
        self._localport = self.server.socket.getsockname()[1]
        self.server.register_introspection_functions()
        self.server.register_multicall_functions()
        LOG.debug("ServerThread.__init__: Registering RPC functions")
        self.server.register_instance(
            self._rpcfunctions, allow_dotted_names=True) 
开发者ID:danielperna84,项目名称:pyhomematic,代码行数:23,代码来源:vccu.py

示例4: __connect

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def __connect(self):
        """
        This function establishes a connection to Spacewalk.
        """
        #set api session and key
        try:
            self.api_session = Server(self.url)
            self.api_key = self.api_session.auth.login(self.username, self.password)
        except Fault as err:
            if err.faultCode == 2950:
                raise InvalidCredentialsException(
                    "Wrong credentials supplied: '%s'", err.faultString
                )
            else:
                raise SessionException(
                    "Generic remote communication error: '%s'", err.faultString
                ) 
开发者ID:stdevel,项目名称:katprep,代码行数:19,代码来源:SpacewalkAPIClient.py

示例5: rpc_thread

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def rpc_thread():
    """RPC Server to serve PATCH requests."""
    LOG.info(f"Starting RPC server. Port: {Config.SOURCES_CLIENT_RPC_PORT}")
    with SimpleXMLRPCServer(("0.0.0.0", Config.SOURCES_CLIENT_RPC_PORT), allow_none=True) as server:
        server.register_introspection_functions()
        server.register_instance(SourcesPatchHandler())
        server.serve_forever() 
开发者ID:project-koku,项目名称:koku,代码行数:9,代码来源:kafka_listener.py

示例6: start_daemon

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def start_daemon(self):
        self.server = SimpleXMLRPCServer((self.domain, self.rpc_port), RPCHandler)
        print("Listening on port %s..." % self.rpc_port)
        self.server.register_function(self.spawn, "spawn")
        self.server.register_function(self.start_worker, "start_worker")
        self.server.register_function(self.stop_worker, "stop_worker")
        self.server.serve_forever() 
开发者ID:honeynet,项目名称:droidbot,代码行数:9,代码来源:droidmaster.py

示例7: __init__

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def __init__(self, ip='localhost', port=8070):
        try:
            self.server = SimpleXMLRPCServer((ip, port), allow_none=True,
                                             logRequests=False)
            self._announcer = Announcer()
        except OSError as error:
            # If address already in use
            if error.errno == 98:
                raise Exception(
                    "Only one application instance can use this module")
            else:
                raise error

        self.server.register_introspection_functions()
        self.server.register_instance(RemoteDispatcher()) 
开发者ID:FrancescoCeruti,项目名称:linux-show-player,代码行数:17,代码来源:controller.py

示例8: __init__

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def __init__(self, port, context):
        self.__running = False
        logging.info('Setting up an RPC server on port %d', port)
        self.__server = SimpleXMLRPCServer(("localhost", port), logRequests=False, allow_none=True)
        self.__server.register_function(context['api']['show_settings'], 'show_settings')
        self.__server.register_function(context['api']['show_about'], 'show_about')
        self.__server.register_function(context['api']['enable_safeeyes'], 'enable_safeeyes')
        self.__server.register_function(context['api']['disable_safeeyes'], 'disable_safeeyes')
        self.__server.register_function(context['api']['take_break'], 'take_break')
        self.__server.register_function(context['api']['status'], 'status')
        self.__server.register_function(context['api']['quit'], 'quit') 
开发者ID:slgobinath,项目名称:SafeEyes,代码行数:13,代码来源:rpc.py

示例9: __init__

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def __init__(self, server_addr):
        threading.Thread.__init__(self)
        self.server = SimpleXMLRPCServer(server_addr)
        self.server.register_multicall_functions()
        self.server.register_function(add, 'add')
        self.server.register_function(subtract, 'subtract')
        self.server.register_function(multiply, 'multiply')
        self.server.register_function(divide, 'divide') 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:10,代码来源:7_2_multithreaded_multicall_xmlrpc_server.py

示例10: server_main

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def server_main():
    global spv

    logging_level = pyspv.WARNING
    if '-v' in sys.argv:
        logging_level = pyspv.INFO
    if '-vv' in sys.argv or '-vvv' in sys.argv:
        logging_level = pyspv.DEBUG

    spv = pyspv.pyspv('pyspv-simple-wallet', logging_level=logging_level, peer_goal=4, testnet=True, listen=('0.0.0.0', 8336))
                #relay_tx=False,

    rpc_server = SimpleXMLRPCServer((RPC_LISTEN_ADDRESS, RPC_LISTEN_PORT), allow_none=True)
    rpc_server.register_function(getnewaddress)
    rpc_server.register_function(getnewstealthaddress)
    rpc_server.register_function(getnewpubkey)
    rpc_server.register_function(getbalance)
    rpc_server.register_function(sendtoaddress)
    rpc_server.register_function(sendspendtoaddress)
    rpc_server.register_function(getinfo)
    rpc_server.register_function(listspends)
    rpc_server.register_function(dumppubkey)
    rpc_server.register_function(dumpprivkey)
    rpc_server.register_function(genmultisig)
    rpc_server.register_function(sendrawtransaction)

    try:
        rpc_server.serve_forever()
    except KeyboardInterrupt:
        pass

    spv.shutdown() # Async shutdown
    spv.join()     # Wait for shutdown to complete 
开发者ID:sarchar,项目名称:pyspv,代码行数:35,代码来源:simple-wallet.py

示例11: runOnThread

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def runOnThread(api):
    server = SimpleXMLRPCServer(("localhost", 8199), allow_none=True, logRequests=False)
    server.register_function(functools.partial(call_method, api), "call_method")
    server.register_function(functools.partial(call_threadsafe_method, api), "call_threadsafe_method")
    server.register_function(functools.partial(get_property, api), "get_property")
    server.register_function(functools.partial(set_property, api), "set_property")
    server.serve_forever()


# this will be called when Facade is imported. this allows the plug-in manager access to the api_broker.
# for this to work, Facade must be imported early in the startup process. 
开发者ID:nion-software,项目名称:nionswift,代码行数:13,代码来源:Facade.py

示例12: main

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def main(args):
    index = read_index(str(args.index.with_suffix(".idx")))
    index.nprobe = args.num_probes

    with args.index.with_suffix(".json").open() as fp:
        metadata = json.load(fp)

    def query(batch, n):
        feats = np.frombuffer(batch.data, dtype=np.float32)
        feats = rearrange(feats, "(n d) -> n d", d=args.dimension)
        assert len(feats.shape) == 2
        assert feats.shape[1] == args.dimension
        assert feats.dtype == np.float32

        dists, indices = index.search(feats, n)

        meta = [[metadata[i] for i in batch] for batch in indices]

        return dists.tolist(), indices.tolist(), meta

    with SimpleXMLRPCServer((args.host, args.port), logRequests=False) as server:
        server.register_function(query)

        try:
            print("⏳ Waiting for similarity calls on {}:{}".format(args.host, args.port), file=sys.stderr)
            server.serve_forever()
        except KeyboardInterrupt:
            print("\n⌛ Done", file=sys.stderr) 
开发者ID:moabitcoin,项目名称:ig65m-pytorch,代码行数:30,代码来源:server.py

示例13: __init__

# 需要导入模块: from xmlrpc import server [as 别名]
# 或者: from xmlrpc.server import SimpleXMLRPCServer [as 别名]
def __init__(self,
                 local=LOCAL,
                 localport=LOCALPORT,
                 remotes=REMOTES,
                 devicefile=DEVICEFILE,
                 paramsetfile=PARAMSETFILE,
                 interface_id=INTERFACE_ID,
                 eventcallback=False,
                 systemcallback=False,
                 resolveparamsets=False):
        LOG.debug("ServerThread.__init__")
        threading.Thread.__init__(self)

        # Member
        self._interface_id = interface_id
        self._local = local
        self._localport = int(localport)
        self._devicefile = devicefile
        self._paramsetfile = paramsetfile
        self.remotes = remotes
        self.eventcallback = eventcallback
        self.systemcallback = systemcallback
        self.resolveparamsets = resolveparamsets
        self.proxies = {}
        self.failed_inits = []

        self.createProxies()
        if not self.proxies:
            LOG.warning("No proxies available. Aborting.")
            raise Exception

        self._rpcfunctions = RPCFunctions(devicefile=self._devicefile,
                                          paramsetfile=self._paramsetfile,
                                          proxies=self.proxies,
                                          remotes=self.remotes,
                                          eventcallback=self.eventcallback,
                                          systemcallback=self.systemcallback,
                                          resolveparamsets=self.resolveparamsets)

        # Setup server to handle requests from CCU / Homegear
        LOG.debug("ServerThread.__init__: Setting up server")
        # class SimpleThreadedXMLRPCServer(ThreadingMixIn, SimpleXMLRPCServer):
        #     pass
        # self.server = SimpleThreadedXMLRPCServer((self._local, self._localport),
        #                                          requestHandler=RequestHandler,
        #                                          logRequests=False)
        self.server = SimpleXMLRPCServer((self._local, self._localport),
                                         requestHandler=RequestHandler,
                                         logRequests=False)
        self._localport = self.server.socket.getsockname()[1]
        self.server.register_introspection_functions()
        self.server.register_multicall_functions()
        LOG.debug("ServerThread.__init__: Registering RPC functions")
        self.server.register_instance(
            self._rpcfunctions, allow_dotted_names=True) 
开发者ID:danielperna84,项目名称:pyhomematic,代码行数:57,代码来源:_hm.py


注:本文中的xmlrpc.server.SimpleXMLRPCServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。