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):
34 print(error_message, end=
' ')
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))
51 HistoryFile=os.path.expanduser('~/.ost_history')
53 # we are not in GUI mode.
59 home = os.getenv('HOME') or os.getenv('USERPROFILE')
60 _ostrc=os.path.join(home, '.ostrc')
61 if os.path.exists(_ostrc):
63 exec(compile(open(_ostrc).read(), _ostrc, 'exec'))
64 except Exception as e:
66 PushVerbosityLevel(options.vlevel)
68 # this should probably only be added when running an interactive shell
71 if len(parser.rargs)>0 :
72 script=parser.rargs[0]
73 sys_argv_backup=sys.argv
76 exec(compile(open(script,'rb').read(), script, 'exec'))
78 sys.argv=sys_argv_backup