Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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.api.signatures = {}
        for methodtuple in inspect.getmembers(self.api,
                                              predicate=inspect.ismethod):
            name = methodtuple[0]
            if name in ["__init__", "success", "error"]:
                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()
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
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()
def xmlrpcserver(run, port):
    server = DocXMLRPCServer(("localhost", port))
    server.register_introspection_functions()
    server.register_function(gimp.gtkrc, "gtkrc")
    server.register_instance(gimp)
    if run:
        server.serve_forever()
    pass
Ejemplo n.º 7
0
    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()
Ejemplo n.º 8
0
    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.""")
 def __init__(self,
              addr,
              requestHandler=SimpleXMLRPCRequestHandler,
              logRequests=1):
     self.allow_reuse_address = True
     DocXMLRPCServer.__init__(self,
                              addr,
                              requestHandler=requestHandler,
                              logRequests=logRequests)
Ejemplo n.º 10
0
    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()
Ejemplo n.º 11
0
    def __init__(self, communicator, name, params, client_request_class=None):
        Listener.__init__(self,
                          communicator,
                          name,
                          params,
                          client_request_class=client_request_class)

        if not params.has_key('service_name'):
            params['service_name'] = self.get_name()

        host = params.get('host')
        port = int(params.get('port'))

        self._server = DocXMLRPCServer(addr=(host, port),
                                       allow_none=1,
                                       logRequests=0)

        self.add_service(XmlrpcDispatcher(self), name=params['service_name'])
Ejemplo n.º 12
0
	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()
Ejemplo n.º 13
0
 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)
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
    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")
Ejemplo n.º 16
0
 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")
Ejemplo n.º 17
0
    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()
Ejemplo n.º 18
0
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()
Ejemplo n.º 19
0
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)
Ejemplo n.º 20
0
	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()
Ejemplo n.º 21
0
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)
Ejemplo n.º 22
0
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()
Ejemplo n.º 23
0
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()
Ejemplo n.º 24
0
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()
Ejemplo n.º 25
0
    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)
Ejemplo n.º 26
0
class XmlrpcListener(Listener):

    logger = logging.get_logger(name='xmlrpc')

    def __init__(self, communicator, name, params, client_request_class=None):
        Listener.__init__(self,
                          communicator,
                          name,
                          params,
                          client_request_class=client_request_class)

        if not params.has_key('service_name'):
            params['service_name'] = self.get_name()

        host = params.get('host')
        port = int(params.get('port'))

        self._server = DocXMLRPCServer(addr=(host, port),
                                       allow_none=1,
                                       logRequests=0)

        self.add_service(XmlrpcDispatcher(self), name=params['service_name'])

    def __get_instance_methods__(self, instance, prefix=None):
        methods = {}
        for o in dir(instance):
            if not o.startswith('_'):
                method = getattr(instance, o)
                if method.__class__.__name__ == 'instancemethod':
                    if prefix:
                        methods["%s.%s" % (prefix, o)] = method
                    else:
                        methods[o] = method
        return methods

    def add_service(self, service, **kwargs):
        '''
        Add a service to listener.
        
        @param service: service object
        '''

        name = kwargs.get('name', None)
        methods = self.__get_instance_methods__(service, name)
        for method_name, method in methods.items():
            self._server.register_function(method, method_name)

    def start(self):
        self._server.serve_forever()

    def stop(self, force):
        try:
            self._server.shutdown()
        except Exception, error:
            XmlrpcListener.logger.warning(error)
Ejemplo n.º 27
0
 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."
     )
Ejemplo n.º 28
0
from SimpleXMLRPCServer import SimpleXMLRPCServer
from DocXMLRPCServer import DocXMLRPCServer

# Create server
#server = SimpleXMLRPCServer(("localhost", 8000))
server = DocXMLRPCServer(("localhost", 8000))
server.register_introspection_functions()

# Register pow() function; this will use the value of
# pow.__name__ as the name, which is just 'pow'.
server.register_function(pow)

# Register a function under a different name
def adder_function(x,y):
    return x + y
server.register_function(adder_function, 'add')

# Register an instance; all the methods of the instance are
# published as XML-RPC methods (in this case, just 'div').
class MyFuncs:
    def div(self, x, y):
        return x // y


server.register_instance(MyFuncs())

def msg(user):
    return '<h1>haha%s</h1>'%user
server.register_function(msg)

# Run the server's main loop
Ejemplo n.º 29
0
        q = q.filter(fias_db.Addrobj.formalname.ilike(name_like))
    if q.count() > return_limit:
        return "Too big list"
    else:
        res = []
        for one in q.all():
            ao = melt.fias_AO(one, session=session)
            one_ = dict(formalname=one.formalname,
                        shortname=one.shortname,
                        aolevel=one.aolevel,
                        code=one.code,
                    okato=str(one.okato) if one.okato else '',
                    postalcode=str(one.postalcode) if one.postalcode else '',
                        name=ao.name,
                        fullname=ao.fullname,
                        aoguid=str(one.aoguid)
                        )
            res.append(one_)
        return res


if __name__ == "__main__":
    from DocXMLRPCServer import DocXMLRPCServer
    serv = DocXMLRPCServer(("127.0.0.1", 8080), allow_none=True)
    serv.register_function(GetAreas)
    serv.register_function(GetAreaProperty)
    serv.register_function(GetBuildings)
    serv.register_function(GetBuildingProperties)
    serv.register_introspection_functions()
    serv.serve_forever()
Ejemplo n.º 30
0
 def __init__(self, addr, handler):
     signal(SIGPIPE, SIG_IGN)
     DocXMLRPCServer.__init__(self, addr, handler)
     self.serving_posts = Array('i', 70)
     self.set_server_title('Premium HTTP Server')
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
Ejemplo n.º 32
0
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()
Ejemplo n.º 33
0
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)
Ejemplo n.º 34
0
 def __init__(self):
     DocXMLRPCServer.__init__(self, ('0.0.0.0', 54000), logRequests=False)
     self.set_server_name("RSSI Proximity")
     self.register_function(self.getProximity)
Ejemplo n.º 35
0
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()
Ejemplo n.º 36
0
 def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=1):
     self.allow_reuse_address = True
     DocXMLRPCServer.__init__(self, addr, requestHandler=requestHandler, logRequests=logRequests)
Ejemplo n.º 37
0
class Server(Mode):
    def _initialise(self, args):
        logging.debug('Starting server mode checks on config file')

        config = get_config(args.config_file)

        self._clients = {}

        self._backup_location = ''
        self._port = 9001

        if config.has_option('server', 'backup_location'):
            self._backup_location = config.get('server', 'backup_location')

            if not os.path.isdir(self._backup_location):
                logging.warn(
                    "Backup location '%s' does not exist, attempting to create it"
                    % self._backup_location)

                try:
                    os.makedirs(self._backup_location)
                except:
                    raise RuntimeError(
                        'Could not create the requested backup location')
        else:
            raise RuntimeError('Backup location not specified in config file')

        if not config.has_option('server', 'port'):
            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()
Ejemplo n.º 38
0
    ##############
    # XMLRPC msg #
    ############################
    def msg(msg):              #
        return bot.sendMsg(msg)#
    ############################
    
    ####################
    # Start Bot Thread #
    ##################################################
    thread.start_new_thread(bot.Listen,('DevBot-1',))#
    ##################################################

    #######################
    # Setup XMLRPC Server #
    ########################################################################
    query = "SELECT address,port FROM devbot WHERE LOWER(name) = 'DevBot'  \
            LIMIT 1"                                                       #
    svrnfo = db.query(query)                                               #
    try:                                                                   #
        svrnfo = svrnfo[0]                                                 #
    except:                                                                #
        print "No instance found!"                                         #
        sys.exit(1)                                                        #
    server = DocXMLRPCServer(svrnfo, logRequests=0)                        #
    server.set_server_name("DevBot")                                       #
    server.register_function(msg)                                          #
    while not bot.terminateFlag:                                           #
        server.handle_request()                                            #
    ########################################################################
Ejemplo n.º 39
0
 def __init__(self, addr, handler):
     signal(SIGPIPE, SIG_IGN)
     DocXMLRPCServer.__init__(self, addr, handler)
     self.serving_posts = Array('i', 70)
     self.set_server_title('Premium HTTP Server')
Ejemplo n.º 40
0
    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()
Ejemplo n.º 41
0
        q = q.filter(fias_db.Addrobj.formalname.ilike(name_like))
    if q.count() > return_limit:
        return "Too big list"
    else:
        res = []
        for one in q.all():
            ao = melt.fias_AO(one, session=session)
            one_ = dict(
                formalname=one.formalname,
                shortname=one.shortname,
                aolevel=one.aolevel,
                code=one.code,
                okato=str(one.okato) if one.okato else '',
                postalcode=str(one.postalcode) if one.postalcode else '',
                name=ao.name,
                fullname=ao.fullname,
                aoguid=str(one.aoguid))
            res.append(one_)
        return res


if __name__ == "__main__":
    from DocXMLRPCServer import DocXMLRPCServer
    serv = DocXMLRPCServer(("127.0.0.1", 8080), allow_none=True)
    serv.register_function(GetAreas)
    serv.register_function(GetAreaProperty)
    serv.register_function(GetBuildings)
    serv.register_function(GetBuildingProperties)
    serv.register_introspection_functions()
    serv.serve_forever()
Ejemplo n.º 42
0
class Server(Mode):
    def _initialise(self, args):
        logging.debug('Starting server mode checks on config file')
        
        config = get_config(args.config_file)

        self._clients = {}

        self._backup_location = ''
        self._port = 9001

        if config.has_option('server', 'backup_location'):
            self._backup_location = config.get('server', 'backup_location')

            if not os.path.isdir(self._backup_location):
                logging.warn("Backup location '%s' does not exist, attempting to create it" % self._backup_location)

                try:
                    os.makedirs(self._backup_location)
                except:
                    raise RuntimeError('Could not create the requested backup location')
        else:
            raise RuntimeError('Backup location not specified in config file')

        if not config.has_option('server', 'port'):
            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()
Ejemplo n.º 43
0
from DocXMLRPCServer import DocXMLRPCServer

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


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


server.register_function(echo)

# 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.
Ejemplo n.º 44
0
	(hwinfot,meth) = xmlrpclib.loads(hwinfostr)
	hwinfo = hwinfot[0]
	# Append date before inserting
	hwinfo.update({'Date': datetime.datetime.now()})
	try:
	    conn = opendb()
        except:
            return False
        else:
	    add_record(conn, hwinfo)
            conn.close()
	return True

    def gethwinfo(self):
	"""Return the entire HW database"""
	return xmlrpclib.dumps((getdb(),))
 
if __name__ == '__main__':
    import os.path
    import time
    if not os.path.isfile(DBFILE):
        createdb(DBFILE)
    from DocXMLRPCServer import DocXMLRPCServer
    server = DocXMLRPCServer(("", 8000), logRequests=0)
    server.register_introspection_functions()
    server.register_instance(HwInfoServer())

    print time.asctime(), 'Application Starting.'
    server.serve_forever()
    print time.asctime(), 'Application Finishing.'
#!/usr/bin/python

from DocXMLRPCServer import DocXMLRPCServer


def sumAndDifference(x,y):
    """This method returns sum and difference of arguments
       as struct with two fields: 'sum' and 'difference'"""
    
    return {'sum':x+y,'difference':x-y}

server = DocXMLRPCServer(("localhost", 5777))
server.register_function(sumAndDifference,"sample.sumAndDifference")
server.register_introspection_functions()
server.register_multicall_functions()
server.serve_forever()
Ejemplo n.º 46
0
def GenerateDjangoXMLRPCHandler(class_instance, server_name="Citrix Service"):
    server = DocXMLRPCServer(("localhost", 0),
                             bind_and_activate=False,
                             allow_none=True)
    server.register_introspection_functions()
    server.register_instance(class_instance)
    server.set_server_name(server_name)
    server.set_server_title(server_name)
    server.set_server_documentation(class_instance.__doc__)

    def handler(request):
        if request.method == "POST":
            response = HttpResponse(content_type="application/xml")
            response.write(server._marshaled_dispatch(request.raw_post_data))
            return response
        elif request.method == "GET":
            response = HttpResponse(content_type="text/html")
            response.write(server.generate_html_documentation())
            return response
        else:
            return HttpResponseNotAllowed("GET", "POST")

    return handler
Ejemplo n.º 47
0
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.
Ejemplo n.º 48
0
def GenerateDjangoXMLRPCHandler2(class_instance,
                                 server_name='Citrix Geppetto v0.1'):
    server = DocXMLRPCServer(("localhost", 0),
                             bind_and_activate=False,
                             allow_none=True)
    server.register_introspection_functions()
    members = inspect.getmembers(class_instance)
    members.sort(key=lambda x: x[0])
    for member_name, member in members:
        if inspect.ismethod(member):
            if not member_name.startswith('_'):
                s = member_name.replace('___', '.')
                server.register_function(member, s)
    server.set_server_name(server_name)
    server.set_server_title(server_name)
    server.set_server_documentation(class_instance.__doc__)

    def handler(request):
        if request.method == "POST":
            response = HttpResponse(content_type="application/xml")
            response.write(server._marshaled_dispatch(request.raw_post_data))
            return response
        elif request.method == "GET":
            response = HttpResponse(content_type="text/html")
            response.write(server.generate_html_documentation())
            return response
        else:
            return HttpResponseNotAllowed("GET", "POST")

    return handler
Ejemplo n.º 49
0
 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)
Ejemplo n.º 50
0
	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)