DAMARIS can now run scripts immediatly upon startup.

This is the first step towards a simple queing implementation.
This commit is contained in:
Markus Rosenstihl
2018-03-16 17:03:44 +01:00
parent 328d50fc43
commit 8991e61600
5 changed files with 55 additions and 38 deletions

View File

@ -3,49 +3,44 @@
# setup script will insert local DAMARIS installation path behind import sys statement
# this must happen before any damaris stuff is called!
import sys
import os, argparse
import os
# for numpy-1.1 and later: check the environment for LANG and LC_NUMERIC
# see: http://projects.scipy.org/scipy/numpy/ticket/902
if os.environ.get("LANG","").startswith("de") or os.environ.get("LC_NUMERIC", "").startswith("de"):
os.environ["LC_NUMERIC"]="C"
if os.environ.get("LANG", "").startswith("de") or os.environ.get("LC_NUMERIC", "").startswith("de"):
os.environ["LC_NUMERIC"] = "C"
parser = argparse.ArgumentParser(description='DArmstadt MAgnetic Resonance Instrumentation Software')
parser.add_argument("--run", action="store_true", help="run DAMARIS immediately with given scripts")
parser.add_argument("--debug", action="store_true", help="run DAMARIS with DEBUG flag set")
parser.add_argument("--mpl", help="run DAMARIS with matplotlib backend",
choices=["GTKAgg","GTKCairo","GTK"], default="GTKAgg")
parser.add_argument("exp_script", help="experiment script", nargs="?", metavar="EXP.py")
parser.add_argument("res_script", help="result script", nargs="?", metavar="RES.py")
args = parser.parse_args()
import damaris.gui.DamarisGUI
import matplotlib
import os.path
# argv is already parsed by gtk initialisation
myargs=sys.argv[1:]
myname=os.path.basename(sys.argv[0])
if args.mpl:
matplotlib.use(args.mpl)
# find debug flag:
if "--debug" in myargs:
import damaris.gui.DamarisGUI
if args.debug:
damaris.gui.DamarisGUI.debug = True
print "debug flag set"
try:
import resource
resource.setrlimit(resource.RLIMIT_CORE, (-1,-1))
resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))
except ImportError:
pass
matplotlib.rcParams["verbose.level"]="debug"
myargs.remove("--debug")
matplotlib.rcParams["verbose.level"] = "debug"
# remove matplotlib flags
if "-d"+matplotlib.rcParams["backend"] in myargs:
myargs.remove("-d"+matplotlib.rcParams["backend"])
# find scripts to load in parameter list
exp_script = None
res_script = None
if len(myargs)<=2:
if len(myargs)>=1:
exp_script=myargs[0]
if len(myargs)==2:
res_script=myargs[1]
else:
print """too many arguments.\n%s [--debug] [-dGTK(Agg|Cairo|)] (Experiment File|"") (Result File|"")"""%(myname)
d=damaris.gui.DamarisGUI.DamarisGUI(exp_script, res_script)
d = damaris.gui.DamarisGUI.DamarisGUI(args.exp_script, args.res_script, start_immediatly=args.run)
d.run()
sys.stdout=sys.__stdout__
sys.stderr=sys.__stderr__
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__