Exemple #1
0
    def __init__(self, host=None, rpc_port=8000, verbose=True):
        """M3RtProxy is the client interface to the M3RtServer.
    It manages the state of the server using XML_RPC methods.
    It can query the server state,
    start/stop the run-time system, create a DataService connection,
    and publish/subscribe desired components to the DataService.
    The DataService uses a faster TCP/IP socket on port 10000"""

        self.stopped = False
        self.host = host
        self.verbose = verbose
        if host is None:
            self.host = m3t.get_config_hostname()
        if self.host is None:
            self.host = m3t.get_local_hostname()

        self.rpc_port = rpc_port
        self.data_port = 10000  #Currently hardcoded in M3
        self.proxy = None
        self.data_socket = None
        self.subscribed = {}
        self.published_param = {}
        self.published_command = {}
        self.available_components = []
        self.available_component_types = []
        self.log_comps = {}
        self.log_names = []
        self.logname = None
        self.status_raw = mbs.M3StatusAll()
        self.command_raw = mbs.M3CommandAll()
        self.ns = 0
        self.nsl = 0
        self.data_svc = None
        self.ros_svc = None
        self.use_timeout = True
        self.is_server_started = False
        try:
            if self.verbose:
                print 'Starting M3 RPC Client at ', self.host, 'on Port ', self.rpc_port, '...'
            self.proxy = xmlrpclib.ServerProxy('http://' + self.host + ':' +
                                               str(self.rpc_port))
            if self.verbose:
                print 'M3 RPC Client started at ', self.host, 'on Port ', self.rpc_port
            #Check that connection made
            try:
                self.proxy.system.listMethods()
            except xmlrpclib.Error, v:
                self.proxy = None
                raise m3t.M3Exception(
                    'Error: ' + v +
                    'Make sure that the M3 RPC Server is running')
        except socket.error, msg:
            self.proxy = None
            raise m3t.M3Exception(
                'Check that server is started. Socket Error: ' + str(msg))
 def __init__(self,host=None,rpc_port=8000,verbose=True):
     """M3RtProxy is the client interface to the M3RtServer.
 It manages the state of the server using XML_RPC methods. 
 It can query the server state,
 start/stop the run-time system, create a DataService connection,
 and publish/subscribe desired components to the DataService.
 The DataService uses a faster TCP/IP socket on port 10000"""
     self.stopped = False
     self.host=host
     self.verbose=verbose
     if host is None:
         self.host=m3t.get_config_hostname()
     if self.host is None:
         self.host = m3t.get_local_hostname()
     self.rpc_port=rpc_port
     self.data_port=10000 #Currently hardcoded in M3
     self.proxy=None
     self.data_socket=None
     self.subscribed={}
     self.published_param={}
     self.published_command={}
     self.available_components=[]
     self.available_component_types=[]
     self.log_comps={}
     self.log_names=[]
     self.logname=None
     self.status_raw=mbs.M3StatusAll()
     self.command_raw=mbs.M3CommandAll()
     self.ns=0
     self.nsl=0
     self.data_svc=None
     self.ros_svc =None
     self.use_timeout=True
     self.is_server_started=False
     try:
         self.proxy = xmlrpclib.ServerProxy('http://'+self.host+':'+str(self.rpc_port))
         if self.verbose: print 'Starting M3 RPC Client at ',self.host, 'on Port ',self.rpc_port,'...'
         #Check that connection made
         try:
             self.proxy.system.listMethods()
         except xmlrpclib.Error, v:
             self.proxy=None
             raise m3t.M3Exception('Error: '+v+'Make sure that the M3 RPC Server is running')
     except socket.error, msg:
         self.proxy=None
         raise m3t.M3Exception('Check that server is started. Socket Error: '+str(msg))
Exemple #3
0
        self.server.register_function(start_log_service)
        self.server.register_function(stop_log_service)
        self.server.register_function(get_log_file)
        self.server.register_function(get_log_info)
        #time.sleep(2.0) # wait for EC kmod to get slaves in OP
    def run(self):
        print 'Starting M3 RPC Server on Host:', host, 'at Port:', port, '...'
        self.server.serve_forever()
        print "M3 INFO: Closing Socket"
        self.server.socket.close()


# ################################################################################

## THE DEFAULT ARGUMENTS TO START THE SERVER
host = m3t.get_local_hostname()
port = 8000
make_op_all = False
make_op_all_shm = False
make_op_all_no_shm = True
start_data_svc = False

svc = None
m3server = None
m3client_thread = None
signal.signal(signal.SIGINT, stop_program)

for idx in range(1, len(sys.argv)):
    if sys.argv[idx] == '-host' or sys.argv[idx] == '-h' and idx < len(
            sys.argv) - 1:
        host = sys.argv[idx + 1]
        self.server.register_instance(svc)
        self.server.register_function(start_log_service)
        self.server.register_function(stop_log_service)
        self.server.register_function(get_log_file)
        self.server.register_function(get_log_info)
        #time.sleep(2.0) # wait for EC kmod to get slaves in OP
    def run(self):
        print 'Starting M3 RPC Server on Host:',host,'at Port:',port,'...'
        self.server.serve_forever()
        print "M3 INFO: Closing Socket"
        self.server.socket.close()
            
# ################################################################################

## THE DEFAULT ARGUMENTS TO START THE SERVER
host = m3t.get_local_hostname()
port=8000
make_op_all = False
make_op_all_shm = False
make_op_all_no_shm = True
start_data_svc = False

svc = None
m3server = None
m3client_thread = None
signal.signal(signal.SIGINT, stop_program)

for idx in range(1,len(sys.argv)):
    if sys.argv[idx]=='-host' or sys.argv[idx]=='-h' and idx<len(sys.argv)-1:
        host=sys.argv[idx+1]
    elif sys.argv[idx]=='-port' or sys.argv[idx]=='-p' and idx<len(sys.argv)-1: