def init_run_output(path, wa_state, force=False): if os.path.exists(path): if force: logger.info('Removing existing output directory.') shutil.rmtree(os.path.abspath(path)) else: raise RuntimeError('path exists: {}'.format(path)) logger.info('Creating output directory.') os.makedirs(path) meta_dir = os.path.join(path, '__meta') os.makedirs(meta_dir) _save_raw_config(meta_dir, wa_state) touch(os.path.join(path, 'run.log')) info = RunInfo( run_name=wa_state.run_config.run_name, project=wa_state.run_config.project, project_stage=wa_state.run_config.project_stage, ) write_pod(info.to_pod(), os.path.join(meta_dir, 'run_info.json')) write_pod(RunState().to_pod(), os.path.join(path, '.run_state.json')) write_pod(Result().to_pod(), os.path.join(path, 'result.json')) ro = RunOutput(path) ro.update_metadata('versions', 'wa', get_wa_version_with_commit()) ro.update_metadata('versions', 'devlib', devlib.__full_version__) return ro
ResourceError, TargetError, TargetNotRespondingError, TimeoutError, ToolError, ValidationError, WAError, WorkloadError, WorkerThreadError) from wa.framework.instrument import (Instrument, extremely_slow, very_slow, slow, normal, fast, very_fast, extremely_fast, hostside) from wa.framework.output import RunOutput, discover_wa_outputs from wa.framework.output_processor import OutputProcessor from wa.framework.plugin import Plugin, Parameter, Alias from wa.framework.resource import (NO_ONE, JarFile, ApkFile, ReventFile, File, Executable) from wa.framework.target.descriptor import (TargetDescriptor, TargetDescription, create_target_description, add_description_for_target) from wa.framework.workload import (Workload, ApkWorkload, ApkUiautoWorkload, ApkReventWorkload, UIWorkload, UiautoWorkload, PackageHandler, ReventWorkload, TestPackageHandler) from wa.framework.version import get_wa_version, get_wa_version_with_commit __version__ = get_wa_version() __full_version__ = get_wa_version_with_commit()
# limitations under the License. # from wa.framework import pluginloader, signal from wa.framework.command import Command, ComplexCommand, SubCommand from wa.framework.configuration import settings from wa.framework.configuration.core import Status from wa.framework.exception import (CommandError, ConfigError, HostError, InstrumentError, # pylint: disable=redefined-builtin JobError, NotFoundError, OutputProcessorError, PluginLoaderError, ResourceError, TargetError, TargetNotRespondingError, TimeoutError, ToolError, ValidationError, WAError, WorkloadError, WorkerThreadError) from wa.framework.instrument import (Instrument, extremely_slow, very_slow, slow, normal, fast, very_fast, extremely_fast, hostside) from wa.framework.output import RunOutput, discover_wa_outputs from wa.framework.output_processor import OutputProcessor from wa.framework.plugin import Plugin, Parameter, Alias from wa.framework.resource import (NO_ONE, JarFile, ApkFile, ReventFile, File, Executable) from wa.framework.target.descriptor import (TargetDescriptor, TargetDescription, create_target_description, add_description_for_target) from wa.framework.workload import (Workload, ApkWorkload, ApkUiautoWorkload, ApkReventWorkload, UIWorkload, UiautoWorkload, ReventWorkload) from wa.framework.version import get_wa_version, get_wa_version_with_commit __version__ = get_wa_version() __full_version__ = get_wa_version_with_commit()
def main(): if not os.path.exists(settings.user_directory): init_user_directory() if not os.path.exists(os.path.join(settings.user_directory, 'config.yaml')): init_config() try: description = ( "Execute automated workloads on a remote device and process " "the resulting output.\n\nUse \"wa <subcommand> -h\" to see " "help for individual subcommands.") parser = argparse.ArgumentParser( description=format_body(description, 80), prog='wa', formatter_class=argparse.RawDescriptionHelpFormatter, ) init_argument_parser(parser) # load_commands will trigger plugin enumeration, and we want logging # to be enabled for that, which requires the verbosity setting; however # full argument parsing cannot be completed until the commands are loaded; so # parse just the base args for now so we can get verbosity. argv = split_joined_options(sys.argv[1:]) # 'Parse_known_args' automatically displays the default help and exits # if '-h' or '--help' is detected, we want our custom help messages so # ensure these are never passed as parameters. filtered_argv = list(argv) if '-h' in filtered_argv: filtered_argv.remove('-h') elif '--help' in filtered_argv: filtered_argv.remove('--help') args, _ = parser.parse_known_args(filtered_argv) settings.set("verbosity", args.verbose) log.init(settings.verbosity) logger.debug('Version: {}'.format(get_wa_version_with_commit())) logger.debug('devlib version: {}'.format(devlib.__full_version__)) logger.debug('Command Line: {}'.format(' '.join(sys.argv))) check_devlib_version() # each command will add its own subparser subparsers = parser.add_subparsers(dest='command') subparsers.required = True commands = load_commands(subparsers) args = parser.parse_args(argv) config = ConfigManager() config.load_config_file(settings.user_config_file) for config_file in args.config: if not os.path.exists(config_file): raise ConfigError( "Config file {} not found".format(config_file)) config.load_config_file(config_file) command = commands[args.command] sys.exit(command.execute(config, args)) except KeyboardInterrupt as e: log.log_error(e, logger) sys.exit(3) except Exception as e: # pylint: disable=broad-except log.log_error(e, logger) sys.exit(2)
def main(): if not os.path.exists(settings.user_directory): init_user_directory() if not os.path.exists(os.path.join(settings.user_directory, 'config.yaml')): init_config() try: description = ("Execute automated workloads on a remote device and process " "the resulting output.\n\nUse \"wa <subcommand> -h\" to see " "help for individual subcommands.") parser = argparse.ArgumentParser(description=format_body(description, 80), prog='wa', formatter_class=argparse.RawDescriptionHelpFormatter, ) init_argument_parser(parser) # load_commands will trigger plugin enumeration, and we want logging # to be enabled for that, which requires the verbosity setting; however # full argument parsing cannot be completed until the commands are loaded; so # parse just the base args for now so we can get verbosity. argv = split_joined_options(sys.argv[1:]) # 'Parse_known_args' automatically displays the default help and exits # if '-h' or '--help' is detected, we want our custom help messages so # ensure these are never passed as parameters. filtered_argv = list(argv) if '-h' in filtered_argv: filtered_argv.remove('-h') elif '--help' in filtered_argv: filtered_argv.remove('--help') args, _ = parser.parse_known_args(filtered_argv) settings.set("verbosity", args.verbose) log.init(settings.verbosity) logger.debug('Version: {}'.format(get_wa_version_with_commit())) logger.debug('devlib version: {}'.format(devlib.__full_version__)) logger.debug('Command Line: {}'.format(' '.join(sys.argv))) # each command will add its own subparser subparsers = parser.add_subparsers(dest='command') subparsers.required = True commands = load_commands(subparsers) args = parser.parse_args(argv) config = ConfigManager() config.load_config_file(settings.user_config_file) for config_file in args.config: if not os.path.exists(config_file): raise ConfigError("Config file {} not found".format(config_file)) config.load_config_file(config_file) command = commands[args.command] sys.exit(command.execute(config, args)) except KeyboardInterrupt as e: log.log_error(e, logger) sys.exit(3) except Exception as e: # pylint: disable=broad-except log.log_error(e, logger) sys.exit(2)