def rtactivate(nameserver, tags, tree): def activate_action(object, ec_index): object.activate_in_ec(ec_index) for tag in tags: # check if/unless attribute in rtactivate tags exec_flag = True if tag.attributes.get(u'if'): val = tag.attributes.get(u'if').value arg = val.split(" ")[1].strip(")") # To "USE_WALKING" exec_flag = get_flag_from_argv(arg) if tag.attributes.get(u'unless'): val = tag.attributes.get(u'unless').value arg = val.split(" ")[1].strip(")") # To "USE_WALKING" exec_flag = not get_flag_from_argv(arg) if not exec_flag: continue cmd_path = nameserver + "/" + tag.attributes.get("component").value full_path = path.cmd_path_to_full_path(cmd_path) full_path = replace_arg_tag_by_env(full_path) # print >>sys.stderr, "[rtmlaunch] activate %s"%(full_path) try: state = wait_component(full_path, tree) if state == 'Active': continue else: print >> sys.stderr, "[rtmlaunch] Activate <-", state, full_path except Exception, e: print >> sys.stderr, '\033[31m[rtmlaunch] Could not Activate (', cmd_path, ') : ', e, '\033[0m' return 1 try: options = optparse.Values({"ec_index": 0, 'verbose': False}) try: state_control_base.alter_component_state(activate_action, cmd_path, full_path, options, tree=tree) except Exception, e: # openrtm 1.1.0 state_control_base.alter_component_states( activate_action, [(cmd_path, full_path)], options, tree=tree) except Exception, e: print >> sys.stderr, '[rtmlaunch] {0}: {1}'.format( os.path.basename(sys.argv[0]), e) return 1
def rtactivate(nameserver, tags, tree): def activate_action(object, ec_index): object.activate_in_ec(ec_index) for tag in tags: # check if/unless attribute in rtactivate tags exec_flag = True if tag.attributes.get(u'if'): val = tag.attributes.get(u'if').value arg = val.split(" ")[1].strip(")") # To "USE_WALKING" exec_flag = get_flag_from_argv(arg) if tag.attributes.get(u'unless'): val = tag.attributes.get(u'unless').value arg = val.split(" ")[1].strip(")") # To "USE_WALKING" exec_flag = not get_flag_from_argv(arg) if not exec_flag: continue cmd_path = nameserver+"/"+tag.attributes.get("component").value full_path = path.cmd_path_to_full_path(cmd_path) full_path = replace_arg_tag_by_env(full_path) # print >>sys.stderr, "[rtmlaunch] activate %s"%(full_path) try: state = wait_component(full_path, tree) if state == 'Active': continue else: print >>sys.stderr, "[rtmlaunch] Activate <-",state,full_path except Exception, e: print >>sys.stderr, '\033[31m[rtmlaunch] Could not Activate (', cmd_path, ') : ', e,'\033[0m' return 1 try: options = optparse.Values({"ec_index": 0, 'verbose': False}) try : state_control_base.alter_component_state(activate_action, cmd_path, full_path, options, tree=tree) except Exception, e: # openrtm 1.1.0 state_control_base.alter_component_states(activate_action, [(cmd_path, full_path)], options, tree=tree) except Exception, e: print >>sys.stderr, '[rtmlaunch] {0}: {1}'.format(os.path.basename(sys.argv[0]), e) return 1