def execute(self, state, args): state.run_config.merge_device_config(state.plugin_cache) if args.device: device = args.device device_config = {} else: device = state.run_config.device device_config = state.run_config.device_config or {} target_manager = TargetManager(device, device_config, None) target_manager.initialize() self.target = target_manager.target revent_file = self.target.path.join(self.target.working_directory, os.path.split(args.recording)[1]) self.logger.info("Pushing file to target") self.target.push(args.recording, self.target.working_directory) revent_recorder = ReventRecorder(target_manager.target) revent_recorder.deploy() if args.clear: self.target.execute('pm clear {}'.format(args.package)) if args.package: self.logger.info('Starting {}'.format(args.package)) cmd = 'monkey -p {} -c android.intent.category.LAUNCHER 1' self.target.execute(cmd.format(args.package)) self.logger.info("Starting replay") revent_recorder.replay(revent_file) self.logger.info("Finished replay") revent_recorder.remove()
class ReventGUI(object): def __init__(self, workload, target, setup_timeout, run_timeout, extract_results_timeout, teardown_timeout): self.workload = workload self.target = target self.setup_timeout = setup_timeout self.run_timeout = run_timeout self.extract_results_timeout = extract_results_timeout self.teardown_timeout = teardown_timeout self.revent_recorder = ReventRecorder(self.target) self.on_target_revent_binary = self.target.get_workpath('revent') self.on_target_setup_revent = self.target.get_workpath( '{}.setup.revent'.format(self.target.model)) self.on_target_run_revent = self.target.get_workpath( '{}.run.revent'.format(self.target.model)) self.on_target_extract_results_revent = self.target.get_workpath( '{}.extract_results.revent'.format(self.target.model)) self.on_target_teardown_revent = self.target.get_workpath( '{}.teardown.revent'.format(self.target.model)) self.logger = logging.getLogger('revent') self.revent_setup_file = None self.revent_run_file = None self.revent_extract_results_file = None self.revent_teardown_file = None def init_resources(self, resolver): self.revent_setup_file = resolver.get(ReventFile( owner=self.workload, stage='setup', target=self.target.model), strict=False) self.revent_run_file = resolver.get( ReventFile(owner=self.workload, stage='run', target=self.target.model)) self.revent_extract_results_file = resolver.get(ReventFile( owner=self.workload, stage='extract_results', target=self.target.model), strict=False) self.revent_teardown_file = resolver.get(resource=ReventFile( owner=self.workload, stage='teardown', target=self.target.model), strict=False) def deploy(self): self.revent_recorder.deploy() def setup(self): self._check_revent_files() if self.revent_setup_file: self.revent_recorder.replay(self.on_target_setup_revent, timeout=self.setup_timeout) def run(self): msg = 'Replaying {}' self.logger.debug( msg.format(os.path.basename(self.on_target_run_revent))) self.revent_recorder.replay(self.on_target_run_revent, timeout=self.run_timeout) self.logger.debug('Replay completed.') def extract_results(self): if self.revent_extract_results_file: self.revent_recorder.replay(self.on_target_extract_results_revent, timeout=self.extract_results_timeout) def teardown(self): if self.revent_teardown_file: self.revent_recorder.replay(self.on_target_teardown_revent, timeout=self.teardown_timeout) def remove(self): self.target.remove(self.on_target_setup_revent) self.target.remove(self.on_target_run_revent) self.target.remove(self.on_target_extract_results_revent) self.target.remove(self.on_target_teardown_revent) self.revent_recorder.remove() def _check_revent_files(self): if not self.revent_run_file: # pylint: disable=too-few-format-args message = '{0}.run.revent file does not exist, ' \ 'Please provide one for your target, {0}' raise WorkloadError(message.format(self.target.model)) self.target.push(self.revent_run_file, self.on_target_run_revent) if self.revent_setup_file: self.target.push(self.revent_setup_file, self.on_target_setup_revent) if self.revent_extract_results_file: self.target.push(self.revent_extract_results_file, self.on_target_extract_results_revent) if self.revent_teardown_file: self.target.push(self.revent_teardown_file, self.on_target_teardown_revent)
class ReventGUI(object): def __init__(self, workload, target, setup_timeout, run_timeout, extract_results_timeout, teardown_timeout): self.workload = workload self.target = target self.setup_timeout = setup_timeout self.run_timeout = run_timeout self.extract_results_timeout = extract_results_timeout self.teardown_timeout = teardown_timeout self.revent_recorder = ReventRecorder(self.target) self.on_target_revent_binary = self.target.get_workpath('revent') self.on_target_setup_revent = self.target.get_workpath('{}.setup.revent'.format(self.target.model)) self.on_target_run_revent = self.target.get_workpath('{}.run.revent'.format(self.target.model)) self.on_target_extract_results_revent = self.target.get_workpath('{}.extract_results.revent'.format(self.target.model)) self.on_target_teardown_revent = self.target.get_workpath('{}.teardown.revent'.format(self.target.model)) self.logger = logging.getLogger('revent') self.revent_setup_file = None self.revent_run_file = None self.revent_extract_results_file = None self.revent_teardown_file = None def init_resources(self, resolver): self.revent_setup_file = resolver.get(ReventFile(owner=self.workload, stage='setup', target=self.target.model), strict=False) self.revent_run_file = resolver.get(ReventFile(owner=self.workload, stage='run', target=self.target.model)) self.revent_extract_results_file = resolver.get(ReventFile(owner=self.workload, stage='extract_results', target=self.target.model), strict=False) self.revent_teardown_file = resolver.get(resource=ReventFile(owner=self.workload, stage='teardown', target=self.target.model), strict=False) def deploy(self): self.revent_recorder.deploy() def setup(self): self._check_revent_files() if self.revent_setup_file: self.revent_recorder.replay(self.on_target_setup_revent, timeout=self.setup_timeout) def run(self): msg = 'Replaying {}' self.logger.debug(msg.format(os.path.basename(self.on_target_run_revent))) self.revent_recorder.replay(self.on_target_run_revent, timeout=self.run_timeout) self.logger.debug('Replay completed.') def extract_results(self): if self.revent_extract_results_file: self.revent_recorder.replay(self.on_target_extract_results_revent, timeout=self.extract_results_timeout) def teardown(self): if self.revent_teardown_file: self.revent_recorder.replay(self.on_target_teardown_revent, timeout=self.teardown_timeout) self.target.remove(self.on_target_setup_revent) self.target.remove(self.on_target_run_revent) self.target.remove(self.on_target_extract_results_revent) self.target.remove(self.on_target_teardown_revent) def remove(self): self.revent_recorder.remove() def _check_revent_files(self): if not self.revent_run_file: # pylint: disable=too-few-format-args message = '{0}.run.revent file does not exist, ' \ 'Please provide one for your target, {0}' raise WorkloadError(message.format(self.target.model)) self.target.push(self.revent_run_file, self.on_target_run_revent) if self.revent_setup_file: self.target.push(self.revent_setup_file, self.on_target_setup_revent) if self.revent_extract_results_file: self.target.push(self.revent_extract_results_file, self.on_target_extract_results_revent) if self.revent_teardown_file: self.target.push(self.revent_teardown_file, self.on_target_teardown_revent)