From 84dd157f082234e7797496015bf3c892ce0c8015 Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Tue, 20 Mar 2018 18:16:09 +0100 Subject: [PATCH] preliminary work for queued experiments --- src/gui/DamarisGUI.py | 24 ++++++++++++++++++++---- tests/exp_test.py | 4 ++-- tests/res_test.py | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/gui/DamarisGUI.py b/src/gui/DamarisGUI.py index c32d0f4..b8b8797 100644 --- a/src/gui/DamarisGUI.py +++ b/src/gui/DamarisGUI.py @@ -156,6 +156,8 @@ class DamarisGUI: self.monitor = MonitorWidgets( self.xml_gui ) self.config = ConfigTab( self.xml_gui ) + # lock file to prevent other DAMARIS to start immediatly + self.lockfile = os.path.expanduser("~/.damaris.lock") exp_script = u"" if exp_script_filename is not None and exp_script_filename != "": @@ -349,7 +351,7 @@ class DamarisGUI: self.sw.enable_editing( ) return - # check whether scripts are syntacticaly valid + # check whether scripts are syntactically valid # should be merged with check script function exp_code = None if exp_script != "": @@ -408,7 +410,13 @@ class DamarisGUI: # set the text mark for hdf logging if self.log.textbuffer.get_mark( "lastdumped" ) is None: self.log.textbuffer.create_mark( "lastdumped", self.log.textbuffer.get_end_iter( ), left_gravity=True ) - + # only observe lock file if you want to start immediatly after start up + if self.start_immediatly: + while os.path.exists(self.lockfile): + time.sleep(0.2) + gtk.main_iteration() + self.experiment_script_statusbar_label.set_text("Waiting for other experiment to finish ... (Loackfile: %s)" % self.lockfile) + print "Lockfile still exists, waiting ... (%s)" % self.lockfile # start experiment try: self.spool_dir = os.path.abspath( actual_config[ "spool_dir" ] ) @@ -458,6 +466,9 @@ class DamarisGUI: # switch to grapics self.main_notebook.set_current_page( DamarisGUI.Monitor_Display ) + # create lock file + print "Creating lockfile %s"%self.lockfile + lfile = open(self.lockfile, "w").close() # set running if self.si.exp_handling is not None: self.experiment_script_statusbar_label.set_text( "Experiment Script Running (0)" ) @@ -604,7 +615,12 @@ class DamarisGUI: # keep data to display but throw away everything else self.si = None - + # delete locak file so that other experiment can start + if os.path.exists(self.lockfile): + try: + os.remove(self.lockfile) + except: + raise IOError("Could not remove lock file: %s"%self.lockfile) return False # dump states? @@ -3135,7 +3151,7 @@ class ScriptInterface: self.exp_writer = self.res_reader = self.back_driver = None if self.backend_executable is not None and self.backend_executable != "": self.back_driver = BackendDriver.BackendDriver( self.backend_executable, spool_dir, clear_jobs, - clear_results ) + clear_results) if self.exp_script: self.exp_writer = self.back_driver.get_exp_writer( ) if self.res_script: diff --git a/tests/exp_test.py b/tests/exp_test.py index bc0a7c5..ad73319 100644 --- a/tests/exp_test.py +++ b/tests/exp_test.py @@ -7,5 +7,5 @@ def test(): return e def experiment(): - for i in range(1): - yield test() + for i in range(1000): + yield test() \ No newline at end of file diff --git a/tests/res_test.py b/tests/res_test.py index fc60898..e841ab1 100644 --- a/tests/res_test.py +++ b/tests/res_test.py @@ -1,4 +1,4 @@ def result(): for num,ts in enumerate(results): data["ts %i"%num] = ts - print ts \ No newline at end of file + #print ts \ No newline at end of file