How to use __stop_loggers method in autotest

Best Python code snippet using autotest_python

logfile_monitor.py

Source:logfile_monitor.py Github

copy

Full Screen

...146 self._console_proc = None147 self._console_log = console_log or 'logfile_monitor.log'148 def reboot_followup(self, *args, **dargs):149 super(LogfileMonitorMixin, self).reboot_followup(*args, **dargs)150 self.__stop_loggers()151 self.__start_loggers()152 def start_loggers(self):153 super(LogfileMonitorMixin, self).start_loggers()154 self.__start_loggers()155 def remote_path_exists(self, remote_path):156 """Return True if remote_path exists, False otherwise."""157 return not self.run(158 'ls %s' % remote_path, ignore_status=True).exit_status159 def check_remote_paths(self, remote_paths):160 """Return list of remote_paths that currently exist."""161 return [162 path for path in remote_paths if self.remote_path_exists(path)]163 @_log_and_ignore_exceptions164 def __start_loggers(self):165 """Start multifile monitoring logger.166 Launch monitors/followfiles.py on the target and hook its output167 to monitors/console.py locally.168 """169 # Check if follow_paths exist, in the case that one doesn't170 # emit a warning and proceed.171 follow_paths_set = set(self.follow_paths)172 existing = self.check_remote_paths(follow_paths_set)173 missing = follow_paths_set.difference(existing)174 if missing:175 # Log warning that we are missing expected remote paths.176 logging.warn('Target %s is missing expected remote paths: %s',177 self.hostname, ', '.join(missing))178 # If none of them exist just return (for now).179 if not existing:180 return181 # Create a new lastlines_dirpath on the remote host if not already set.182 if not self._lastlines_dirpath:183 self._lastlines_dirpath = self.get_tmp_dir(parent='/var/tmp')184 # Launch followfiles on target185 self._followfiles_proc = launch_remote_followfiles(186 self, self._lastlines_dirpath, existing)187 # Ensure we have sane pattern_paths before launching console.py188 sane_pattern_paths = []189 for patterns_path in set(self.pattern_paths):190 try:191 patterns_path = resolve_patterns_path(patterns_path)192 except InvalidPatternsPathError, e:193 logging.warn('Specified patterns_path is invalid: %s, %s',194 patterns_path, str(e))195 else:196 sane_pattern_paths.append(patterns_path)197 # Launch console.py locally, pass in output stream from followfiles.198 self._console_proc, self._logfile_warning_stream = \199 launch_local_console(200 self._followfiles_proc.stdout, self._console_log,201 sane_pattern_paths)202 if self.job:203 self.job.warning_loggers.add(self._logfile_warning_stream)204 def stop_loggers(self):205 super(LogfileMonitorMixin, self).stop_loggers()206 self.__stop_loggers()207 @_log_and_ignore_exceptions208 def __stop_loggers(self):209 if self._console_proc:210 utils.nuke_subprocess(self._console_proc)211 utils.nuke_subprocess(self._followfiles_proc)212 self._console_proc = self._followfile_proc = None213 if self.job:214 self.job.warning_loggers.discard(self._logfile_warning_stream)215 self._logfile_warning_stream.close()216def NewLogfileMonitorMixin(follow_paths, pattern_paths=None):217 """Create a custom in-memory subclass of LogfileMonitorMixin.218 Args:219 follow_paths: list; Remote paths to tail.220 pattern_paths: list; Local alert pattern definition files.221 """222 if not follow_paths or (pattern_paths and not follow_paths):...

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