SHARE
TWEET

Untitled

a guest Mar 26th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top