How to use handle_output_files_command method in avocado

Best Python code snippet using avocado_python

jobs.py

Source:jobs.py Github

copy

Full Screen

...143 except SpawnerException as ex:144 LOG_UI.error("Error: Failed to download: %s. Exiting...", ex)145 return exit_codes.AVOCADO_GENERIC_CRASH146 return exit_codes.AVOCADO_ALL_OK147 def handle_output_files_command(self, config):148 """Called when 'avocado jobs get-output-files' command is executed."""149 job_id = config.get('jobs.get.output_files.job_id')150 destination = config.get('jobs.get.output_files.destination')151 results_dir = get_job_results_dir(job_id)152 results_file = os.path.join(results_dir, 'results.json')153 config_file = os.path.join(results_dir, 'jobdata/args.json')154 try:155 config_data = self._get_data_from_file(config_file)156 results_data = self._get_data_from_file(results_file)157 except FileNotFoundError as ex:158 LOG_UI.error("Could not get job information: %s", ex)159 return exit_codes.AVOCADO_GENERIC_CRASH160 spawners = {'process': ProcessSpawner,161 'podman': PodmanSpawner}162 spawner_name = config_data.get('nrunner.spawner')163 spawner = spawners.get(spawner_name)164 if spawner is None:165 msg = ("Could not find the spawner for job %s. This command is "166 "experimental and only supported when job executed with "167 "the Spawner architecture.")168 LOG_UI.error(msg, job_id)169 return exit_codes.AVOCADO_GENERIC_CRASH170 return self._download_tests(results_data.get('tests'),171 destination,172 job_id,173 spawner)174 def handle_show_command(self, config):175 """Called when 'avocado jobs show' command is executed."""176 job_id = config.get('jobs.show.job_id')177 results_dir = get_job_results_dir(job_id)178 if results_dir is None:179 LOG_UI.error("Error: Job %s not found", job_id)180 return exit_codes.AVOCADO_GENERIC_CRASH181 results_file = os.path.join(results_dir, 'results.json')182 config_file = os.path.join(results_dir, 'jobdata/args.json')183 try:184 results_data = self._get_data_from_file(results_file)185 except FileNotFoundError as ex:186 # Results data are important and should exit if not found187 LOG_UI.error(ex)188 return exit_codes.AVOCADO_GENERIC_CRASH189 try:190 config_data = self._get_data_from_file(config_file)191 except FileNotFoundError:192 pass193 data = {'JOB ID': job_id,194 'JOB LOG': results_data.get('debuglog'),195 'SPAWNER': config_data.get('nrunner.spawner', 'unknown')}196 # We could improve this soon with more data and colors197 self._print_job_details(data)198 LOG_UI.info("")199 self._print_job_tests(results_data.get('tests'))200 results = ('PASS %d | ERROR %d | FAIL %d | SKIP %d |'201 'WARN %d | INTERRUPT %s | CANCEL %s')202 results %= (results_data.get('pass', 0),203 results_data.get('error', 0),204 results_data.get('failures', 0),205 results_data.get('skip', 0),206 results_data.get('warn', 0),207 results_data.get('interrupt', 0),208 results_data.get('cancel', 0))209 self._print_job_details({'RESULTS': results})210 return exit_codes.AVOCADO_ALL_OK211 def run(self, config):212 results = {}213 jobs_dir = get_logs_dir()214 for result in glob(os.path.join(jobs_dir, '*/results.json')):215 with open(result, 'r') as fp:216 job = json.load(fp)217 results[job['job_id']] = result218 subcommand = config.get('jobs_subcommand')219 if subcommand == 'list':220 return self.handle_list_command(results)221 elif subcommand == 'show':222 return self.handle_show_command(config)223 elif subcommand == 'get-output-files':224 return self.handle_output_files_command(config)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful