How to use copy_client_config_file method in autotest

Best Python code snippet using autotest_python

autotest.py

Source:autotest.py Github

copy

Full Screen

...418 _, number, _ = log.split('.', 2)419 if number.isdigit():420 max_digit = max(max_digit, int(number))421 return 'client.%d' % (max_digit + 1)422 def copy_client_config_file(self, client_log_prefix=None):423 """424 Create and copy the client config file based on the server config.425 @param client_log_prefix: Optional prefix to prepend to log files.426 """427 client_config_file = self._create_client_config_file(client_log_prefix)428 self.host.send_file(client_config_file, self.config_file)429 os.remove(client_config_file)430 def _create_client_config_file(self, client_log_prefix=None):431 """432 Create a temporary file with the [CLIENT] section configuration values433 taken from the server global_config.ini.434 @param client_log_prefix: Optional prefix to prepend to log files.435 @return: Path of the temporary file generated.436 """437 config = global_config.global_config.get_section_values('CLIENT')438 if client_log_prefix:439 config.set('CLIENT', 'default_logging_name', client_log_prefix)440 return self._create_aux_file(config.write)441 def _create_aux_file(self, func, *args):442 """443 Creates a temporary file and writes content to it according to a444 content creation function. The file object is appended to *args, which445 is then passed to the content creation function446 @param func: Function that will be used to write content to the447 temporary file.448 @param *args: List of parameters that func takes.449 @return: Path to the temporary file that was created.450 """451 fd, path = tempfile.mkstemp(dir=self.host.job.tmpdir)452 aux_file = os.fdopen(fd, "w")453 try:454 list_args = list(args)455 list_args.append(aux_file)456 func(*list_args)457 finally:458 aux_file.close()459 return path460 @staticmethod461 def is_client_job_finished(last_line):462 return bool(re.match(r'^END .*\t----\t----\t.*$', last_line))463 @staticmethod464 def is_client_job_rebooting(last_line):465 return bool(re.match(r'^\t*GOOD\t----\treboot\.start.*$', last_line))466 def log_unexpected_abort(self, stderr_redirector):467 stderr_redirector.flush_all_buffers()468 msg = "Autotest client terminated unexpectedly"469 self.host.job.record("END ABORT", None, None, msg)470 def _execute_in_background(self, section, timeout):471 full_cmd = self.get_background_cmd(section)472 devnull = open(os.devnull, "w")473 self.copy_client_config_file(self.get_client_log())474 self.host.job.push_execution_context(self.results_dir)475 try:476 result = self.host.run(full_cmd, ignore_status=True,477 timeout=timeout,478 stdout_tee=devnull,479 stderr_tee=devnull)480 finally:481 self.host.job.pop_execution_context()482 return result483 @staticmethod484 def _strip_stderr_prologue(stderr):485 """Strips the 'standard' prologue that get pre-pended to every486 remote command and returns the text that was actually written to487 stderr by the remote command."""488 stderr_lines = stderr.split("\n")[1:]489 if not stderr_lines:490 return ""491 elif stderr_lines[0].startswith("NOTE: autotestd_monitor"):492 del stderr_lines[0]493 return "\n".join(stderr_lines)494 def _execute_daemon(self, section, timeout, stderr_redirector,495 client_disconnect_timeout):496 monitor_dir = self.host.get_tmp_dir()497 daemon_cmd = self.get_daemon_cmd(section, monitor_dir)498 # grab the location for the server-side client log file499 client_log_prefix = self.get_client_log()500 client_log_path = os.path.join(self.results_dir, 'debug',501 client_log_prefix + '.log')502 client_log = open(client_log_path, 'w', 0)503 self.copy_client_config_file(client_log_prefix)504 stdout_read = stderr_read = 0505 self.host.job.push_execution_context(self.results_dir)506 try:507 self.host.run(daemon_cmd, ignore_status=True, timeout=timeout)508 disconnect_warnings = []509 while True:510 monitor_cmd = self.get_monitor_cmd(monitor_dir, stdout_read,511 stderr_read)512 try:513 result = self.host.run(monitor_cmd, ignore_status=True,514 timeout=timeout,515 stdout_tee=client_log,516 stderr_tee=stderr_redirector)517 except error.AutoservRunError, e:...

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 autotest 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