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


Python DocXMLRPCServer.DocXMLRPCServer类代码示例

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


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

示例1: START

def START():
    host = "localhost"
    host2 = "192.168.178.14"
    hos2t = "192.168.16.20"
    print("Listen host:" + host)
    server = DocXMLRPCServer((host, 8080), RequestHandler)
    server.serve_forever()
开发者ID:rajeshpillai,项目名称:zebra,代码行数:7,代码来源:startup.py

示例2: __init__

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,代码行数:33,代码来源:XMLRPCServer.py

示例3: APIService

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,代码行数:59,代码来源:api_service.py

示例4: __init__

    def __init__(self, addr):
        DocXMLRPCServer.__init__(self, addr, logRequests=True)
        self.register_introspection_functions()
        self.allow_none = True
        self.set_server_title('ZDStack')
        self.set_server_name('ZDStack XML-RPC API')
        self.set_server_documentation("""\
This is the documentation for the ZDStack XML-RPC API.  For more information, visit
http://zdstack.googlecode.com.""")
开发者ID:camgunz,项目名称:zdstack,代码行数:9,代码来源:XMLRPCServer.py

示例5: __init__

	def __init__(self, registerInstance, server_address, keyFile=DEFAULTKEYFILE, certFile=DEFAULTCERTFILE, logRequests=True):
		"""Secure Documenting XML-RPC server.
		It it very similar to DocXMLRPCServer but it uses HTTPS for transporting XML data.
		"""
		DocXMLRPCServer.__init__(self, server_address, SecureDocXMLRpcRequestHandler, logRequests,True)
		self.logRequests = logRequests

		# stuff for doc server
		try: self.set_server_title(registerInstance.title)
		except AttributeError: self.set_server_title('N4D Documentation page')
		try: self.set_server_name(registerInstance.name)
		except AttributeError: self.set_server_name('N4D')
		#for plugin in registerInstace
		if registerInstance.__doc__: self.set_server_documentation(registerInstance.__doc__)
		else: self.set_server_documentation('default documentation')
		
		
		#self.register_introspection_functions()
		
		# init stuff, handle different versions:
		try:
			SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self,allow_none=True)
		except TypeError:
			# An exception is raised in Python 2.5 as the prototype of the __init__
			# method has changed and now has 3 arguments (self, allow_none, encoding)
			SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self, allow_none=True, encoding=None)
		SocketServer.BaseServer.__init__(self, server_address, SecureDocXMLRpcRequestHandler)
		self.register_instance(registerInstance) # for some reason, have to register instance down here!

		# SSL socket stuff
		ctx = SSL.Context(SSL.SSLv23_METHOD)
		ctx.use_privatekey_file(keyFile)
		ctx.use_certificate_file(certFile)
		self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
		
		old = fcntl.fcntl(self.socket.fileno(), fcntl.F_GETFD)	
		fcntl.fcntl(self.socket.fileno(), fcntl.F_SETFD, old | fcntl.FD_CLOEXEC)	
		
		self.server_bind()
		self.server_activate()

		# requests count and condition, to allow for keyboard quit via CTL-C
		self.requests = 0
		self.rCondition = Condition()
开发者ID:raurodse,项目名称:N4D,代码行数:44,代码来源:server.py

示例6: __init__

 def __init__(self, users_auth, addr, timeout=0.5, *args, **kargs):
     # we use an inner class so that we can call out to the
     # authenticate method
     class VerifyingRequestHandler(DocXMLRPCRequestHandler):
         def parse_request(myself):
             # first, call the original implementation which returns
             # True if all OK so far
             if DocXMLRPCRequestHandler.parse_request(myself):
                 # next we authenticate
                 if self.authenticate(myself.headers):
                     return True
                 else:
                     # if authentication fails, tell the client
                     myself.send_error(401, 'Authentication failed')
             return False
     self._users_auth = users_auth
     self._finished = False
     self.timeout = timeout
     DocXMLRPCServer.__init__(self, addr, *args, requestHandler=VerifyingRequestHandler, **kargs)
开发者ID:mabl,项目名称:nanowrite_wrapper,代码行数:19,代码来源:nanowrite_server.py

示例7: start

def start( address, scheduler, debug=False ):
    global count

    if debug:
        s = DocXMLRPCServer( address, allow_none=True )
        s.register_introspection_functions()
    else:
        s = SimpleXMLRPCServer( address, allow_none=True )
    handler = RPCHandler( scheduler )
    s.register_multicall_functions()
    s.register_instance( handler )
    s.thread = threading.Thread( name="RPC", target=s.serve_forever )
    s.thread.daemon = True
    s.thread.start()
    logging.info( "rpc interface started" )
    return s, s.thread, handler
开发者ID:koenbollen,项目名称:pollbuster,代码行数:16,代码来源:rpc.py

示例8: __init__

    def __init__(self, debug, port, hostname):
        super(MLLSlaveService, self).__init__()

        self._stop = Event()
        self.abort = False
        self.aborted = False
        self.port = port
        self.hostname = hostname
        self.slave = MLLSlave(port, debug)
        mdebug("Initializing MLL Slave 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("MLL Slave Service (xmlrpc)")
        self.server.set_server_name("MLL Slave Service (xmlrpc)")
        # self.server.register_introspection_functions()
        self.slave.signatures = {}
        for methodtuple in getmembers(self.slave, predicate=ismethod):
            name = methodtuple[0]
            if name in ["__init__", "success", "error"]:
                continue
            func = getattr(self.slave, name)
            argspec = 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.slave.signatures[name] = {"args": spec[1:], "named": named}
            self.server.register_function(unwrap_kwargs(func, doc), name)
        mdebug("MLL Slave Service started")
开发者ID:hinesmr,项目名称:mica,代码行数:41,代码来源:slave.py

示例9: __init__

 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")
开发者ID:Minsukk,项目名称:cbtool,代码行数:21,代码来源:api_service.py

示例10: __init__

    def __init__(self, registerInstance, server_address, keyFile=DEFAULTKEYFILE, certFile=DEFAULTCERTFILE, logRequests=True):
        """Secure Documenting XML-RPC server.
        It it very similar to DocXMLRPCServer but it uses HTTPS for transporting XML data.
        """
        DocXMLRPCServer.__init__(self, server_address, SecureDocXMLRpcRequestHandler, logRequests)
        self.logRequests = logRequests

        # stuff for doc server
        try: self.set_server_title(registerInstance.title)
        except AttributeError: self.set_server_title('default title')
        try: self.set_server_name(registerInstance.name)
        except AttributeError: self.set_server_name('default name')
        if registerInstance.__doc__: self.set_server_documentation(registerInstance.__doc__)
        else: self.set_server_documentation('default documentation')
        self.register_introspection_functions()

        # init stuff, handle different versions:
        try:
            SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self)
        except TypeError:
            # An exception is raised in Python 2.5 as the prototype of the __init__
            # method has changed and now has 3 arguments (self, allow_none, encoding)
            SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self, False, None)
        SocketServer.BaseServer.__init__(self, server_address, SecureDocXMLRpcRequestHandler)
        self.register_instance(registerInstance) # for some reason, have to register instance down here!

        # SSL socket stuff
        ctx = SSL.Context(SSL.SSLv23_METHOD)
        ctx.use_privatekey_file(keyFile)
        ctx.use_certificate_file(certFile)
        # verify
        ctx.load_verify_locations('cert/rpc-ca.crt')
        ctx.set_verify(SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT, self._verify)
        self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
        self.server_bind()
        self.server_activate()

        # requests count and condition, to allow for keyboard quit via CTL-C
        self.requests = 0
        self.rCondition = Condition()
开发者ID:hizel,项目名称:twistsnmp,代码行数:40,代码来源:mainsrv.py

示例11: __init__

	def __init__(self, registerInstance, server_address, logRequests=True):
		"""Secure Documenting XML-RPC server.
		It it very similar to DocXMLRPCServer but it uses HTTPS for transporting XML data.
		"""
		DocXMLRPCServer.__init__(self, server_address, RPCHandler, logRequests)
		self.logRequests = logRequests

		# stuff for doc server
		try: self.set_server_title(registerInstance.title)
		except AttributeError: self.set_server_title('default title')
		try: self.set_server_name(registerInstance.name)
		except AttributeError: self.set_server_name('default name')
		if registerInstance.__doc__: self.set_server_documentation(registerInstance.__doc__)
		else: self.set_server_documentation('default documentation')
		self.register_introspection_functions()

		# init stuff, handle different versions:
		try:
			SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self)
		except TypeError:
			# An exception is raised in Python 2.5 as the prototype of the __init__
			# method has changed and now has 3 arguments (self, allow_none, encoding)
			SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self, False, None)
		SocketServer.BaseServer.__init__(self, server_address, RPCHandler)
		self.register_instance(registerInstance) # for some reason, have to register instance down here!

		# SSL socket stuff
		ctx = SSL.Context(SSL.SSLv23_METHOD)
		keyfile = os.path.join(Config.djangoroot, Config.get("xmlrpc-server", "keyfile"))
		certfile = os.path.join(Config.djangoroot, Config.get("xmlrpc-server", "certfile"))
		ctx.use_privatekey_file(keyfile)
		ctx.use_certificate_file(certfile)
		self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
		self.server_bind()
		self.server_activate()

		# requests count and condition, to allow for keyboard quit via CTL-C
		self.requests = 0
		self.rCondition = Condition()
开发者ID:SnowmanRM,项目名称:Snowman,代码行数:39,代码来源:xmlrpcserver.py

示例12: START

def START(host = "localhost", port = 8080):
    class AsyncDocXMLRPCServer(SocketServer.ThreadingMixIn, DocXMLRPCServer): pass
    class AsyncJRPCServer(SocketServer.ThreadingMixIn, JRPCServer): pass

    server1 = DocXMLRPCServer((host, port), XRPCRequestHandler)
    # server2 = JRPCServer((host, port + 1))
    # reg_srv_methods(server1);
    # reg_srv_methods(server2);

    # class ST(Thread):
    #     def __init__(self, server, msg):
    #         Thread.__init__(self);
    #         self.daemon = True
    #         self.server = server
    #         self.msg = msg
    #         self.start()

    #     def run(self):
    #         self.server.serve_forever()

    print("Start Zebra demo HTTP Server %s:%d" % (host, port))
    server1.serve_forever()
开发者ID:Augus,项目名称:zebra,代码行数:22,代码来源:startup.py

示例13: run_xmlrpc_server

def run_xmlrpc_server():
	'''Run an XMLRPC server that publishes the translate_stacktrace function.'''
	from DocXMLRPCServer import DocXMLRPCServer as XMLRPCServer

	logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s')

	with open(PIDFILE, 'w') as pidfile:
		pidfile.write('%s' % os.getpid())

	try:
		# Create server
		server = XMLRPCServer(LISTEN_ADDR)
		server.register_function(translate_stacktrace)

		# Run the server's main loop
		try:
			server.serve_forever()
		except KeyboardInterrupt:
			pass

	finally:
		os.remove(PIDFILE)
开发者ID:nixtux,项目名称:spring,代码行数:22,代码来源:stacktrace_translator.py

示例14: APIService

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,代码行数:36,代码来源:api_service.py

示例15: testserver

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,代码行数:13,代码来源:cgi108.py


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