1 import sys, os, platform, glob
16 ost [ost options] [script to execute] [script parameters]
19 ost [action name] [action options]
23 action_path = os.path.abspath(os.environ.get(
"OST_EXEC_DIR",
""))
25 usage +=
'Following actions are available:\n'
26 for action
in sorted(glob.glob(os.path.join(action_path,
'ost-*'))):
27 usage +=
" %s\n" % action[len(action_path)+5:]
28 usage +=
'\nEach action should respond to "--help".\n'
32 optparse.OptionParser.__init__(self, **kwargs)
33 def exit(self, status_code, error_message):
37 parser=
OstOptionParser(usage=usage,conflict_handler=
"resolve", prog=
'ost''')
38 parser.add_option("-i", "--interactive", action="callback", callback=interactive_flag, help="start interpreter interactively (must be first parameter, ignored otherwise)")
39 parser.add_option("-h", "--help", action="callback", callback=show_help, help="show this help message and exit")
40 parser.add_option("-v", "--verbosity_level", action="store", type="int", dest="vlevel", default=2, help="sets the verbosity level [default: %default]")
41 parser.disable_interspersed_args()
42 (options, args) = parser.parse_args()
44 _site_packs='python%d.%d/site-packages' % sys.version_info[0:2]
45 _base_dir=os.getenv('DNG_ROOT')
46 sys.path.insert(0, os.path.join(_base_dir, 'lib64', _site_packs))
48 from ost import SetPrefixPath, GetSharedDataPath, conop
50 SetPrefixPath(_base_dir)
52 def _InitRuleBasedProcessor():
53 compound_lib_path=os.path.join(GetSharedDataPath(), 'compounds.chemlib')
54 if os.path.exists(compound_lib_path):
55 compound_lib=conop.CompoundLib.Load(compound_lib_path)
56 conop.SetDefaultLib(compound_lib)
58 # switch to rule-based processor, if compound library is available
59 _InitRuleBasedProcessor()
64 HistoryFile=os.path.expanduser('~/.ost_history')
66 # we are not in GUI mode.
72 home = os.getenv('HOME') or os.getenv('USERPROFILE')
73 _ostrc=os.path.join(home, '.ostrc')
74 if os.path.exists(_ostrc):
79 PushVerbosityLevel(options.vlevel)
81 # this should probably only be added when running an interactive shell
84 if len(parser.rargs)>0 :
85 script=parser.rargs[0]
86 sys_argv_backup=sys.argv
91 sys.argv=sys_argv_backup