10 # - JPF logs directory
13 # - list #2 (if needed)
15 # Index 0 is always for the Python script itself
16 jpfLogDir = sys.argv[1]
17 csvFileOutput = sys.argv[2]
18 addLogFile = sys.argv[3]
20 # Extract the status finished/unfinished
22 if (text.find('no errors') != -1):
31 startStatesInfo = text.find('states:')
32 startIndex = text.find('=', startStatesInfo)
33 endIndex = text.find(',', startIndex)
34 return text[startIndex+1:endIndex]
36 # Extract number of conflicts
37 def getConflicts(text, startIndex):
38 conflictIndex = text.find('conflicts :', startIndex)
39 newLineIndex = text.index('\n', conflictIndex)
40 startIndex = conflictIndex + 10 # Assuming that it will be greater than 10
41 if conflictIndex == -1:
43 startIndex = len(text)
45 returnedText = text[conflictIndex+14:newLineIndex]
46 return startIndex, returnedText
48 print("Opening log files ...\n\n")
49 out = open(csvFileOutput, "w+")
50 with open(addLogFile, 'r') as addFile:
51 addText = addFile.read()
53 for filename in glob.glob(os.path.join(jpfLogDir, '*.log')):
54 with open(filename, 'r') as f:
56 status = getStatus(text) # Getting status "no errors/finished" or "not finished"
57 states = getStates(text)
58 startIndex, conflicts = getConflicts(addText, startIndex)
59 lastSlash = filename.rfind('/')
60 lastDoubleDash = filename.rfind('--')
61 fname = filename[lastSlash+1:lastDoubleDash]
62 lineReport = fname + ',' + status + ',' + states + ',' + conflicts + '\n'