Guest User

Python log parse script - baseline

a guest
Jun 9th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. # Original Python script used in parsing log
  2.  
  3. def read_log(fname):
  4.     try:
  5.         with open(fname, 'r') as f:
  6.             raw = f.read().splitlines()
  7.             ns = [s.split() for s in raw if 'SOC_NOT_PUSHED' in s]
  8.             ss = [w.split("SYNC_PUSH:")[1].strip() for w in raw if 'SYNC_PUSH:' in w]
  9.             not_pushed = [[s[2]+s[3], int(s[-1]), s[-2]] for s in ns]
  10.             ww = [(int(e.split(' at ')[0]), e.split(' at ')[1].split(' in ')[0], int(e.split(' at ')[1].split(' in ')[1].split(' ms ')[0]), set(e.split(' at ')[1].split(' in ')[1].split(' ms ')[1].split())) for e in ss]
  11.             pushed = [[w[0], w[1], w[2], 1 if 'PA-SOC_POP' in w[3] else 0, 1 if 'CU-SOC_POP' in w[3] else 0] for w in ww]
  12.             return not_pushed, pushed
  13.     except:
  14.         return []
Add Comment
Please, Sign In to add comment