コード例 #1
0
ファイル: server.py プロジェクト: ckt1010/ROS-pi-toolchain
    def _register_with_server(self):
        """
        Register child node with server
        """        
        name = self.name
        self.logger.info("attempting to register with roslaunch parent [%s]"%self.server_uri)
        try:
            server = ServerProxy(self.server_uri)
            code, msg, _ = server.register(name, self.uri)
            if code != 1:
                raise RLException("unable to register with roslaunch server: %s"%msg)
        except Exception as e:
            self.logger.error("Exception while registering with roslaunch parent [%s]: %s"%(self.server_uri, traceback.format_exc()))
            # fail
            raise RLException("Exception while registering with roslaunch parent [%s]: %s"%(self.server_uri, traceback.format_exc()))
        
        self.logger.debug("child registered with server")
        
        # register printlog handler so messages are funneled to remote
        def serverlog(msg):
            server.log(name, Log.INFO, msg)
        def servererrlog(msg):
            server.log(name, Log.ERROR, msg)
        add_printlog_handler(serverlog)
        add_printerrlog_handler(servererrlog)            

        # register process listener to forward process death events to main server
        self.pm.add_process_listener(_ProcessListenerForwarder(server))
コード例 #2
0
ファイル: server.py プロジェクト: Aand1/ROSCH
    def _register_with_server(self):
        """
        Register child node with server
        """        
        name = self.name
        self.logger.info("attempting to register with roslaunch parent [%s]"%self.server_uri)
        try:
            server = ServerProxy(self.server_uri)
            code, msg, _ = server.register(name, self.uri)
            if code != 1:
                raise RLException("unable to register with roslaunch server: %s"%msg)
        except Exception as e:
            self.logger.error("Exception while registering with roslaunch parent [%s]: %s"%(self.server_uri, traceback.format_exc()))
            # fail
            raise RLException("Exception while registering with roslaunch parent [%s]: %s"%(self.server_uri, traceback.format_exc()))
        
        self.logger.debug("child registered with server")
        
        # register printlog handler so messages are funneled to remote
        def serverlog(msg):
            server.log(name, Log.INFO, msg)
        def servererrlog(msg):
            server.log(name, Log.ERROR, msg)
        add_printlog_handler(serverlog)
        add_printerrlog_handler(servererrlog)            

        # register process listener to forward process death events to main server
        self.pm.add_process_listener(_ProcessListenerForwarder(server))
コード例 #3
0
 def test_printlog(self):
     from roslaunch.core import add_printlog_handler, add_printerrlog_handler, printlog, printlog_bold, printerrlog
     add_printlog_handler(printlog_cb)
     add_printlog_handler(printlog_cb_exception)        
     add_printerrlog_handler(printlog_cb)
     add_printerrlog_handler(printlog_cb_exception)        
         
     #can't really test functionality, just make sure it doesn't crash
     global _lastmsg
     _lastmsg = None
     printlog('foo')
     self.assertEquals('foo', _lastmsg)
     printlog_bold('bar')
     self.assertEquals('bar', _lastmsg)        
     printerrlog('baz')
     self.assertEquals('baz', _lastmsg)        
コード例 #4
0
ファイル: test_core.py プロジェクト: lucasw/ros_comm-1
 def test_printlog(self):
     from roslaunch.core import add_printlog_handler, add_printerrlog_handler, printlog, printlog_bold, printerrlog
     add_printlog_handler(printlog_cb)
     add_printlog_handler(printlog_cb_exception)        
     add_printerrlog_handler(printlog_cb)
     add_printerrlog_handler(printlog_cb_exception)        
         
     #can't really test functionality, just make sure it doesn't crash
     global _lastmsg
     _lastmsg = None
     printlog('foo')
     self.assertEquals('foo', _lastmsg)
     printlog_bold('bar')
     self.assertEquals('bar', _lastmsg)        
     printerrlog('baz')
     self.assertEquals('baz', _lastmsg)        
コード例 #5
0
ファイル: server.py プロジェクト: lucasw/ros_comm-1
class ROSLaunchChildNode(ROSLaunchNode):
    """
    XML-RPC server for roslaunch child processes
    """
    def __init__(self, run_id, name, server_uri, pm):
        """
    ## Startup roslaunch remote client XML-RPC services. Blocks until shutdown
    ## @param name: name of remote client
    ## @type  name: str
    ## @param server_uri: XML-RPC URI of roslaunch server
    ## @type  server_uri: str
    ## @return: XML-RPC URI
    ## @rtype: str
        """
        self.logger = logging.getLogger("roslaunch.server")
        self.run_id = run_id
        self.name = name
        self.server_uri = server_uri
        self.pm = pm

        if self.pm is None:
            raise RLException(
                "cannot create child node: pm is not initialized")
        handler = ROSLaunchChildHandler(self.run_id, self.name,
                                        self.server_uri, self.pm)
        super(ROSLaunchChildNode, self).__init__(handler)

    def _register_with_server(self):
        """
        Register child node with server
        """
        name = self.name
        self.logger.info("attempting to register with roslaunch parent [%s]" %
                         self.server_uri)
        try:
            server = xmlrpclib.ServerProxy(self.server_uri)
            code, msg, _ = server.register(name, self.uri)
            if code != 1:
                raise RLException(
                    "unable to register with roslaunch server: %s" % msg)
        except Exception, e:
            self.logger.error(
                "Exception while registering with roslaunch parent [%s]: %s" %
                (self.server_uri, traceback.format_exc(e)))
            # fail
            raise RLException(
                "Exception while registering with roslaunch parent [%s]: %s" %
                (self.server_uri, traceback.format_exc(e)))

        self.logger.debug("child registered with server")

        # register printlog handler so messages are funneled to remote
        def serverlog(msg):
            server.log(name, Log.INFO, msg)

        def servererrlog(msg):
            server.log(name, Log.ERROR, msg)

        add_printlog_handler(serverlog)
        add_printerrlog_handler(servererrlog)

        # register process listener to forward process death events to main server
        self.pm.add_process_listener(_ProcessListenerForwarder(server))