forked from bumps/bumps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_examples.py
39 lines (32 loc) · 1004 Bytes
/
check_examples.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
#!/usr/bin/env python
import sys, os
examples = [
"peaks/model.py",
]
ROOT = os.path.abspath(os.path.dirname(__file__))
EXAMPLEDIR = os.path.join(ROOT,'doc','examples')
if os.name == 'nt':
os.environ['PYTHONPATH'] = ROOT+";"+ROOT+"/dream"
else:
os.environ['PYTHONPATH'] = ROOT+":"+ROOT+"/dream"
PYTHON = sys.executable
CLI = "%s %s/bin/bumps %%s %%s"%(PYTHON,ROOT)
class Commands(object):
@staticmethod
def preview(f):
os.system(CLI%(f,'--preview --seed=1'))
@staticmethod
def edit(f):
os.system(CLI%(f,'--edit --seed=1'))
@staticmethod
def chisq(f):
return os.system(CLI%(f,'--chisq --seed=1'))
def main():
if len(sys.argv) == 1 or not hasattr(Commands, sys.argv[1]):
print "usage: check_examples.py [preview|edit|chisq]"
else:
command = getattr(Commands, sys.argv[1])
for f in examples:
print "Example",f
command(os.path.join(EXAMPLEDIR,f))
if __name__ == "__main__": main()