Modification in the script for extraction.
authorrtrimana <rtrimana@uci.edu>
Thu, 23 Apr 2020 03:52:50 +0000 (20:52 -0700)
committerrtrimana <rtrimana@uci.edu>
Thu, 23 Apr 2020 03:52:50 +0000 (20:52 -0700)
SummarizeLogs.py

index e184fda298fc399acfd895061df6a52616005d96..4de9acb840eaf753036a17ea1ab4dc2d94e93977 100644 (file)
@@ -15,6 +15,7 @@ import glob
 # Index 0 is always for the Python script itself
 jpfLogDir = sys.argv[1]
 csvFileOutput = sys.argv[2]
+addLogFile = sys.argv[3]
 
 # Extract the status finished/unfinished
 def getStatus(text):
@@ -31,20 +32,36 @@ def getStates(text):
        startIndex = text.find('=', startStatesInfo)
        endIndex = text.find(',', startIndex)
        return text[startIndex+1:endIndex]
+       
+# Extract number of conflicts
+def getConflicts(text, startIndex):
+       conflictIndex = text.find('conflicts   :', startIndex)
+       newLineIndex = text.index('\n', conflictIndex)
+       startIndex = conflictIndex + 10 # Assuming that it will be greater than 10
+       if conflictIndex == -1:
+               returnedText = '0'
+               startIndex = len(text)
+       else:
+               returnedText = text[conflictIndex+14:newLineIndex]
+       return startIndex, returnedText
 
 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)
+with open(addLogFile, 'r') as addFile:
+       addText = addFile.read()
+       startIndex = 0
+       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)
+                       startIndex, conflicts = getConflicts(addText, startIndex)
+                       lastSlash = filename.rfind('/')
+                       lastDoubleDash = filename.rfind('--')
+                       fname = filename[lastSlash+1:lastDoubleDash]
+                       lineReport = fname + ',' + status + ',' + states + ',' + conflicts + '\n'
+                       out.write(lineReport)
+                       print(lineReport)
 out.close()