def main(argv): parser = bb_utils.GetParser() parser.add_option('--bot-id', help='Specify bot id directly.') parser.add_option('--testing', action='store_true', help='For testing: print, but do not run commands') options, args = parser.parse_args(argv[1:]) if args: parser.error('Unused args: %s' % args) bot_id = options.bot_id or options.factory_properties.get('android_bot_id') if not bot_id: parser.error( 'A bot id must be specified through option or factory_props.') # Get a BotConfig object looking first for an exact bot-id match. If no exact # match, look for a bot-id which is a substring of the specified id. # This allows similar bots to have unique IDs, but to share config. # If multiple substring matches exist, pick the longest one. bot_map = GetBotStepMap() bot_config = bot_map.get(bot_id) if not bot_config: substring_matches = filter(lambda x: x in bot_id, bot_map.iterkeys()) if substring_matches: max_id = max(substring_matches, key=len) print 'Using config from id="%s" (substring match).' % max_id bot_config = bot_map[max_id] if not bot_config: print 'Error: config for id="%s" cannot be inferred.' % bot_id return 1 print 'Using config:', bot_config commands = GetCommands(options, bot_config) for command in commands: print 'Will run: ', bb_utils.CommandToString(command) print env = GetEnvironment(bot_config.host_obj, options.testing) print 'Environment changes:' print DictDiff(dict(os.environ), env) for command in commands: print bb_utils.CommandToString(command) sys.stdout.flush() if options.testing: env['BUILDBOT_TESTING'] = '1' return_code = subprocess.call(command, cwd=bb_utils.CHROME_SRC, env=env) if return_code != 0: return return_code
def main(argv): proc = subprocess.Popen(['/bin/hostname', '-f'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) hostname_stdout, hostname_stderr = proc.communicate() if proc.returncode == 0: print 'Running on: ' + hostname_stdout else: print >> sys.stderr, 'WARNING: failed to run hostname' print >> sys.stderr, hostname_stdout print >> sys.stderr, hostname_stderr sys.exit(1) parser = GetRunBotOptParser() options, args = parser.parse_args(argv[1:]) if args: parser.error('Unused args: %s' % args) bot_config = GetBotConfig(options, GetBotStepMap()) if not bot_config: sys.exit(1) print 'Using config:', bot_config commands = GetCommands(options, bot_config) for command in commands: print 'Will run: ', bb_utils.CommandToString(command) print env = GetEnvironment(bot_config.host_obj, options.testing) return RunBotCommands(options, commands, env)
def RunBotCommands(options, commands, env): print 'Environment changes:' print DictDiff(dict(os.environ), env) for command in commands: print bb_utils.CommandToString(command) sys.stdout.flush() if options.testing: env['BUILDBOT_TESTING'] = '1' return_code = subprocess.call(command, cwd=bb_utils.CHROME_SRC, env=env) if return_code != 0: return return_code
def main(argv): parser = GetRunBotOptParser() options, args = parser.parse_args(argv[1:]) if args: parser.error('Unused args: %s' % args) bot_config = GetBotConfig(options, GetBotStepMap()) if not bot_config: sys.exit(1) print 'Using config:', bot_config commands = GetCommands(options, bot_config) for command in commands: print 'Will run: ', bb_utils.CommandToString(command) print env = GetEnvironment(bot_config.host_obj, options.testing) return RunBotCommands(options, commands, env)