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 if platform.machine()=='x86_64':
31 sys.path.insert(0, os.path.join(os.getenv('DNG_ROOT'), 'lib64', _site_packs))
33 sys.path.insert(0,os.path.join(os.getenv('DNG_ROOT'), 'lib', _site_packs))
38 ost.SetPrefixPath(os.getenv('DNG_ROOT'))
39 def _InitRuleBasedBuilder():
40 compound_lib_path=os.path.join(ost.GetSharedDataPath(), 'compounds.chemlib')
41 if os.path.exists(compound_lib_path):
42 compound_lib=conop.CompoundLib.Load(compound_lib_path)
43 conop.RegisterBuilder(conop.RuleBasedBuilder(compound_lib), 'RBB')
44 conop.SetDefaultBuilder('RBB')
46 # switch to rule-based builder for high fidelity if compounds.chemlib is
48 _InitRuleBasedBuilder()
50 HistoryFile=os.path.expanduser('~/.ost_history')
52 # we are not in GUI mode.
58 home = os.getenv('HOME') or os.getenv('USERPROFILE')
59 _ostrc=os.path.join(home, '.ostrc')
60 if os.path.exists(_ostrc):
66 rcfile=open(_ostrc,"w")
67 print >> rcfile, '# This python file is parsed by ost and dng at startup'
68 print >> rcfile, '# Its content is be made available in the global namespace'
69 print >> rcfile, '# It can be used to define custom variables and functions'
70 print >> rcfile, '# For example:'
71 print >> rcfile, '# IMPORTANT_DIR="path/to/important/dir"'
74 PushVerbosityLevel(options.vlevel)
78 if len(parser.rargs)>0 :
79 script=parser.rargs[0]
80 sys_argv_backup=sys.argv
85 sys.argv=sys_argv_backup