11 print(
"OpenStructure " + ost.__version__)
24 parser =
OstOptionParser(usage=usage, conflict_handler=
"resolve", prog=
"ost")
29 callback=interactive_flag,
30 help=
"start interpreter interactively (must be first parameter, ignored otherwise)",
37 help=
"show this help message and exit",
43 callback=show_version,
44 help=
"show OST version and exit",
53 help=
"sets the verbosity level [default: %default]",
55 parser.disable_interspersed_args()
60 ost [ost options] [script to execute] [script parameters]
61 ost [action name] [action options]
63 The following actions are available:
66 action_path = os.path.abspath(os.environ.get(
"OST_EXEC_DIR",
""))
67 for action
in sorted(glob.glob(os.path.join(action_path,
"ost-*"))):
68 usage +=
" %s\n" % action[len(action_path) + 5 :]
70 usage +=
'\nEach action should respond to "--help".'
75 optparse.OptionParser.__init__(self, **kwargs)
77 def exit(self, status_code, error_message):
78 print(error_message, end=
" ")
82 _site_packs =
"python%d.%d/site-packages" % sys.version_info[0:2]
83 _base_dir = os.getenv(
"DNG_ROOT")
84 sys.path.insert(0, os.path.join(_base_dir,
"lib64", _site_packs))
90 (options, args) = parser.parse_args()
92 HistoryFile = os.path.expanduser(
"~/.ost_history")
99 sys.argv = sys.argv[1:]
100 home = os.getenv(
"HOME")
or os.getenv(
"USERPROFILE")
101 _ostrc = os.path.join(home,
".ostrc")
102 if os.path.exists(_ostrc):
104 exec(compile(open(_ostrc).read(), _ostrc,
"exec"))
105 except Exception
as e:
113 if len(parser.rargs) > 0:
114 script = parser.rargs[0]
115 sys_argv_backup = sys.argv
116 sys.argv = parser.rargs
118 exec(compile(open(script,
"rb").read(), script,
"exec"))
120 sys.argv = sys_argv_backup
def __init__(self, **kwargs)
def exit(self, status_code, error_message)
def PushVerbosityLevel(value)
def show_version(option, opt, value, parser)
def get_options_parser(usage)
def show_help(option, opt, value, parser)
def interactive_flag(option, opt, value, parser)