From f7373aa466f328e5c405ebc7ff208d6772aa8953 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Mon, 20 Apr 2020 14:31:00 -0700 Subject: [PATCH] Adding a script to extract statistics of states and transitions. --- SummarizeLogs.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 SummarizeLogs.py diff --git a/SummarizeLogs.py b/SummarizeLogs.py new file mode 100644 index 0000000..e184fda --- /dev/null +++ b/SummarizeLogs.py @@ -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() + + + -- 2.34.1