def launch_remote_nodes(self): """ Contact each child to launch remote nodes """ succeeded = [] failed = [] # initialize remote_nodes. we use the machine config key as # the key for the dictionary so that we can bin the nodes. self.remote_nodes = {} for m in self.machine_list: self.remote_nodes[m.config_key()] = [] # build list of nodes that will be launched by machine nodes = [ x for x in self.rosconfig.nodes if not is_machine_local(x.machine) ] for n in nodes: self.remote_nodes[n.machine.config_key()].append(n) for child in self.remote_processes: nodes = self.remote_nodes[child.machine.config_key()] body = '\n'.join([n.to_remote_xml() for n in nodes]) # force utf-8 encoding, #3799 xml = '<?xml version="1.0" encoding="utf-8"?>\n<launch>\n%s</launch>' % body if 0: print xml api = child.getapi() # TODO: timeouts try: self.logger.debug("sending [%s] XML [\n%s\n]" % (child.uri, xml)) code, msg, val = api.launch(xml) if code == 1: c_succ, c_fail = val succeeded.extend(c_succ) failed.extend(c_fail) else: printerrlog('error launching on [%s, uri %s]: %s' % (child.name, child.uri, msg)) self._assume_failed(nodes, failed) except socket.error, (errno, msg): printerrlog('error launching on [%s, uri %s]: %s' % (child.name, child.uri, str(msg))) self._assume_failed(nodes, failed) except socket.gaierror, (errno, msg): # usually errno == -2. See #815. child_host, _ = network.parse_http_host_and_port(child.uri) printerrlog( "Unable to contact remote roslaunch at [%s]. This is most likely due to a network misconfiguration with host lookups. Please make sure that you can contact '%s' from this machine" % (child.uri, child_host)) self._assume_failed(nodes, failed)
def launch_remote_nodes(self): """ Contact each child to launch remote nodes """ succeeded = [] failed = [] # initialize remote_nodes. we use the machine config key as # the key for the dictionary so that we can bin the nodes. self.remote_nodes = {} for m in self.machine_list: self.remote_nodes[m.config_key()] = [] # build list of nodes that will be launched by machine nodes = [x for x in self.rosconfig.nodes if not is_machine_local(x.machine)] for n in nodes: self.remote_nodes[n.machine.config_key()].append(n) for child in self.remote_processes: nodes = self.remote_nodes[child.machine.config_key()] body = '\n'.join([n.to_remote_xml() for n in nodes]) xml = '<launch>\n%s</launch>'%body if 0: print xml api = child.getapi() # TODO: timeouts try: self.logger.debug("sending [%s] XML [\n%s\n]"%(child.uri, xml)) code, msg, val = api.launch(xml) if code == 1: c_succ, c_fail = val succeeded.extend(c_succ) failed.extend(c_fail) else: printerrlog('error launching on [%s, uri %s]: %s'%(child.name, child.uri, msg)) self._assume_failed(nodes, failed) except socket.error, (errno, msg): printerrlog('error launching on [%s, uri %s]: %s'%(child.name, child.uri, str(msg))) self._assume_failed(nodes, failed) except socket.gaierror, (errno, msg): # usually errno == -2. See #815. child_host, _ = network.parse_http_host_and_port(child.uri) printerrlog("Unable to contact remote roslaunch at [%s]. This is most likely due to a network misconfiguration with host lookups. Please make sure that you can contact '%s' from this machine"%(child.uri, child_host)) self._assume_failed(nodes, failed)
def test_parse_http_host_and_port(self): from roslib.network import parse_http_host_and_port invalid = ['', 'http://', 'http://localhost:bar', None] for t in invalid: try: parse_http_host_and_port(t) self.fail("should have failed: %s"%t) except ValueError: pass self.assertEquals(('localhost', 80), parse_http_host_and_port('http://localhost')) self.assertEquals(('localhost', 1234), parse_http_host_and_port('http://localhost:1234')) self.assertEquals(('localhost', 1), parse_http_host_and_port('http://localhost:1')) self.assertEquals(('willowgarage.com', 1), parse_http_host_and_port('http://willowgarage.com:1'))
def __init__(self, run_id, name, server_uri, pm): """ @param server_uri: XML-RPC URI of server @type server_uri: str @param pm: process monitor to use @type pm: L{ProcessMonitor} @raise RLException: If parameters are invalid """ super(ROSLaunchChildHandler, self).__init__(pm) if server_uri is None: raise RLException("server_uri is not initialized") self.run_id = run_id # parse the URI to make sure it's valid _, urlport = network.parse_http_host_and_port(server_uri) if urlport <= 0: raise RLException("ERROR: roslaunch server URI is not a valid XML-RPC URI. Value is [%s]"%m.uri) self.name = name self.pm = pm self.server_uri = server_uri self.server = xmlrpclib.ServerProxy(server_uri)
def __init__(self, run_id, name, server_uri, pm): """ @param server_uri: XML-RPC URI of server @type server_uri: str @param pm: process monitor to use @type pm: L{ProcessMonitor} @raise RLException: If parameters are invalid """ super(ROSLaunchChildHandler, self).__init__(pm) if server_uri is None: raise RLException("server_uri is not initialized") self.run_id = run_id # parse the URI to make sure it's valid _, urlport = network.parse_http_host_and_port(server_uri) if urlport <= 0: raise RLException( "ERROR: roslaunch server URI is not a valid XML-RPC URI. Value is [%s]" % m.uri) self.name = name self.pm = pm self.server_uri = server_uri self.server = xmlrpclib.ServerProxy(server_uri)
def test_create_local_xmlrpc_uri(self): from roslib.network import parse_http_host_and_port, create_local_xmlrpc_uri self.assertEquals(type(create_local_xmlrpc_uri(1234)), str) os.environ['ROS_HOSTNAME'] = 'localhost' self.assertEquals(('localhost', 1234), parse_http_host_and_port(create_local_xmlrpc_uri(1234)))