def main(args): subprocess42.inhibit_os_error_reporting() # Disable magical auto-detection of OAuth config. See main() in bot_main.py # for detailed explanation why. net.disable_oauth_config() parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) parser.add_option('--in-file', help='Name of the request file') parser.add_option( '--out-file', help='Name of the JSON file to write a task summary to') parser.add_option( '--swarming-server', help='Swarming server to send data back') parser.add_option( '--is-grpc', action='store_true', help='If true, --swarming-server is a gRPC proxy') parser.add_option( '--cost-usd-hour', type='float', help='Cost of this VM in $/h') parser.add_option('--start', type='float', help='Time this task was started') parser.add_option( '--bot-file', help='Path to a file describing the state of the host.') parser.add_option( '--auth-params-file', help='Path to a file with bot authentication parameters') options, args = parser.parse_args(args) if not options.in_file or not options.out_file: parser.error('task_runner is meant to be used by swarming_bot.') on_error.report_on_exception_exit(options.swarming_server) logging.info('starting') now = monotonic_time() if options.start > now: options.start = now try: load_and_run( options.in_file, options.swarming_server, options.is_grpc, options.cost_usd_hour, options.start, options.out_file, args, options.bot_file, options.auth_params_file) return 0 finally: logging.info('quitting')
def main(args): subprocess42.inhibit_os_error_reporting() parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) parser.add_option('--in-file', help='Name of the request file') parser.add_option('--out-file', help='Name of the JSON file to write a task summary to') parser.add_option('--swarming-server', help='Swarming server to send data back') parser.add_option('--cost-usd-hour', type='float', help='Cost of this VM in $/h') parser.add_option('--start', type='float', help='Time this task was started') parser.add_option('--min-free-space', type='int', help='Value to send down to run_isolated') parser.add_option('--bot-file', help='Path to a file describing the state of the host.') parser.add_option('--auth-params-file', help='Path to a file with bot authentication parameters') options, args = parser.parse_args(args) if not options.in_file or not options.out_file or args: parser.error('task_runner is meant to be used by swarming_bot.') on_error.report_on_exception_exit(options.swarming_server) logging.info('starting') now = monotonic_time() if options.start > now: options.start = now try: load_and_run(options.in_file, options.swarming_server, options.cost_usd_hour, options.start, options.out_file, options.min_free_space, options.bot_file, options.auth_params_file) return 0 finally: logging.info('quitting')
def main(args): subprocess42.inhibit_os_error_reporting() # Add SWARMING_HEADLESS into environ so subcommands know that they are running # in a headless (non-interactive) mode. os.environ['SWARMING_HEADLESS'] = '1' # The only reason this is kept is to enable the unit test to use --help to # quit the process. parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) _, args = parser.parse_args(args) # Enforces that only one process with a bot in this directory can be run on # this host at once. if not SINGLETON.acquire(): if sys.platform == 'darwin': msg = ('Found a previous bot, %d rebooting as a workaround for ' 'https://crbug.com/569610.') % os.getpid() print >> sys.stderr, msg os_utilities.restart(msg) else: print >> sys.stderr, 'Found a previous bot, %d exiting.' % os.getpid( ) return 1 base_dir = os.path.dirname(THIS_FILE) for t in ('out', 'err'): log_path = os.path.join(base_dir, 'logs', 'bot_std%s.log' % t) os_utilities.roll_log(log_path) os_utilities.trim_rolled_log(log_path) error = None if len(args) != 0: error = 'Unexpected arguments: %s' % args try: return run_bot(error) finally: call_hook(bot.Bot(None, None, None, None, base_dir, None), 'on_bot_shutdown') logging.info('main() returning')
'--service', metavar='URL', default='', help='Service to use') self.add_option_group(self.server_group) add_auth_options(self) def parse_args(self, *args, **kwargs): options, args = logging_utils.OptionParserWithLogging.parse_args( self, *args, **kwargs) if not options.service: self.error('--service is required.') try: options.service = normalize_host_url(options.service) except ValueError as exc: self.error(str(exc)) return options, args def main(args): dispatcher = subcommand.CommandDispatcher(__name__) return dispatcher.execute(OptionParserAuth(version=__version__), args) if __name__ == '__main__': subprocess42.inhibit_os_error_reporting() fix_encoding.fix_encoding() tools.disable_buffering() colorama.init() sys.exit(main(sys.argv[1:]))