forked from HamidMushtaq/SparkGA1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runAll.py
48 lines (39 loc) · 1.3 KB
/
runAll.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
#****************************************/
# Script: runAll.py
# Author: Hamid Mushtaq
#****************************************/
from xml.dom import minidom
import sys
import os
import time
logFile = "time.txt"
configFile = sys.argv[1]
startingPart = 1
doc = minidom.parse(configFile)
outputFolder = doc.getElementsByTagName("outputFolder")[0].firstChild.data
if len(sys.argv) > 2:
startingPart = int(sys.argv[2])
if startingPart == 1:
if os.path.exists(logFile):
os.remove(logFile)
def addToLog(s):
f = open(logFile,'a+')
f.write(s + "\n")
f.close()
def getElapsedStr(elapsed):
return str(elapsed / 60) + " mins " + str(elapsed % 60) + " secs"
times_list = []
times_list.append(time.time())
iterations = 4 - startingPart
for i in range(0, iterations):
part = str(i+startingPart)
os.system("./runPart.py " + configFile + " " + part + " &> log" + part + ".txt")
pt = times_list[i]
ct = time.time()
times_list.append(ct)
addToLog(">> Part" + part + " took " + getElapsedStr(int(ct-pt)))
addToLog("--------------------------------------")
totalTime = getElapsedStr(int(times_list[iterations]-times_list[0]))
addToLog(">> From part " + str(startingPart) + " till end, it took " + totalTime)
print "<< From part " + str(startingPart) + " till the end, it took " + totalTime + " >>"