1 import sys, os, platform
14 usage =
'usage: ost [ost options] [script to execute] [script parameters]'
17 optparse.OptionParser.__init__(self, **kwargs)
18 def exit(self, status_code, error_message):
22 parser=
OstOptionParser(usage=usage,conflict_handler=
"resolve", prog=
'ost''')
23 parser.add_option("-i", "--interactive", action="callback", callback=interactive_flag, help="start interpreter interactively (must be first parameter, ignored otherwise)")
24 parser.add_option("-h", "--help", action="callback", callback=show_help, help="show this help message and exit")
25 parser.add_option("-v", "--verbosity_level", action="store", type="int", dest="vlevel", default=2, help="sets the verbosity level [default: %default]")
26 parser.disable_interspersed_args()
27 (options, args) = parser.parse_args()
29 _site_packs='python%d.%d/site-packages' % sys.version_info[0:2]
30 _base_dir=os.getenv('DNG_ROOT')
31 sys.path.insert(0, os.path.join(_base_dir, 'lib64', _site_packs))
36 ost.SetPrefixPath(_base_dir)
38 def _InitRuleBasedProcessor():
39 compound_lib_path=os.path.join(ost.GetSharedDataPath(), 'compounds.chemlib')
40 if os.path.exists(compound_lib_path):
41 compound_lib=conop.CompoundLib.Load(compound_lib_path)
42 conop.SetDefaultLib(compound_lib)
43 io.profiles['DEFAULT'].processor = conop.RuleBasedProcessor(compound_lib)
45 # switch to rule-based processor, if compound library is available
46 _InitRuleBasedProcessor()
48 HistoryFile=os.path.expanduser('~/.ost_history')
50 # we are not in GUI mode.
56 home = os.getenv('HOME') or os.getenv('USERPROFILE')
57 _ostrc=os.path.join(home, '.ostrc')
58 if os.path.exists(_ostrc):
63 PushVerbosityLevel(options.vlevel)
65 # this should probably only be added when running an interactive shell
68 if len(parser.rargs)>0 :
69 script=parser.rargs[0]
70 sys_argv_backup=sys.argv
75 sys.argv=sys_argv_backup