def run(): """Trace a single file""" parser = argparse.ArgumentParser() parser.add_argument('--dfuse', help='Summarise dfuse I/O', action='store_true') parser.add_argument('--warnings', action='store_true') parser.add_argument('file', help='input file') args = parser.parse_args() try: log_iter = cart_logparse.LogIter(args.file) except UnicodeDecodeError: # If there is a unicode error in the log file then retry with checks # enabled which should both report the error and run in latin-1 so # perform the log parsing anyway. The check for log_iter.file_corrupt # later on will ensure that this error does not get logged, then # ignored. # The only possible danger here is the file is simply too big to check # the encoding on, in which case this second attempt would fail with # an out-of-memory error. log_iter = cart_logparse.LogIter(args.file, check_encoding=True) test_iter = LogTest(log_iter) if args.dfuse: test_iter.check_dfuse_io() else: try: test_iter.check_log_file(args.warnings) except LogError: print('Errors in log file, ignoring') except NotAllFreed: print('Memory leaks, ignoring') if log_iter.file_corrupt: sys.exit(1)
def run(): """Trace a single file""" parser = argparse.ArgumentParser() parser.add_argument('--dfuse', help='Summarise dfuse I/O', action='store_true') parser.add_argument('file', help='input file') args = parser.parse_args() log_iter = cart_logparse.LogIter(args.file) test_iter = LogTest(log_iter) if args.dfuse: test_iter.check_dfuse_io() else: test_iter.check_log_file(False)
def log_check(self): """Check log files for consistency.""" logparse = self.params.get("logparse", "/run/tests/*/") if logparse is None or not logparse: return strict_test = False self.log.info("Parsing log path %s", self.log_path) if not os.path.exists(self.log_path): self.log.info("Path does not exist") return for filename in os.listdir(self.log_path): log_file = os.path.join(self.log_path, filename) if not os.path.isfile(log_file): self.log.info("File is a Directory. Skipping.... :%s", log_file) continue self.log.info("Parsing %s", log_file) cl = cart_logparse.LogIter(log_file) c_log_test = cart_logtest.LogTest(cl) c_log_test.check_log_file(strict_test)
def log_check(cartobj): """Check log files for consistency """ logparse = cartobj.params.get("logparse", "/run/tests/*/") if logparse is None or not logparse: return strict_test = False print("Parsing log path", cartobj.log_path) if not os.path.exists(cartobj.log_path): print("Path does not exist") return for filename in os.listdir(cartobj.log_path): log_file = os.path.join(cartobj.log_path, filename) if not os.path.isfile(log_file): print("File is a Directory. Skipping.... :", log_file) continue print("Parsing ", log_file) cl = cart_logparse.LogIter(log_file) c_log_test = cart_logtest.LogTest(cl) c_log_test.check_log_file(strict_test)
def run(): """Trace a single file""" parser = argparse.ArgumentParser() parser.add_argument('--dfuse', help='Summarise dfuse I/O', action='store_true') parser.add_argument('file', help='input file') args = parser.parse_args() try: log_iter = cart_logparse.LogIter(args.file) except IsADirectoryError: print('Log tracing on directory not possible') return test_iter = LogTest(log_iter) if args.dfuse: test_iter.check_dfuse_io() else: try: test_iter.check_log_file(False) except LogError: print('Errors in log file, ignoring') except NotAllFreed: print('Memory leaks, ignoring')
def trace_one_file(filename): """Trace a single file""" log_iter = cart_logparse.LogIter(filename) test_iter = LogTest(log_iter) test_iter.check_log_file(False)