Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. def readlines_reverse(qfile):
  2.     position = qfile.seek(-1, 1)
  3.     line = b''
  4.     while position >= 0:
  5.         qfile.seek(position)
  6.         next_char = qfile.read(1)
  7.         if next_char == b"\n":
  8.            yield line[::-1]
  9.            line = b''
  10.         else:
  11.            line += next_char
  12.         position -= 1
  13.     yield line[::-1]
  14.  
  15. def logger_analyzer(fail_log, root_cause):
  16.     with open('log.txt', 'rb') as f:
  17.          num_fail_log = 0
  18.          while not bytearray(fail_log, "utf8") in f.readline():
  19.              num_fail_log += 1
  20.  
  21.          for num, line in enumerate(readlines_reverse(f)):
  22.              if bytearray(root_cause, "utf8") in line:
  23.                  break
  24.     return num_fail_log - num + 1  
  25.    
  26. logger_analyzer("FAIL", "testA")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement