How to use get_background_cmd method in autotest

Best Python code snippet using autotest_python

autotest.py

Source:autotest.py Github

copy

Full Screen

...390 args.append('--hostname=%s' % self.host.hostname)391 args.append('--user=%s' % self.host.job.user)392 args.append(self.remote_control_file)393 return args394 def get_background_cmd(self, section):395 cmd = ['nohup', os.path.join(self.autodir, 'bin/autotest_client')]396 cmd += self.get_base_cmd_args(section)397 cmd += ['>/dev/null', '2>/dev/null', '&']398 return ' '.join(cmd)399 def get_daemon_cmd(self, section, monitor_dir):400 cmd = ['nohup', os.path.join(self.autodir, 'bin/autotestd'),401 monitor_dir, '-H autoserv']402 cmd += self.get_base_cmd_args(section)403 cmd += ['>/dev/null', '2>/dev/null', '&']404 return ' '.join(cmd)405 def get_monitor_cmd(self, monitor_dir, stdout_read, stderr_read):406 cmd = [os.path.join(self.autodir, 'bin', 'autotestd_monitor'),407 monitor_dir, str(stdout_read), str(stderr_read)]408 return ' '.join(cmd)409 def get_client_log(self):410 """Find what the "next" client.* prefix should be411 @returns A string of the form client.INTEGER that should be prefixed412 to all client debug log files.413 """414 max_digit = -1415 debug_dir = os.path.join(self.results_dir, 'debug')416 client_logs = glob.glob(os.path.join(debug_dir, 'client.*.*'))417 for log in client_logs: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 every...

Full Screen

Full Screen

test_utils.py

Source:test_utils.py Github

copy

Full Screen

...19 @patch('backgroundchanger.utils.distro_name')20 def test_linux_cmd(self, mock_distro, mock_platform):21 mock_distro.return_value = 'Ubuntu'22 mock_platform.return_value = 'Linux'23 res = utils.get_background_cmd("./tests/test.png")24 assert res[0] == 'gsettings'25@patch('backgroundchanger.utils.Tk')26def test_get_screen_size(mock_tk):27 mock_tk.return_value.winfo_vrootheight = MagicMock()28 mock_tk.return_value.winfo_vrootheight.return_value = 1029 mock_tk.return_value.winfo_vrootwidth = MagicMock()30 mock_tk.return_value.winfo_vrootwidth.return_value = 1031 screen = utils.get_screen_size()32 assert screen['height'] == 1033 assert screen['width'] == 1034def test_get_keys():35 with patch('builtins.open', new_callable=MockOpen) as open_mock:36 jsonStr = '''37 {...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

...34 """35 changes the background using a command36 determined by operating system37 """38 cmd = get_background_cmd(photo_name)39 call(cmd)40def get_screen_size():41 """42 gets the screen size as a dict43 {height, width}44 """45 root = Tk()46 return {47 'height': root.winfo_vrootheight(),48 'width': root.winfo_vrootwidth()49 }50def copy_file(src, dst):51 logging.info('Copying pic {} to {}'.format(src, dst))52 shutil.copy2(src, dst)53def get_background_cmd(photo_name: str):54 system = platform_system()55 if system == 'Darwin':56 raise ValueError(57 'macOS is not yet implemented to change the background. However, you can still change the background. photo name: {}'.format(58 photo_name))59 elif system == 'Linux':60 logging.info('Linux OS found; finding distro')61 dist = distro_name()62 logging.info('Found {}'.format(dist))63 if 'elementary' in dist or 'Ubuntu' in dist:64 return [65 'gsettings',66 'set',67 'org.gnome.desktop.background',...

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