source: coopr.pyomo/trunk/scripts/pyomo @ 2646

Last change on this file since 2646 was 2646, checked in by khunter, 11 years ago

Remove unused import (traceback)

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#! /usr/bin/env python
2#
3# A script that runs a solver to optimize a pyomo model:
4#
5#   pyomo <model.py> <model.dat>
6#
7#  _________________________________________________________________________
8#
9#  Coopr: A COmmon Optimization Python Repository
10#  Copyright (c) 2008 Sandia Corporation.
11#  This software is distributed under the BSD License.
12#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
13#  the U.S. Government retains certain rights in this software.
14#  For more information, see the FAST README.txt file.
15#  _________________________________________________________________________
16
17import sys
18
19if sys.version_info[0:3] < (2,5,1):
20   print ""
21   print "ERROR: Pyomo requires Python 2.5.1 or newer"
22   sys.exit(1)
23from os.path import abspath, dirname
24import os
25sys.path.insert(0, dirname(dirname(abspath(__file__))))
26sys.path.append(".")
27currdir = dirname(abspath(__file__))
28coopr_path = dirname(currdir)
29pyutilib_path = dirname(coopr_path)+os.sep+"pyutilib"
30sys.path.append(coopr_path)
31sys.path.append(pyutilib_path)
32sys.path.append(abspath(os.getcwd()))
33#
34# Adjust the user path if it looks like this script is being used
35# from an Acro build (adds the Acro bin directory, if it exists).
36#
37# Recurse up the current path, looking for a subdirectory that
38# contains 'python' and 'bin'
39#
40curr = os.path.abspath(os.getcwd())
41while os.sep in curr:
42    if os.path.exists(curr+os.sep+"python") and os.path.exists(curr+os.sep+"bin"):
43        os.environ["PATH"] = curr+os.sep+"bin:"+os.environ["PATH"]
44        break
45    if os.path.basename(curr) == "":
46        break
47    curr = os.path.dirname(curr)
48
49import coopr.pyomo.scripting.pyomo
50
51try:
52    coopr.pyomo.scripting.pyomo.run(args=sys.argv[1:])
53except SystemExit:
54    pass
Note: See TracBrowser for help on using the repository browser.