Adding a script to extract statistics of states and transitions.
authorrtrimana <rtrimana@uci.edu>
Mon, 20 Apr 2020 21:31:00 +0000 (14:31 -0700)
committerrtrimana <rtrimana@uci.edu>
Mon, 20 Apr 2020 21:31:00 +0000 (14:31 -0700)
SummarizeLogs.py [new file with mode: 0644]

diff --git a/SummarizeLogs.py b/SummarizeLogs.py
new file mode 100644 (file)
index 0000000..e184fda
--- /dev/null
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+import itertools
+import sys
+import os
+import glob
+
+# Input parameters:
+# - JPF directory
+# - JPF logs directory
+# - app directory
+# - list #1
+# - list #2 (if needed)
+
+# Index 0 is always for the Python script itself
+jpfLogDir = sys.argv[1]
+csvFileOutput = sys.argv[2]
+
+# Extract the status finished/unfinished
+def getStatus(text):
+       if (text.find('no errors') != -1):
+               return 'finished'
+       else:
+               return 'unfinished'
+               
+# Extract the states
+def getStates(text):
+       if not text:
+               return '0'
+       startStatesInfo = text.find('states:')
+       startIndex = text.find('=', startStatesInfo)
+       endIndex = text.find(',', startIndex)
+       return text[startIndex+1:endIndex]
+
+print("Opening log files ...\n\n")
+out = open(csvFileOutput, "w+")
+for filename in glob.glob(os.path.join(jpfLogDir, '*.log')):
+       with open(filename, 'r') as f:
+               text = f.read()
+               status = getStatus(text) # Getting status "no errors/finished" or "not finished"
+               states = getStates(text)
+               lastSlash = filename.rfind('/')
+               lastDoubleDash = filename.rfind('--')
+               fname = filename[lastSlash+1:lastDoubleDash]
+               lineReport = fname + ',' + status + ',' + states + '\n'
+               out.write(lineReport)
+               print(lineReport)
+out.close()
+               
+
+