Skip to content
Snippets Groups Projects
Commit 23450658 authored by valerio's avatar valerio
Browse files

Ost is not deficient anymore. Fixes BZDNG-107

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2093 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 52b53f58
No related branches found
No related tags found
No related merge requests found
import sys, os, platform import sys, os, platform
import optparse
interactive=False
def show_help(option, opt, value, parser):
parser.print_help()
sys.exit(-1)
def interactive_flag(option, opt, value, parser):
pass
usage = 'usage: ost [ost options] [script to execute] [script parameters]'
class OstOptionParser(optparse.OptionParser):
def __init__(self, **kwargs):
optparse.OptionParser.__init__(self, **kwargs)
def exit(self, status_code, error_message):
print error_message,
QtGui.QApplication.instance().exit()
sys.exit(-1)
parser=OstOptionParser(usage=usage,conflict_handler="resolve")
parser.add_option("-i", "--interactive", action="callback", callback=interactive_flag, help="start interpreter interactively (must be first parameter, ignored otherwise)")
parser.add_option("-h", "--help", action="callback", callback=show_help, help="show this help message and exit")
parser.add_option("-v", "--verbosity_level", action="store", type="int", dest="vlevel", default=1, help="sets the verbosity level [default: %default]")
parser.disable_interspersed_args()
(options, args) = parser.parse_args()
if platform.machine()=='x86_64': if platform.machine()=='x86_64':
sys.path.insert(0, os.getenv('DNG_ROOT')+'/lib64/openstructure') sys.path.insert(0, os.getenv('DNG_ROOT')+'/lib64/openstructure')
else: else:
...@@ -40,7 +67,16 @@ if os.path.exists(_ostrc): ...@@ -40,7 +67,16 @@ if os.path.exists(_ostrc):
except Exception, e: except Exception, e:
print e print e
if(len(sys.argv)>0): PushVerbosityLevel(options.vlevel)
script=sys.argv[0]
execfile(script) sys.path.append(".")
if len(parser.rargs)>0 :
script=parser.rargs[0]
sys_argv_backup=sys.argv
sys.argv=parser.rargs
try:
execfile(script)
finally:
sys.argv=sys_argv_backup
...@@ -57,17 +57,17 @@ if [ $# == 0 ];then ...@@ -57,17 +57,17 @@ if [ $# == 0 ];then
else else
opts="" opts=""
for argument in "$@";do for argument in "$@";do
if [ "$argument" == "-i" ] ;then if [ -n "$opts" ]; then
interactive="-i" opts=$opts"#""$argument"
else else
if [ -n "$opts" ]; then opts="$argument"
opts=$opts"#""$argument" fi
else
opts="$argument"
fi
fi
done done
if [ $1 == "-i" ] ;then
interactive="-i"
fi
fi fi
# finally pass control to python instance # finally pass control to python instance
IFS="#" IFS="#"
exec $pyexec $interactive "$DNG_ROOT/@LIBDIR@/openstructure/init_cl.py" $opts exec $pyexec $interactive "$DNG_ROOT/@LIBDIR@/openstructure/init_cl.py" $opts
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment