forked from piernik-dev/piernik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_test.py
74 lines (60 loc) · 1.79 KB
/
make_test.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
73
#!/usr/bin/env python
import sys
import getopt
import os
import subprocess as sp
import shutil as sh
import xmlrpclib
class MakeTest(object):
def __init__(self,test):
self.initpath = os.getcwd()
self.runpath = os.path.join(self.initpath,'runs',test)
self.test = test
os.chdir(self.runpath)
retcode = sp.call(["mpiexec","./piernik"])
if retcode != 0:
sys.exit(retcode)
self.runtest(test)
os.chdir(self.initpath)
def put_png(self):
server = xmlrpclib.ServerProxy("http://piernik:p1ern1k@hum/piernik/login/xmlrpc")
for file in os.listdir(self.runpath):
if file.find('png') != -1:
server.wiki.putAttachment(self.test+'/'+file, xmlrpclib.Binary(open(self.runpath+'/'+file).read()))
def testJeans (self):
sp.call(["gnuplot","verify.gpl"])
self.put_png()
def testMaclaurin (self):
from maclaurin import Maclaurin_test
Maclaurin_test(self.runpath+'/maclaurin_sph_0001.h5')
self.put_png()
def testSedov (self):
print "test not implemented"
def output(self):
print self.initpath
print self.runpath
def runtest(self,test):
tests = { "jeans": self.testJeans,
"maclaurin": self.testMaclaurin,
"sedov": self.testSedov}[test]()
#tests.get(test)
def usage():
print __doc__
def main(argv):
try:
opts, args = getopt.getopt(argv, "ht", ["help", "test="])
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in ("-t", "--test"):
test=arg
# add piernik modules
sys.path.append(sys.path[0]+'/python')
t = MakeTest(test)
t.output()
if __name__ == "__main__":
main(sys.argv[1:])