當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。