/[escript]/trunk/escript/py_src/runmodel.py
ViewVC logotype

Contents of /trunk/escript/py_src/runmodel.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 269 - (show annotations)
Wed Nov 30 01:59:55 2005 UTC (13 years, 10 months ago) by elspeth
File MIME type: text/x-python
File size: 1040 byte(s)
Fixed typos and import problems

1 #!/usr/bin/python
2 # $Id$
3 from esys.escript import modelframe
4
5 #commandline utility to take an xml file, parse it, and run a simulation.
6 # invoke this by doing ./runmodel.py <filename.xml>
7
8 import optparse
9
10 parser = optparse.OptionParser(usage="\n%prog [options]\n%prog files...")
11 parser.add_option('-f', '--file', dest='filename',
12 help='the FILE', metavar='FILE')
13 parser.add_option('-n', '--old-name', action="store",
14 help='the old filename, used in aup',
15 dest='old_name', default='')
16 def main():
17 (options, args) = parser.parse_args()
18 if options.filename and args:
19 parser.usage("Please only specifiy 1 file if using --file=")
20 if options.filename:
21 files = [(file(options.filename), options.filename)]
22 elif args:
23 files = [(file(arg), arg) for arg in args]
24 else:
25 parser.usage
26
27 for f, filename in files:
28
29 simstring = f.read()
30 sim = modelframe.parse(simstring)
31 print sim
32 sim.run()
33
34 if __name__=='__main__':
35 main()
36

  ViewVC Help
Powered by ViewVC 1.1.26