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


Python DocXMLRPCServer.serve_forever方法代码示例

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


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

示例1: START

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import serve_forever [as 别名]
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,代码行数:9,代码来源:startup.py

示例2: __init__

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

示例3: APIService

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

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import serve_forever [as 别名]
def start():
    """
    Start the XML-RPC server, and print out the port number that it is
    listening on.
    """

    server = XMLRPCServer(("127.0.0.1", 0), JPushyXMLRPCRequestHandler)

    # print out the port number
    print server.socket.getsockname()[1]
    sys.stdout.flush()

    server.allow_none = True
    server.register_introspection_functions()
    server.register_instance(JPushyFunctions())
    server.serve_forever()
开发者ID:alfredodeza,项目名称:pushy,代码行数:18,代码来源:jpushy.py

示例5: run

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import serve_forever [as 别名]
 def run( s ):
     server = DocXMLRPCServer( (s.host_name, s.port_number),
                               logRequests=0 )
     server.register_function( s.notify )
     server.register_function( s.subscribe )
     server.register_function( s.unsubscribe )
     server.register_function( s.unsubscribe_all )
     server.register_function( s.get_logs )
     print time.asctime(), "Event Server Starts - %s:%s" % (s.host_name,
                                                            s.port_number)
     try:
         server.serve_forever()
     except KeyboardInterrupt:
         pass
     server.close() # might work..?
     print time.asctime(), "Event Server Stops - %s:%s" % (s.host_name,
                                                           s.port_number)
开发者ID:BackupTheBerlios,项目名称:onebigsoup-svn,代码行数:19,代码来源:server.py

示例6: run_xmlrpc_server

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import serve_forever [as 别名]
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,代码行数:24,代码来源:stacktrace_translator.py

示例7: START

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import serve_forever [as 别名]
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,代码行数:24,代码来源:startup.py

示例8: run

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import serve_forever [as 别名]
	def run( s ):
		server = DocXMLRPCServer( (s.host_name, s.port_number),
					  logRequests=0 )
		server.register_function( s.notify )
		server.register_function( s.create_user )
		server.register_function( s.delete_user )
		server.register_function( s.email_pw )
		server.register_function( s.change_pw )
		server.register_function( s.create_namespace )
		server.register_function( s.delete_namespace )
		server.register_function( s.set )
		server.register_function( s.unset )
		server.register_function( s.get_description_url )
		server.register_introspection_functions()

		print time.asctime(), "Local Names Store Server Starts - %s:%s" % (s.host_name,
									  s.port_number)
		try:
			server.serve_forever()
		except KeyboardInterrupt:
			pass
		print time.asctime(), "Local Names Store Server Stops - %s:%s" % (s.host_name,
                                                             s.port_number)
开发者ID:BackupTheBerlios,项目名称:onebigsoup-svn,代码行数:25,代码来源:lnss_server.py

示例9: APIService

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

示例10: DocXMLRPCServer

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import serve_forever [as 别名]
from DocXMLRPCServer import DocXMLRPCServer
import time

# Create server
server = DocXMLRPCServer(("localhost", 8000))

# Register a function
def echo(message):
    "Accepts a message parameter and returns it unchanged."
    return message

# New functions for lab exercise
def time():
    "Returns the current time"
    return time.asctime()


server.register_function(echo)
server.register_function(time)

# Run the server's main loop
server.serve_forever()

# DocXMLRPCServer classes automatically create and serve documentation to 
# browsers, visit http://localhost:8000/ to see it.
开发者ID:jon-jacky,项目名称:internet-python,代码行数:27,代码来源:xmlrpc_server.py

示例11: Server

# 需要导入模块: from DocXMLRPCServer import DocXMLRPCServer [as 别名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import serve_forever [as 别名]

#.........这里部分代码省略.........
            logging.warn('No port specified, using 9001')
        else:
            try:
                self._port = int(config.get('server', 'port'))
            except:
                raise RuntimeError('Server port must be an integer')

        for section in config.sections():
            if not section == 'server':
                logging.debug('Found a client: %s' % section)

                if not config.has_option(section, 'artifacts'):
                    raise RuntimeError('Client sections require an artifacts option')

                artifacts_string = config.get(section, 'artifacts')
                artifacts = {}

                if artifacts_string == '':
                    raise RuntimeError('Artifacts list cannot be empty')

                for artifact in artifacts_string.split(','):
                    logging.debug('Found an artifact: %s' % artifact)

                    file_based = True
                    filename = ''
                    backup_command = ''
                    restore_command = ''
                    cleanup = False
                    versions = 1
                    interval = '1h'

                    if config.has_option(section, artifact + '_filename'):
                        filename = config.get(section, artifact + '_filename')
                    else:
                        raise RuntimeError("Artifacts must have at least a file specified. Error in client '%s'" % section)

                    if config.has_option(section, artifact + '_backup_command'):
                        file_based = False
                        backup_command = config.get(section, artifact + '_backup_command')

                        if config.has_option(section, artifact + '_restore_command'):
                            restore_command = config.get(section, artifact + '_restore_command')
                        else:
                            raise RuntimeError("A backup command was specified without a restore command. A restore command is required in client '%s', artifact '%s'" % (section, artifact))

                    if config.has_option(section, artifact + '_cleanup'):
                        tmp = config.get(section, artifact + '_cleanup')

                        if tmp.lower() == 'true':
                            cleanup = True
                        elif tmp.lower() == 'false':
                            cleanup = False
                        else:
                            raise RuntimeError("Invalid option for cleanup in client '%s', artifact '%s'" % (section, artifact))

                    if config.has_option(section, artifact + '_versions'):
                        try:
                            versions = int(config.get(section, artifact + '_versions'))
                        except:
                            raise RuntimeError("Version option must be an integer in client '%s', artifact '%s'" % (section, artifact))

                    if config.has_option(section, artifact + '_interval'):
                        interval = config.get(section, artifact + '_interval')
                        regex = "^(\d+w ?)?(\d+d ?)?(\d+h ?)?(\d+m ?)?(\d+s ?)?$"

                        if not re.search(regex, interval):
                            raise RuntimeError("Interval option must in valid timedelta format. e.g. 1w2d3h4m. In client '%s', artifact '%s'" % (section, artifact))

                    artifacts[artifact] = {
                        'file_based': file_based,
                        'filename': filename,
                        'backup_command': backup_command,
                        'restore_command': restore_command,
                        'cleanup': cleanup,
                        'versions': versions,
                        'interval': interval
                    }

                self._clients[section] = artifacts

        if not len(self._clients) > 0:
            raise RuntimeError('No clients specified')

        self._server = None

    def _add_arguments(self):
        self._parser.add_argument('config_file', metavar='CONFIGFILE')

    def run(self):
        logging.debug('Starting XMLRPC server')

        self._server = DocXMLRPCServer(('0.0.0.0', self._port), logRequests=False)
        self._server.register_instance(_XMLRPCServer(self._clients, self._backup_location))
        self._server.serve_forever()

    def stop(self):
        logging.debug('Stopping XMLRPC Server')

        if self._server != None:
            self._server.shutdown()
开发者ID:mattdavis90,项目名称:re-store-it,代码行数:104,代码来源:server.py


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