Implemented ordered queue of experiments for starting multiple DAMARIS

instances simultaneously.
This commit is contained in:
Markus Rosenstihl
2018-03-23 12:26:21 +01:00
parent 58515f1cf3
commit 113cc82684
2 changed files with 71 additions and 48 deletions

View File

@ -4,7 +4,7 @@
# this must happen before any damaris stuff is called!
import sys
import os, argparse
import sqlite3
# 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"):
@ -13,22 +13,36 @@ if os.environ.get("LANG", "").startswith("de") or os.environ.get("LC_NUMERIC", "
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("--clean", action="store_true", help="cleanup DAMARIS run files")
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")
#parser.add_argument("exp_res_script", help="(NOT IMPLEMENTED) further experiment and result script pairs", nargs=argparse.REMAINDER, metavar="EXPn.py RESn.py")
args = parser.parse_args()
import matplotlib
if args.mpl:
matplotlib.use(args.mpl)
import damaris.gui.DamarisGUI
lockfile = os.path.expanduser('~/.damaris.lockdb')
if args.clean:
if os.path.exists(lockfile):
os.remove(lockfile)
lockdb = sqlite3.connect(lockfile)
c = lockdb.cursor()
c.execute("CREATE TABLE IF NOT EXISTS damaris (uuid text, status text)")
print "Make sure experiment table exists"
lockdb.commit()
if args.debug:
damaris.gui.DamarisGUI.debug = True
print "debug flag set"
@ -38,9 +52,17 @@ if args.debug:
except ImportError:
pass
matplotlib.rcParams["verbose.level"] = "debug"
d = damaris.gui.DamarisGUI.DamarisGUI(args.exp_script, args.res_script, start_immediatly=args.run)
print args
d = damaris.gui.DamarisGUI.DamarisGUI(args.exp_script, args.res_script, start_immediately=args.run)
print "run"
d.run()
#for exp_script, res_script in args.exp_res_script:
# print "here"
# d = damaris.gui.DamarisGUI.DamarisGUI(exp_script, res_script, start_immediatly=args.run)
# d.run()
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
#lockdb.close()