Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def readlines_reverse(qfile):
- position = qfile.seek(-1, 1)
- line = b''
- while position >= 0:
- qfile.seek(position)
- next_char = qfile.read(1)
- if next_char == b"\n":
- yield line[::-1]
- line = b''
- else:
- line += next_char
- position -= 1
- yield line[::-1]
- def logger_analyzer(fail_log, root_cause):
- with open('log.txt', 'rb') as f:
- num_fail_log = 0
- while not bytearray(fail_log, "utf8") in f.readline():
- num_fail_log += 1
- for num, line in enumerate(readlines_reverse(f)):
- if bytearray(root_cause, "utf8") in line:
- break
- return num_fail_log - num + 1
- logger_analyzer("FAIL", "testA")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement