Queueing works now with more than 2 queued experiments
This commit is contained in:
parent
7280a9aba3
commit
58515f1cf3
@ -18,6 +18,7 @@ import xdg.BaseDirectory
|
|||||||
# import 3rd party modules
|
# import 3rd party modules
|
||||||
# gui graphics
|
# gui graphics
|
||||||
import gobject
|
import gobject
|
||||||
|
import glob
|
||||||
|
|
||||||
gobject.threads_init( )
|
gobject.threads_init( )
|
||||||
import pygtk
|
import pygtk
|
||||||
@ -80,7 +81,7 @@ from damaris.data import DataPool, Accumulation, ADC_Result, MeasurementResult
|
|||||||
debug = False
|
debug = False
|
||||||
|
|
||||||
# version info
|
# version info
|
||||||
__version__ = "0.15-0-$Revision$"
|
__version__ = "0.18-0-$Revision$"
|
||||||
|
|
||||||
|
|
||||||
class logstream:
|
class logstream:
|
||||||
@ -115,6 +116,30 @@ BackendDriver.log = log
|
|||||||
DataPool.log = log
|
DataPool.log = log
|
||||||
|
|
||||||
|
|
||||||
|
class LockFile:
|
||||||
|
def __init__(self):
|
||||||
|
self.index = 0
|
||||||
|
self.templ = os.path.expanduser("~/.damaris.lock")
|
||||||
|
self.existing = []
|
||||||
|
self._lockfile = self.lockfile(self.index)
|
||||||
|
self.has_lockfile = None
|
||||||
|
|
||||||
|
def lockfile(self, idx):
|
||||||
|
return "%s.%i"%(self.templ, idx)
|
||||||
|
|
||||||
|
def get_lockfile(self):
|
||||||
|
#self._lockfile = self.lockfile()
|
||||||
|
while os.path.exists(self._lockfile):
|
||||||
|
self.existing.append(self._lockfile)
|
||||||
|
self.index += 1
|
||||||
|
self._lockfile = self.lockfile(self.index)
|
||||||
|
print self._lockfile
|
||||||
|
self.has_lockfile = self._lockfile
|
||||||
|
|
||||||
|
def no_lockfiles(self):
|
||||||
|
return glob.glob("%s.*"%self.templ) == []
|
||||||
|
|
||||||
|
|
||||||
class DamarisGUI:
|
class DamarisGUI:
|
||||||
ExpScript_Display = 0
|
ExpScript_Display = 0
|
||||||
ResScript_Display = 1
|
ResScript_Display = 1
|
||||||
@ -157,7 +182,7 @@ class DamarisGUI:
|
|||||||
|
|
||||||
self.config = ConfigTab( self.xml_gui )
|
self.config = ConfigTab( self.xml_gui )
|
||||||
# lock file to prevent other DAMARIS to start immediatly
|
# lock file to prevent other DAMARIS to start immediatly
|
||||||
self.lockfile = os.path.expanduser("~/.damaris.lock")
|
self.lockfile = LockFile() # = os.path.expanduser("~/.damaris.lock")
|
||||||
|
|
||||||
exp_script = u""
|
exp_script = u""
|
||||||
if exp_script_filename is not None and exp_script_filename != "":
|
if exp_script_filename is not None and exp_script_filename != "":
|
||||||
@ -414,14 +439,18 @@ class DamarisGUI:
|
|||||||
# only observe lock file if you want to start immediatly after start up
|
# only observe lock file if you want to start immediatly after start up
|
||||||
if self.start_immediatly:
|
if self.start_immediatly:
|
||||||
loop_run=0
|
loop_run=0
|
||||||
while os.path.exists(self.lockfile):
|
interval = 2
|
||||||
time.sleep(0.2)
|
self.lockfile.get_lockfile()
|
||||||
|
while not self.lockfile.no_lockfiles():
|
||||||
|
time.sleep(interval)
|
||||||
while gtk.events_pending():
|
while gtk.events_pending():
|
||||||
gtk.main_iteration(False)
|
gtk.main_iteration(False)
|
||||||
if loop_run%10==0:
|
if loop_run > 2:
|
||||||
self.experiment_script_statusbar_label.set_text("Waiting for other experiment to finish (Lockfile: %s)" % self.lockfile)
|
self.experiment_script_statusbar_label.set_text("Waiting for other experiment to finish (My lockfile: %s)" % self.lockfile.has_lockfile)
|
||||||
print "Lockfile still exists, waiting ... (%s)" % self.lockfile
|
loop_run = 0
|
||||||
loop_run += 1
|
print "Lockfile still exists, waiting ... (%s)" % self.lockfile.has_lockfile
|
||||||
|
loop_run += interval
|
||||||
|
|
||||||
# start experiment
|
# start experiment
|
||||||
try:
|
try:
|
||||||
self.spool_dir = os.path.abspath( actual_config[ "spool_dir" ] )
|
self.spool_dir = os.path.abspath( actual_config[ "spool_dir" ] )
|
||||||
@ -472,8 +501,8 @@ class DamarisGUI:
|
|||||||
self.main_notebook.set_current_page( DamarisGUI.Monitor_Display )
|
self.main_notebook.set_current_page( DamarisGUI.Monitor_Display )
|
||||||
|
|
||||||
# create lock file
|
# create lock file
|
||||||
print "Creating lockfile %s"%self.lockfile
|
print "Creating lockfile %s"%self.lockfile.has_lockfile
|
||||||
lfile = open(self.lockfile, "w").close()
|
lfile = open(self.lockfile.has_lockfile, "w").close()
|
||||||
# set running
|
# set running
|
||||||
if self.si.exp_handling is not None:
|
if self.si.exp_handling is not None:
|
||||||
self.experiment_script_statusbar_label.set_text( "Experiment Script Running (0)" )
|
self.experiment_script_statusbar_label.set_text( "Experiment Script Running (0)" )
|
||||||
@ -621,9 +650,9 @@ class DamarisGUI:
|
|||||||
# keep data to display but throw away everything else
|
# keep data to display but throw away everything else
|
||||||
self.si = None
|
self.si = None
|
||||||
# delete locak file so that other experiment can start
|
# delete locak file so that other experiment can start
|
||||||
if os.path.exists(self.lockfile):
|
if os.path.exists(self.lockfile.has_lockfile):
|
||||||
try:
|
try:
|
||||||
os.remove(self.lockfile)
|
os.remove(self.lockfile.has_lockfile)
|
||||||
except:
|
except:
|
||||||
raise IOError("Could not remove lock file: %s"%self.lockfile)
|
raise IOError("Could not remove lock file: %s"%self.lockfile)
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user