SHARE
TWEET

Python log parse script - baseline

a guest Jun 9th, 2017 20 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 []
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