source: trunk/gui/apps/rerun @ 115

Last change on this file since 115 was 115, checked in by mmc, 17 years ago

Updated all copyright notices.

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1#! /bin/sh
2# ----------------------------------------------------------------------
3#  rerun
4
5#  script to view the output of a previously created run.xml file
6#  rerunning the simulation with new data is outside of the scope
7#  of this script. it is currently only for viewing the output
8#  of a previously created run.xml file.
9
10#
11#  RUN AS FOLLOWS:
12#    rerun [-h | -d driver_path] <run.xml-file>
13#
14#      -h | --help                  - print the help menu
15#      -d | --driver driver_path    - specify the path to the driver
16#                                     program. You will need to specify
17#                                     the path if the driver program is
18#                                     not in your PATH environment
19#                                     variable.
20#
21#      <run.xml-file> - the run.xml file you containing an output
22#                       section you would like to re-generate.
23#
24# ======================================================================
25#  AUTHOR:  Derrick Kearney, Purdue University
26#  Copyright (c) 2004-2005  Purdue Research Foundation
27#
28#  See the file "license.terms" for information on usage and
29#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
30# ======================================================================
31#
32#
33""":"
34exec python $0 ${1+"$@"}
35"""
36
37import getopt, shutil, re, os, sys
38
39def printHelp():
40    print """rerun [-h | -d driver_path] runFile
41
42      -h | --help                  - print the help menu
43      -d | --driver driver_path    - specify the path to the driver
44                                     program. You will need to specify
45                                     the path if the driver program is
46                                     not in your PATH environment
47                                     variable.
48
49      <run.xml-file> - the run.xml file you containing an output
50                       section you would like to re-generate.
51"""
52    sys.exit()
53
54
55if __name__ == '__main__' :
56
57    longOpts = ["driver=","help"]
58    shortOpts = "d:h"
59    opts, args = getopt.getopt(sys.argv[1:], shortOpts, longOpts)
60
61    driverPath = 'driver'
62    runFile = args[0]
63
64    # match options
65    for o, v in opts:
66        if o in ("-d", "--driver"):
67            driverPath = v
68        elif o in ("-h", "--help"):
69            printHelp()
70
71    # look for the text <command> (any characters) </command>
72    re_command = re.compile(r'<command>.*</command>', re.I|re.DOTALL)
73
74    # prepare text variables
75    outTmpFileName = '/tmp/rerun_' + os.path.basename(runFile)
76    outCmd = '<command>echo =RAPPTURE-RUN=>%s</command>' % outTmpFileName
77
78    # do the file <command> switheroo!
79    xmlfile = open(runFile, "rb").read()
80    tmpfile = open(outTmpFileName, "wb")
81    outText = re_command.sub(outCmd,xmlfile)
82    tmpfile.write(outText)
83    tmpfile.close()
84
85    # run driver on the temporary run file
86    systemCmd = '%s -tool %s' % (driverPath, outTmpFileName)
87    os.system(systemCmd)
88   
89    # presto-change-o
90   
91    # clean up our tmp file
92    os.remove(outTmpFileName)
93    sys.exit()
Note: See TracBrowser for help on using the repository browser.