def _SetUpProcess(child, context): # pylint: disable=unused-argument ps_util.EnableListingStrayProcessesUponExitHook() if binary_manager.NeedsInit(): # Typ doesn't keep the DependencyManager initialization in the child # processes. binary_manager.InitDependencyManager(context.client_config) # We need to reset the handlers in case some other parts of telemetry already # set it to make this work. logging.getLogger().handlers = [] logging.basicConfig( level=logging.INFO, format='(%(levelname)s) %(asctime)s %(module)s.%(funcName)s:%(lineno)d ' '%(message)s') args = context if not args.disable_logging_config: logging.getLogger().handlers = [] logging.basicConfig( level=logging.INFO, format= '(%(levelname)s) %(asctime)s %(module)s.%(funcName)s:%(lineno)d' ' %(message)s') if args.device and args.device == 'android': android_devices = android_device.FindAllAvailableDevices(args) if not android_devices: raise RuntimeError("No Android device found") android_devices.sort(key=lambda device: device.name) args.device = android_devices[child.worker_num - 1].guid options_for_unittests.Push(args)
def _SetUpProcess(child, context): # pylint: disable=unused-argument ps_util.EnableListingStrayProcessesUponExitHook() # Make sure that we don't invokes cloud storage I/Os when we run the tests in # parallel. # TODO(nednguyen): always do this once telemetry tests in Chromium is updated # to prefetch files. # (https://github.com/catapult-project/catapult/issues/2192) args = context if args.disable_cloud_storage_io: os.environ[cloud_storage.DISABLE_CLOUD_STORAGE_IO] = '1' if binary_manager.NeedsInit(): # Typ doesn't keep the DependencyManager initialization in the child # processes. binary_manager.InitDependencyManager(context.client_configs) # We need to reset the handlers in case some other parts of telemetry already # set it to make this work. if not args.disable_logging_config: logging.getLogger().handlers = [] logging.basicConfig( level=logging.INFO, format='(%(levelname)s) %(asctime)s pid=%(process)d' ' %(module)s.%(funcName)s:%(lineno)d' ' %(message)s') if args.remote_platform_options.device == 'android': android_devices = android_device.FindAllAvailableDevices(args) if not android_devices: raise RuntimeError("No Android device found") android_devices.sort(key=lambda device: device.name) args.remote_platform_options.device = ( android_devices[child.worker_num - 1].guid) options_for_unittests.Push(args)
def main(environment): # The log level is set in browser_options. # Clear the log handlers to ensure we can set up logging properly here. logging.getLogger().handlers = [] logging.basicConfig(format=DEFAULT_LOG_FORMAT) ps_util.EnableListingStrayProcessesUponExitHook() # Get the command name from the command line. if len(sys.argv) > 1 and sys.argv[1] == '--help': sys.argv[1] = 'help' command_name = 'run' for arg in sys.argv[1:]: if not arg.startswith('-'): command_name = arg break # TODO(eakuefner): Remove this hack after we port to argparse. if command_name == 'help' and len(sys.argv) > 2 and sys.argv[2] == 'run': command_name = 'run' sys.argv[2] = '--help' # Validate and interpret the command name. matching_commands = commands.MatchingCommands(command_name) if len(matching_commands) > 1: print >> sys.stderr, ( '"%s" is not a %s command. Did you mean one of these?' % (command_name, commands.ScriptName())) for command in matching_commands: print >> sys.stderr, ' %-10s %s' % (command.Name(), command.Description()) return 1 if matching_commands: command = matching_commands[0] else: command = commands.Run binary_manager.InitDependencyManager(environment.client_configs) # Parse and run the command. parser = command.CreateParser() command.AddCommandLineArgs(parser, environment) # Set the default chrome root variable. parser.set_defaults(chrome_root=environment.default_chrome_root) options, args = parser.parse_args() if matching_commands: args = args[1:] options.positional_args = args command.ProcessCommandLineArgs(parser, options, environment) return_code = command().Run(options) if return_code == -1: logging.warn('No stories were run.') return 0 return return_code
def RunCommand(options): """Run a selected command from parsed command line args. Args: options: The return value from ParseArgs. Returns: The exit_code from the command execution. """ ps_util.EnableListingStrayProcessesUponExitHook() return_code = _COMMANDS[options.command]().Run(options) if return_code == exit_codes.ALL_TESTS_SKIPPED: logging.warning('No stories were run.') return return_code
def main(environment): ps_util.EnableListingStrayProcessesUponExitHook() # Get the command name from the command line. if len(sys.argv) > 1 and sys.argv[1] == '--help': sys.argv[1] = 'help' command_name = 'run' for arg in sys.argv[1:]: if not arg.startswith('-'): command_name = arg break # TODO(eakuefner): Remove this hack after we port to argparse. if command_name == 'help' and len(sys.argv) > 2 and sys.argv[2] == 'run': command_name = 'run' sys.argv[2] = '--help' # Validate and interpret the command name. commands = _MatchingCommands(command_name) if len(commands) > 1: print >> sys.stderr, ('"%s" is not a %s command. Did you mean one of these?' % (command_name, _ScriptName())) for command in commands: print >> sys.stderr, ' %-10s %s' % ( command.Name(), command.Description()) return 1 if commands: command = commands[0] else: command = Run binary_manager.InitDependencyManager(environment.client_config) # Parse and run the command. parser = command.CreateParser() command.AddCommandLineArgs(parser, environment) # Set the default chrome root variable. parser.set_defaults(chrome_root=environment.default_chrome_root) options, args = parser.parse_args() if commands: args = args[1:] options.positional_args = args command.ProcessCommandLineArgs(parser, options, environment) return command().Run(options)
def main(environment, extra_commands=None, **log_config_kwargs): # The log level is set in browser_options. log_config_kwargs.pop('level', None) log_config_kwargs.setdefault('format', DEFAULT_LOG_FORMAT) logging.basicConfig(**log_config_kwargs) ps_util.EnableListingStrayProcessesUponExitHook() # Get the command name from the command line. if len(sys.argv) > 1 and sys.argv[1] == '--help': sys.argv[1] = 'help' command_name = 'run' for arg in sys.argv[1:]: if not arg.startswith('-'): command_name = arg break # TODO(eakuefner): Remove this hack after we port to argparse. if command_name == 'help' and len(sys.argv) > 2 and sys.argv[2] == 'run': command_name = 'run' sys.argv[2] = '--help' if extra_commands is None: extra_commands = [] all_commands = [Help, List, Run] + extra_commands # Validate and interpret the command name. commands = _MatchingCommands(command_name, all_commands) if len(commands) > 1: print >> sys.stderr, ('"%s" is not a %s command. Did you mean one of these?' % (command_name, _ScriptName())) for command in commands: print >> sys.stderr, ' %-10s %s' % ( command.Name(), command.Description()) return 1 if commands: command = commands[0] else: command = Run binary_manager.InitDependencyManager(environment.client_configs) # Parse and run the command. parser = command.CreateParser() command.AddCommandLineArgs(parser, environment) # Set the default chrome root variable. parser.set_defaults(chrome_root=environment.default_chrome_root) if isinstance(parser, argparse.ArgumentParser): commandline_args = sys.argv[1:] options, args = parser.parse_known_args(commandline_args[1:]) command.ProcessCommandLineArgs(parser, options, args, environment) else: options, args = parser.parse_args() if commands: args = args[1:] options.positional_args = args command.ProcessCommandLineArgs(parser, options, environment) if command == Help: command_instance = command(all_commands) else: command_instance = command() if isinstance(command_instance, command_line.OptparseCommand): return command_instance.Run(options) else: return command_instance.Run(options, args)
'cmd': ' '.join(base_cmd + [ '--browser=reference', '--output-trace-tag=_ref']), 'device_affinity': device_affinity, 'perf_dashboard_id': perf_dashboard_id, } return json.dumps(output, indent=2, sort_keys=True) def presentation.main(environment, extra_commands=None, **log_config_kwargs): # The log level is set in browser_options. log_config_kwargs.pop('level', None) log_config_kwargs.setdefault('format', DEFAULT_LOG_FORMAT) logging.basicConfig(**log_config_kwargs) ps_util.EnableListingStrayProcessesUponExitHook() # Get the command name from the command line. if len(sys.argv) > 1 and sys.argv[1] == '--help': sys.argv[1] = 'help' command_name = 'run' for arg in sys.argv[1:]: if not arg.startswith('-'): command_name = arg break # TODO(eakuefner): Remove this hack after we port to argparse. if command_name == 'help' and len(sys.argv) > 2 and sys.argv[2] == 'run': command_name = 'run' sys.argv[2] = '--help'