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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 265 - (hide annotations)
Tue Nov 29 22:56:08 2005 UTC (13 years, 9 months ago) by elspeth
File MIME type: text/x-python
File size: 1033 byte(s)
Minor bugfix - should now actually run simulations

1 gross 250 #!/usr/bin/python
2     # $Id$
3     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 gross 260 parser.usage
26 gross 250
27     for f, filename in files:
28    
29     simstring = f.read()
30     sim = modelframe.parse(simstring)
31     print sim
32 elspeth 265 sim.modelframe.run()
33 gross 250
34     if __name__=='__main__':
35     main()
36    

  ViewVC Help
Powered by ViewVC 1.1.26