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


Python SimpleXMLRPCServer.serve_forever方法代码示例

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


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

示例1: ServerThread

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
class ServerThread( threading.Thread ) :
    
    def __init__( self, case ) :
        self.case = case
        threading.Thread.__init__( self )

        
        print "starting local Ophidian server..."
        self.ProblemServer = ophidian.ProblemServer()
        self.ProblemServer.RunDir = 'RunDir'
        
        # check the run directory for cached problems
        self.ProblemServer.InitProblemList()
        
        # load the first problem, if it exists, exit otherwise
        if self.ProblemServer.ProblemList.__contains__(case) :
         
            self.ProblemServer.ProblemList = [case]
            
            print "Loading CUBE data for problem " + case
            self.ProblemServer.LoadProblem( case )
            
            print "Starting server..."
            self.server = SimpleXMLRPCServer(('127.0.0.1', 8000 ))
            self.server.register_function(self.ProblemServer.GetProblem)
            self.server.register_function(self.ProblemServer.GetBlock)
            self.server.register_function(self.ProblemServer.CheckInBlock)
        else :
            print "No problems found. Ophidian server shutting down."
    
    def run( self ) :
        print "Now serving problem " + self.ProblemServer.Problem.problemname
        self.server.serve_forever()
开发者ID:ryneches,项目名称:Ophidian,代码行数:35,代码来源:standalone.py

示例2: Network

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
class Network(object):
    def __init__(self, config,log):
        self.log = log
        
        xmlport = config.getValue("xmlport")
        xmlhost = config.getValue("xmlhost")
        udpport = config.getValue("udpport")
        udphost = config.getValue("udphost")

        self.xml = SimpleXMLRPCServer((xmlhost, xmlport))
        self.udp = netServer(udphost,udpport,log)

        log.StartupMessage("* Attempting to start XML-RPC Server")
        self.udp.serve_forever()
        self.xmlThread = Thread( target = self.startXMLRPCServer )
        self.xmlThread.setDaemon( True )
        self.xmlThread.start()
        log.StartupMessage( "    XML-RPC Server is up at port %d" % xmlport)
        
    def register_function(self,func,funcname):
        self.xml.register_function(func,funcname)
        self.udp.register_function(func,funcname)
        self.log.Notice("Registered funtion %s for network access" % funcname)

    def stopServices(self):
        self.udp.stopServer()
        self.udp.join()
        
        self.log.StartupMessage("* Attempting to stop XML-RPC Server")
        self.xml.server_close()
        #self.xmlThread.join()

    def startXMLRPCServer(self):
        self.xml.serve_forever()
开发者ID:nojan1,项目名称:IHouseServer,代码行数:36,代码来源:network.py

示例3: main

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
def main():
    print ("init")
    server = SimpleXMLRPCServer(('0.0.0.0', int(SLAVE_DAEMON_PORT)))
    server.register_introspection_functions()
    server.register_instance(Node())
    print ("starting server")
    server.serve_forever()
开发者ID:Infosys,项目名称:High-Availability-Hadoop,代码行数:9,代码来源:slave_daemon.py

示例4: main

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
def main():
  try:
    opts, args = getopt.getopt(sys.argv[1:], "hs:p:", ["help"])

    serv = "localhost"
    port = 8088

    for opt, val in opts:
      if opt in ("-h", "--help"):
        usage()
        sys.exit(0)
      elif opt == "-s":
        serv = val
      elif opt == "-p":
        port = int(val)

    server = SimpleXMLRPCServer((serv, port), RequestHandler, True, True)
    server.register_introspection_functions()
    server.serve_forever()

  except getopt.GetoptError as err:
    print str(err)
    usage()
    sys.exit(1)
  except ValueError:
    usage()
    sys.exit(1)
  except KeyboardInterrupt:
    sys.exit(0)
开发者ID:sayradley,项目名称:XMLRPCServer,代码行数:31,代码来源:server.py

示例5: run

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
    def run(self):
        class RequestHandler(SimpleXMLRPCRequestHandler):
            rpc_paths = ('/RPC2',)
    	#create a server
    	server = SimpleXMLRPCServer(("localhost",8045),requestHandler = RequestHandler)

        server.register_introspection_functions()
        def transmit_orbited(channel, message):
           """
              @param channel: The stomp channel to send to
              @param message: The message that needs to be transmitted
           """
           self.orbited.send_data(channel, message)
           return ""

        server.register_function(transmit_orbited, 'transmit')
        server.serve_forever()
开发者ID:liuhuiwisdom,项目名称:WRed,代码行数:19,代码来源:relay.py

示例6: __init__

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
class servidor:
    """main class"""
    configuraciones = {'puerto':6051, 'version_cliente':0.1,'version_server':0.1}
    
    
    def __init__(self):
        #self.leer_configuraciones()
        #oldstderr=sys.stderr

        sys.stderr=file('infoserver.log', 'w')
        self.server = SimpleXMLRPCServer(("", self.configuraciones['puerto']))
        cpu_datos = allocate_lock()
        cpu_datos.acquire()
        cpu_da = [0,0]
        cpu_datos.release()

        self.server.register_instance(sesiones(cpu_datos,cpu_da))

        a = cpu_datos,cpu_da
        start_new_thread(cpu_funcion, a)
        
    def run(self):
        self.server.serve_forever()
开发者ID:kotejante,项目名称:info-server,代码行数:25,代码来源:iserver.py

示例7: RPCServer

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
class RPCServer(Thread) :
	def __init__(self) :
		Thread.__init__(self)
		self.n = 0
		self.uniqueRequests = []
		self.numDoneSent = 0
		self.server = SimpleXMLRPCServer(("0.0.0.0", port))
		self.server.register_function(self.nextInput, "nextInput")
		self.lock = Lock()
	def nextInput(self, ip) :
		self.lock.acquire()
		if self.uniqueRequests.count(ip) == 0 : self.uniqueRequests.append(ip)
		if self.n >= len(input_files) :
			self.numDoneSent += 1
			if self.numDoneSent >= len(self.uniqueRequests) : shutdown(1)
			self.lock.release()
			return -1
		rtn = self.n
		self.n += 1
		self.lock.release()
		return rtn
		
	def run(self) :
		self.server.serve_forever()
开发者ID:djames,项目名称:ay250,代码行数:26,代码来源:DistributedPrimitives.py

示例8: getId

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
def getId():
    if cursor.execute("SELECT * FROM Notes").fetchall():
        id = cursor.execute("SELECT Id FROM Notes").fetchall()[-1][0] + 1
        return id
    return 0


def update( searchBy, valueToSearch, changeWhich, newValue):
    cursor.execute("UPDATE Notes set {} = ? where {} = ?".format(searchBy, changeWhich),
                        (newValue, valueToSearch,))
    cursor.execute("UPDATE Notes set Date = ? where {} = ?".format(changeWhich),
                        (datetime.datetime.now(), valueToSearch,))
    connection.commit()
    return True

def add( name, id, tel, mail):
    cursor.execute("INSERT INTO Notes VALUES(?,?,?,?,?)", (id, name, tel, mail, datetime.datetime.now(),))
    connection.commit()
    return True

server = SimpleXMLRPCServer(("localhost", 8002))
server.register_function(get_all)
server.register_function(search)
server.register_function(delete)
server.register_function(reset)
server.register_function(getId)
server.register_function(update)
server.register_function(add)
server.serve_forever()
开发者ID:shrumo,项目名称:miscellaneous,代码行数:31,代码来源:server.py

示例9: run

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
 def run(self):
     se = SimpleXMLRPCServer((shared.config.get('bitmessagesettings', 'apiinterface'), shared.config.getint(
         'bitmessagesettings', 'apiport')), MySimpleXMLRPCRequestHandler, True, True)
     se.register_introspection_functions()
     se.serve_forever()
开发者ID:kawalgrover,项目名称:PyBitmessage,代码行数:7,代码来源:bitmessagemain.py

示例10: runServer

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
def runServer(port):
    server = SimpleXMLRPCServer(("", port))
    server.register_instance(Functions())
    server.register_introspection_functions()
    server.register_multicall_functions()
    server.serve_forever()
开发者ID:grep0,项目名称:ExecServer,代码行数:8,代码来源:ExecServer.py

示例11: StatusCollector

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
        '''
        _logger.error('StatusCollector has died. Exiting program.')
        # Stop the XML-RPC server to exit serve_forever
        global stopping
        stopping = True
        serverXMLRPC.server_close()

    # Instantiate the StatusCollector and start the XML-RPC server
    try:
        # Create our StatusCollector which talks to the Spectracom
        collector = StatusCollector('timeserver', '/data/hcr/spectracom_log',
                                    onStatusCollectorFailure)
        # The main thread is devoted to just running the XML-RPC server. This
        # will finish when a SIGINT is received (i.e., via ^C) or a SIGTERM
        # is received (e.g., via a 'kill' command).
        serverXMLRPC.serve_forever()
    except socket.error as e:
        # Ignore socket.error if we're stopping the server, otherwise
        # complain and exit
        if (not stopping):
            _logger.error('Exiting on XML-RPC server socket error: %s' % (e))
            serverXMLRPC.server_close()

    # Perform a clean shutdown of the XML-RPC server
    serverXMLRPC.shutdown()
    
    # Unregister with procmap
    procmapUnregister()

    _logger.info('Finished ' + time.asctime())
开发者ID:NCAR,项目名称:HCR_instrument,代码行数:32,代码来源:SpectracomDaemon.py

示例12: launch

# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import serve_forever [as 别名]
def launch():
    server = SimpleXMLRPCServer(("localhost", 8000))
    server.register_instance(Test())
    server.serve_forever()
开发者ID:bhramoss,项目名称:code,代码行数:6,代码来源:recipe-359874.py


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