1 | """ |
---|
2 | Script to run all the produce_results scripts in the Tests/xxx/xxx/ directories |
---|
3 | """ |
---|
4 | |
---|
5 | import os |
---|
6 | import anuga |
---|
7 | import time |
---|
8 | from anuga import indent |
---|
9 | |
---|
10 | #-------------------------------- |
---|
11 | # Get Default values for |
---|
12 | # algorithm parameters. |
---|
13 | #-------------------------------- |
---|
14 | from parameters import alg |
---|
15 | from parameters import cfl |
---|
16 | |
---|
17 | #--------------------------------- |
---|
18 | # Get the current svn revision |
---|
19 | #--------------------------------- |
---|
20 | timestamp = time.asctime() |
---|
21 | major_revision = anuga.config.major_revision |
---|
22 | minor_revision = anuga.utilities.system_tools.get_revision_number() |
---|
23 | |
---|
24 | #--------------------------------- |
---|
25 | # Run the tests |
---|
26 | #--------------------------------- |
---|
27 | buildroot = os.getcwd() |
---|
28 | |
---|
29 | Upper_dirs = os.listdir('./Tests') |
---|
30 | |
---|
31 | try: |
---|
32 | Upper_dirs.remove('.svn') |
---|
33 | except ValueError: |
---|
34 | pass |
---|
35 | #print Upper_dirs |
---|
36 | os.chdir('./Tests') |
---|
37 | |
---|
38 | print 'Tests' |
---|
39 | for dir in Upper_dirs: |
---|
40 | |
---|
41 | os.chdir(dir) |
---|
42 | |
---|
43 | print indent + dir |
---|
44 | #print 'Changing to', os.getcwd() |
---|
45 | Lower_dirs = os.listdir('.') |
---|
46 | try: |
---|
47 | Lower_dirs.remove('.svn') |
---|
48 | except ValueError: |
---|
49 | pass |
---|
50 | #print Lower_dirs |
---|
51 | for l_dir in Lower_dirs: |
---|
52 | os.chdir(l_dir) |
---|
53 | #print os.getcwd() |
---|
54 | print 2*indent + l_dir |
---|
55 | try: |
---|
56 | cmd = 'python produce_results.py' |
---|
57 | print 3*indent + 'Running: '+cmd |
---|
58 | os.system( cmd ) |
---|
59 | except: |
---|
60 | print 3*indent + 'Failed running produce_results in '+os.getcwd() |
---|
61 | pass |
---|
62 | |
---|
63 | os.chdir('..') |
---|
64 | #print 'Changing to', os.getcwd() |
---|
65 | |
---|
66 | os.chdir('..') |
---|
67 | #print 'Changing to', os.getcwd() |
---|
68 | |
---|
69 | os.chdir('..') |
---|
70 | #---------------------------------- |
---|
71 | # Now it is ok to create the latex |
---|
72 | # macro file with run parameters |
---|
73 | #---------------------------------- |
---|
74 | |
---|
75 | f = open('saved_parameters.tex','w') |
---|
76 | f.write('\\newcommand{\\cfl}{\\UScore{%s}}\n' % str(cfl)) |
---|
77 | f.write('\\newcommand{\\alg}{\\UScore{%s}}\n' % str(alg)) |
---|
78 | f.write('\\newcommand{\\majorR}{\\UScore{%s}}\n' % str(major_revision)) |
---|
79 | f.write('\\newcommand{\\minorR}{\\UScore{%s}}\n' % str(minor_revision)) |
---|
80 | f.write('\\newcommand{\\timeR}{{%s}}\n' % str(timestamp)) |
---|
81 | |
---|
82 | f.close() |
---|
83 | |
---|
84 | |
---|
85 | cmd = 'pdflatex -shell-escape -interaction=batchmode report.tex' |
---|
86 | print cmd |
---|
87 | import subprocess |
---|
88 | subprocess.call( [cmd], shell=True ) |
---|
89 | cmd = 'mv report.pdf report_cfl_%s_alg_%s.pdf' % (str(cfl), str(alg)) |
---|
90 | print cmd |
---|
91 | subprocess.call( [cmd] , shell=True ) |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | |
---|