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


Python DocXMLRPCServer.set_server_title方法代码示例

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


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

示例1: __init__

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import set_server_title [as 别名]
class XMLRPCServer:
  def __init__(self, host, port, logic):
    """Initialise XMLRPC"""
    #Create XMLRPC server with functions from XMLRPCInterface class below
    self.rpcserver = DocXMLRPCServer((host, port), logRequests=0)
    self.rpcserver.register_instance(XMLRPCInterface(logic))
    
    self.port = port
    
    #Set up documentation interface properties
    self.rpcserver.set_server_title("Truemix XMLRPC API")
    self.rpcserver.set_server_name("Truemix XMLRPC API Documentation")
    self.rpcserver.set_server_documentation(
      "Truemix is a radio automation system with a server/client"
      " organisation. This XMLRPC API allows you to write your own"
      " applications that connect with the Truemix backend server."
      )
      
  def start_serving(self):
    try:
      #Advertise the service with avahi and dbus
      bus = dbus.SystemBus()
      server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
      
      g = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.EntryGroupNew()), avahi.DBUS_INTERFACE_ENTRY_GROUP)
      g.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, dbus.UInt32(0), "Truemix Server", "_truemix-xmlrpc._tcp", "", "", dbus.UInt16(self.port), "")
      g.Commit()
    except dbus.exceptions.DBusException:
      #Unable to advertise server
      pass
    
    #Start the xmlrpc server
    self.rpcserver.serve_forever()
开发者ID:andrewgee,项目名称:truemix,代码行数:35,代码来源:XMLRPCServer.py

示例2: make_server

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import set_server_title [as 别名]
def make_server():
    serv = DocXMLRPCServer(("localhost", 0), logRequests=False)

    try:
        # Add some documentation
        serv.set_server_title("DocXMLRPCServer Test Documentation")
        serv.set_server_name("DocXMLRPCServer Test Docs")
        serv.set_server_documentation(
            "This is an XML-RPC server's documentation, but the server "
            "can be used by POSTing to /RPC2. Try self.add, too.")

        # Create and register classes and functions
        class TestClass(object):
            def test_method(self, arg):
                """Test method's docs. This method truly does very little."""
                self.arg = arg

        serv.register_introspection_functions()
        serv.register_instance(TestClass())

        def add(x, y):
            """Add two instances together. This follows PEP008, but has nothing
            to do with RFC1952. Case should matter: pEp008 and rFC1952.  Things
            that start with http and ftp should be auto-linked, too:
            http://google.com.
            """
            return x + y

        serv.register_function(add)
        serv.register_function(lambda x, y: x-y)
        return serv
    except:
        serv.server_close()
        raise
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:36,代码来源:test_docxmlrpc.py

示例3: APIService

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import set_server_title [as 别名]
class APIService ( threading.Thread ):
    
    
    @trace
    def __init__(self, pid, passive, active, background, debug, port, hostname) :
        super(APIService, self).__init__()
        
        self._stop = threading.Event()
        self.pid = pid
        self.abort = False
        self.aborted = False
        self.port = port 
        self.hostname = hostname 
        self.api = API(pid, passive, active, background, port, debug)
        cbdebug("Initializing API Service on " + hostname + ":" + str(port))
        if debug is None :
            self.server = AsyncDocXMLRPCServer((self.hostname, int(self.port)), allow_none = True)
        else :
            self.server = DocXMLRPCServer((self.hostname, int(self.port)), allow_none = True)
        self.server.abort = False
        self.server.aborted = False
        self.server.set_server_title("API Service (xmlrpc)")
        self.server.set_server_name("API Service (xmlrpc)")
        #self.server.register_introspection_functions()
        self.api.signatures = {}
        for methodtuple in inspect.getmembers(self.api, predicate=inspect.ismethod) :
            name = methodtuple[0]
            if name in ["__init__", "success", "error", "migrate" ] :
                continue
            func = getattr(self.api, name)
            argspec = inspect.getargspec(func) 
            spec = argspec[0]
            defaults = [] if argspec[3] is None else argspec[3]
            num_spec = len(spec)
            num_defaults = len(defaults)
            diff = num_spec - num_defaults
            named = diff - 1
            doc = "Usage: "
            for x in range(1, diff) :
                doc += spec[x] + ", "
            for x in range(diff, num_spec) :
                doc += spec[x] + " = " + str(defaults[x - diff]) + ", "
            doc = doc[:-2]
            self.api.signatures[name] = {"args" : spec[1:], "named" : named }
            self.server.register_function(unwrap_kwargs(func, doc), name)
#        self.server.register_instance(self.api)
        cbdebug("API Service started")

    @trace
    def run(self):
        cbdebug("API Service waiting for requests...")
        self.server.serve_forever()
        cbdebug("API Service shutting down...")
        
    @trace
    def stop (self) :
        cbdebug("Calling API Service shutdown....")
        self._stop.set()
        self.server.shutdown()
开发者ID:lmeyemezu,项目名称:cbtool,代码行数:61,代码来源:api_service.py

示例4: testserver

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import set_server_title [as 别名]
def testserver():

    class ThreadingServer(ThreadingMixIn,DocXMLRPCServer):
        pass

    server = DocXMLRPCServer(('localhost',8888),DocXMLRPCRequestHandler,allow_none=True)
    server.set_server_title("Chapter 18 document")
    server.set_server_name("chapter")
    server.set_server_documentation("""welcome""")
    server.register_instance(Math())
    server.register_introspection_functions()
    server.register_function(int)
    server.register_function(list.sort)
开发者ID:huangnauh,项目名称:learnpython,代码行数:15,代码来源:cgi108.py

示例5: server

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import set_server_title [as 别名]
def server(evt, numrequests):
    serv = DocXMLRPCServer(("localhost", 0), logRequests=False)

    try:
        global PORT
        PORT = serv.socket.getsockname()[1]

        # Add some documentation
        serv.set_server_title("DocXMLRPCServer Test Documentation")
        serv.set_server_name("DocXMLRPCServer Test Docs")
        serv.set_server_documentation(
            """This is an XML-RPC server's documentation, but the server can be used by
POSTing to /RPC2. Try self.add, too."""
        )

        # Create and register classes and functions
        class TestClass(object):
            def test_method(self, arg):
                """Test method's docs. This method truly does very little."""
                self.arg = arg

        serv.register_introspection_functions()
        serv.register_instance(TestClass())

        def add(x, y):
            """Add two instances together. This follows PEP008, but has nothing
            to do with RFC1952. Case should matter: pEp008 and rFC1952.  Things
            that start with http and ftp should be auto-linked, too:
            http://google.com.
            """
            return x + y

        serv.register_function(add)
        serv.register_function(lambda x, y: x - y)

        while numrequests > 0:
            serv.handle_request()
            numrequests -= 1
    except socket.timeout:
        pass
    finally:
        serv.server_close()
        PORT = None
        evt.set()
开发者ID:Cinnz,项目名称:python,代码行数:46,代码来源:test_docxmlrpc.py

示例6: APIService

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import set_server_title [as 别名]
class APIService ( threading.Thread ):
    
    @trace
    def __init__(self, pid, passive, active, background, debug, port, hostname) :
        super(APIService, self).__init__()
        self._stop = threading.Event()
        self.pid = pid
        self.abort = False
        self.aborted = False
        self.port = port 
        self.hostname = hostname 
        self.api = API(pid, passive, active, background)
        cbdebug("Initializing API Service on port " + str(self.port))
        if debug is None :
            self.server = AsyncDocXMLRPCServer((self.hostname, int(self.port)), allow_none = True)
        else :
            self.server = DocXMLRPCServer((self.hostname, int(self.port)), allow_none = True)
        self.server.abort = False
        self.server.aborted = False
        self.server.set_server_title("API Service (xmlrpc)")
        self.server.set_server_name("API Service (xmlrpc)")
        #self.server.register_introspection_functions()
        self.server.register_instance(self.api)
        cbdebug("API Service started")

    @trace
    def run(self):
        cbdebug("API Service waiting for requests...")
        self.server.serve_forever()
        cbdebug("API Service shutting down...")
        
    @trace
    def stop (self) :
        cbdebug("Calling API Service shutdown....")
        self._stop.set()
        self.server.shutdown()
开发者ID:Minsukk,项目名称:cbtool,代码行数:38,代码来源:api_service.py


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