-
Notifications
You must be signed in to change notification settings - Fork 0
/
OSUT3AnalysisMonitor.py
72 lines (56 loc) · 2.29 KB
/
OSUT3AnalysisMonitor.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
import os, subprocess, shutil, threading, sys
import Release, Test
class OSUT3AnalysisMonitor:
_tests = None
_releases = None
def __init__ (self, releases = None, tests = None):
self._tests = []
self._releases = []
if releases is not None:
self._releases.extend (releases)
if tests is not None:
self._tests.extend (tests)
def addRelease (self, release):
self._releases.append (release)
def addReleases (self, releases):
self._releases.extend (releases)
def getReleases (self):
return self._releases
def addTest (self, test):
self._tests.append (test)
def addTests (self, tests):
self._tests.extend (tests)
def getTests (self):
return self._tests
def runTests (self):
try:
os.mkdir ("tmp")
except OSError:
print "Working directory \"tmp/\" already exists."
print "OSUT3AnalysisMonitor appears to still be running."
print "Either wait for completion or remove \"tmp/\"."
sys.exit (1)
cwd = os.path.realpath (os.getcwd ())
lock = threading.Lock ()
threads = []
for release in self._releases:
for test in self._tests:
releaseDir = release.getArch ()
os.makedirs ("tmp/" + test.getTestDir () + "/" + releaseDir)
os.chdir ("tmp/" + test.getTestDir () + "/" + releaseDir)
subprocess.call ("SCRAM_ARCH=" + release.getArch () + " scramv1 project CMSSW " + release.getReleaseVersion (), shell = True)
releaseDir += "/" + release.getReleaseVersion ()
test.setReleaseDir (releaseDir)
os.chdir (release.getReleaseVersion () + "/src/")
shutil.copy (cwd + "/Tests/" + test.getTestDir () + "/" + test.getBuildPackagesScript (), "./" + test.getBuildPackagesScript ())
shutil.copy (cwd + "/Tests/" + test.getTestDir () + "/" + test.getLaunchJobsScript (), "./" + test.getLaunchJobsScript ())
shutil.copy (cwd + "/Tests/" + test.getTestDir () + "/" + test.getHarvestOutputScript (), "./" + test.getHarvestOutputScript ())
test.setWorkingDir (os.path.realpath (os.getcwd ()))
os.chdir (cwd)
threads.append (threading.Thread (target = test.runTest, args = (lock,)))
for thread in threads:
thread.start ()
for thread in threads:
thread.join ()
shutil.rmtree ("tmp")