reformatted DamarisGUI.py to make it better readable

This commit is contained in:
Markus Rosenstihl 2014-11-26 13:31:28 +00:00
parent aed38c1c89
commit 7aeb010a83

View File

@ -18,15 +18,19 @@ import xdg.BaseDirectory
# import 3rd party modules
# gui graphics
import gobject
gobject.threads_init( )
import pygtk
pygtk.require( "2.0" )
import gtk
gtk_version_missmatch = gtk.check_version( 2, 8, 0 )
if gtk_version_missmatch:
raise Exception( "insufficient gtk version: " + gtk_version_missmatch )
import gtk.gdk
gtk.gdk.threads_init( )
import gtk.glade
@ -46,13 +50,16 @@ matplotlib.rcParams["axes.formatter.limits"]="-3,3"
if matplotlib.rcParams[ "backend" ] == "GTK":
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
max_points_to_display = 0 # no limit
elif matplotlib.rcParams[ "backend" ] == "GTKCairo":
from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as FigureCanvas
max_points_to_display = 1 << 14 # cairo cannot render longer paths than 18???
else:
# default
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
max_points_to_display = 0
import matplotlib.axes
@ -75,6 +82,7 @@ debug=False
# version info
__version__ = "0.14-svn-$Revision$"
class logstream:
gui_log = None
text_log = sys.__stdout__
@ -93,6 +101,7 @@ class logstream:
def __del__( self ):
pass
global log
log = logstream( )
sys.stdout = log
@ -105,8 +114,8 @@ ExperimentWriter.log=log
BackendDriver.log = log
DataPool.log = log
class DamarisGUI:
class DamarisGUI:
ExpScript_Display = 0
ResScript_Display = 1
Monitor_Display = 2
@ -120,8 +129,6 @@ class DamarisGUI:
Quit_State = 4
def __init__( self, exp_script_filename=None, res_script_filename=None ):
# state: edit, run, stop, quit
# state transitions:
# edit -> run|quit
@ -486,7 +493,8 @@ class DamarisGUI:
self.backend_statusbar_label.set_text( b_text )
gtk.gdk.threads_leave( )
still_running=filter(None,[self.si.exp_handling, self.si.res_handling, self.si.back_driver, self.dump_thread])
still_running = filter( None,
[ self.si.exp_handling, self.si.res_handling, self.si.back_driver, self.dump_thread ] )
if len( still_running ) == 0:
if self.save_thread is None and self.dump_filename != "":
print "all subprocesses ended, saving data pool"
@ -634,7 +642,8 @@ class DamarisGUI:
try:
while len( dir_stack ):
dir_trunk = os.path.join( dir_trunk, dir_stack.pop( ) )
if os.path.isdir(dir_trunk): continue
if os.path.isdir( dir_trunk ):
continue
os.mkdir( dir_trunk )
except OSError, e:
print e
@ -659,7 +668,8 @@ class DamarisGUI:
timeline_tablecols = numpy.recarray( 0, dtype=([ ("time", "S17"),
("experiments", "int64"),
("results", "int64") ]) )
timeline_table=dump_file.createTable("/","timeline", timeline_tablecols, title="Timeline of Experiment")
timeline_table = dump_file.createTable( "/", "timeline", timeline_tablecols,
title="Timeline of Experiment" )
if tables.__version__[ 0 ] == "1":
logarray = dump_file.createVLArray( where=dump_file.root,
name="log",
@ -723,7 +733,8 @@ class DamarisGUI:
logtext_end = logtextbuffer.get_end_iter( )
logtextbuffer.move_mark( last_end, logtext_end )
# recode from unicode
logtext=codecs.getencoder("iso-8859-15")(logtextbuffer.get_text(logtext_start , logtext_end),"replace")[0]
logtext = codecs.getencoder( "iso-8859-15" )( logtextbuffer.get_text( logtext_start, logtext_end ), "replace" )[
0 ]
# avoid circular references (seems to be necessary with gtk-2.12)
del logtextbuffer, logtext_start, logtext_end, last_end
for l in logtext.splitlines( ):
@ -740,11 +751,14 @@ class DamarisGUI:
"""
pause experiment execution (that means delay backend and let others run)
"""
if self.si is None: return False
if self.si is None:
return False
pause_state = self.toolbar_pause_button.get_active( )
if pause_state:
if self.state!=DamarisGUI.Run_State: return False
if self.spool_dir is None: return False
if self.state != DamarisGUI.Run_State:
return False
if self.spool_dir is None:
return False
no = self.si.data.get( "__recentresult", -1 ) + 1
result_pattern = os.path.join( self.spool_dir, "job.%09d.result" )
job_pattern = os.path.join( self.spool_dir, "job.%09d" )
@ -761,7 +775,8 @@ class DamarisGUI:
self.backend_statusbar_label.set_text( "Backend Paused" )
else:
if self.state!=DamarisGUI.Pause_State: return False
if self.state != DamarisGUI.Pause_State:
return False
self.state = DamarisGUI.Run_State
for f in self.pause_files:
os.rename( f, f[ :-6 ] )
@ -770,7 +785,8 @@ class DamarisGUI:
def stop_experiment( self, widget, data=None ):
if self.state in [ DamarisGUI.Run_State, DamarisGUI.Pause_State ]:
if self.si is None: return
if self.si is None:
return
still_running = filter( None, [ self.si.exp_handling, self.si.res_handling, self.si.back_driver ] )
for r in still_running:
r.quit_flag.set( )
@ -836,7 +852,8 @@ class DamarisGUI:
}
if os.path.isdir( "/usr/share/doc/python%d.%d-doc/html" % (sys.version_info[ :2 ]) ):
self.doc_urls["Python"]="file:///usr/share/doc/python%d.%d-doc/html/index.html"%(sys.version_info[:2])
self.doc_urls[ "Python" ] = "file:///usr/share/doc/python%d.%d-doc/html/index.html" % (
sys.version_info[ :2 ])
if os.path.isdir( "/usr/share/doc/python-tables-doc/html" ):
self.doc_urls[ "pytables" ] = "file:///usr/share/doc/python-tables-doc/html/index.html"
@ -847,7 +864,8 @@ class DamarisGUI:
for i in xrange( 5 ):
installation_base = os.path.dirname( installation_base )
if os.path.isfile( os.path.join( installation_base, "share", "python-damaris", "doc", "index.html" ) ):
self.doc_urls["Python DAMARIS"]=os.path.join(installation_base, "share", "python-damaris", "doc", "index.html")
self.doc_urls[ "Python DAMARIS" ] = os.path.join( installation_base, "share", "python-damaris", "doc",
"index.html" )
elif os.path.isfile( "/usr/share/doc/python-damaris/html/index.html" ):
# check generic debian location
self.doc_urls[ "Python DAMARIS" ] = "file:///usr/share/doc/python-damaris/html/index.html"
@ -884,8 +902,8 @@ class DamarisGUI:
show_manual = show_doc_menu
class start_browser(threading.Thread):
class start_browser( threading.Thread ):
def __init__( self, url ):
threading.Thread.__init__( self, name="manual browser" )
self.my_webbrowser = None
@ -916,6 +934,7 @@ class start_browser(threading.Thread):
"import webbrowser\nwebbrowser.open('%s')" % self.start_url )
return True
class LogWindow:
"""
writes messages to the log window
@ -952,8 +971,8 @@ class LogWindow:
self.logstream.gui_log = None
self.logstream = None
class ScriptWidgets:
class ScriptWidgets:
def __init__( self, xml_gui ):
"""
initialize text widgets with text
@ -1129,10 +1148,12 @@ class ScriptWidgets:
# text widget related events
def check_script( self, widget, data=None ):
if not self.editing_state: return 0
if not self.editing_state:
return 0
current_page = self.main_notebook.get_current_page( )
if not current_page in [0,1]: return 0
if not current_page in [ 0, 1 ]:
return 0
script = self.get_scripts( )[ current_page ]
try:
compile( script, ("Experiment Script", "Result Script")[ current_page ], "exec" )
@ -1151,7 +1172,8 @@ class ScriptWidgets:
ln = 0
if type( lo ) is not types.IntType:
lo = 0
print "Syntax Error:\n%s in %s at line %d, offset %d"%(str(se), se.filename, ln, lo)+"\n(ToDo: Dialog)"
print "Syntax Error:\n%s in %s at line %d, offset %d" % (
str( se ), se.filename, ln, lo) + "\n(ToDo: Dialog)"
if ln > 0 and ln <= tb.get_line_count( ):
new_place = tb.get_iter_at_line_offset( ln - 1, 0 )
if lo > 0 and lo <= new_place.get_chars_in_line( ):
@ -1276,7 +1298,8 @@ class ScriptWidgets:
if (event.keyval == 0xFF09 or event.keyval == 0xFF08):
textbuffer = widget.get_buffer( )
# do not do things during selection
if (textbuffer.get_selection_bounds()): return 0
if (textbuffer.get_selection_bounds( )):
return 0
cursor_mark = textbuffer.get_insert( )
cursor_iter = textbuffer.get_iter_at_mark( cursor_mark )
if (cursor_iter.starts_line( )):
@ -1315,7 +1338,8 @@ class ScriptWidgets:
elif (event.keyval == 0xFF0D):
textbuffer = widget.get_buffer( )
# do not do things during selection
if (textbuffer.get_selection_bounds()): return 0
if (textbuffer.get_selection_bounds( )):
return 0
cursor_mark = textbuffer.get_insert( )
cursor_iter = textbuffer.get_iter_at_mark( cursor_mark )
# determine this line's indent count
@ -1336,7 +1360,8 @@ class ScriptWidgets:
# find last char before cursor
lastchar_iter = cursor_iter.copy( )
lastchar_iter.backward_char( )
if (lastchar_iter.get_char()==u":"): indent_length+=4
if (lastchar_iter.get_char( ) == u":"):
indent_length += 4
# now find indent of next line...
textbuffer.insert( cursor_iter, u'\n' + (u' ' * indent_length) )
widget.scroll_to_mark( cursor_mark, 0.0, 0 )
@ -1359,7 +1384,8 @@ class ScriptWidgets:
do the open file dialog, if necessary ask for save
"""
# ignore
if not self.editing_state: return 0
if not self.editing_state:
return 0
# Determining the tab which is currently open
current_page = self.main_notebook.get_current_page( )
@ -1421,7 +1447,8 @@ class ScriptWidgets:
save file to associated filename
"""
# ignore
if not self.editing_state: return 0
if not self.editing_state:
return 0
# Determining the tab which is currently open
current_page = self.main_notebook.get_current_page( )
@ -1432,7 +1459,8 @@ class ScriptWidgets:
else:
return 0
if filename is None: return 0
if filename is None:
return 0
# save file
if current_page == 0:
@ -1488,7 +1516,8 @@ class ScriptWidgets:
dialog = gtk.FileChooserDialog( title=dialog_title,
parent=parent_window,
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons = (gtk.STOCK_SAVE, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
buttons=(
gtk.STOCK_SAVE, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) )
dialog.set_default_response( gtk.RESPONSE_OK )
dialog.set_select_multiple( False )
@ -1522,7 +1551,8 @@ class ScriptWidgets:
def new_file( self, widget, Data=None ):
if not self.editing_state: return 0
if not self.editing_state:
return 0
current_page = self.main_notebook.get_current_page( )
if current_page == 0:
if self.experiment_script_textbuffer.get_modified( ):
@ -1613,6 +1643,7 @@ class ScriptWidgets:
if not (i < end and iter.next_line( )):
break
class ConfigTab:
"""
by now all values are saved in the GUI widgets
@ -1633,10 +1664,13 @@ class ConfigTab:
self.config_start_backend_checkbutton = self.xml_gui.get_widget( "start_backend_checkbutton" )
self.config_backend_executable_entry = self.xml_gui.get_widget( "backend_executable_entry" )
self.config_spool_dir_entry = self.xml_gui.get_widget( "spool_dir_entry" )
self.config_start_experiment_script_checkbutton=self.xml_gui.get_widget("start_experiment_script_checkbutton")
self.config_start_experiment_script_checkbutton = self.xml_gui.get_widget(
"start_experiment_script_checkbutton" )
self.config_start_result_script_checkbutton = self.xml_gui.get_widget( "start_result_script_checkbutton" )
self.config_del_results_after_processing_checkbutton=self.xml_gui.get_widget("del_results_after_processing_checkbutton")
self.config_del_jobs_after_execution_checkbutton=self.xml_gui.get_widget("del_jobs_after_execution_checkbutton")
self.config_del_results_after_processing_checkbutton = self.xml_gui.get_widget(
"del_results_after_processing_checkbutton" )
self.config_del_jobs_after_execution_checkbutton = self.xml_gui.get_widget(
"del_jobs_after_execution_checkbutton" )
self.config_data_pool_name_entry = self.xml_gui.get_widget( "data_pool_name_entry" )
self.config_data_pool_write_interval_entry = self.xml_gui.get_widget( "data_pool_write_interval_entry" )
self.config_data_pool_complib = self.xml_gui.get_widget( "CompLibs" )
@ -1967,8 +2001,8 @@ pygobject version %(pygobject)s
configfile.write( " <config key='%s' type='%s'>%s</config>\n" % (k, typename, val) )
configfile.write( "</damaris>\n" )
class MonitorWidgets:
class MonitorWidgets:
def __init__( self, xml_gui ):
"""
initialize matplotlib widgets and stuff around
@ -2021,7 +2055,8 @@ class MonitorWidgets:
self.matplot_canvas.show( )
# Matplot Toolbar hinzufuegen (Display_Table, 2. Zeile)
self.matplot_toolbar = matplotlib.backends.backend_gtk.NavigationToolbar2GTK(self.matplot_canvas, self.main_window)
self.matplot_toolbar = matplotlib.backends.backend_gtk.NavigationToolbar2GTK( self.matplot_canvas,
self.main_window )
self.display_table.attach( self.matplot_toolbar, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, 0, 0, 0 )
self.matplot_toolbar.show( )
@ -2051,7 +2086,8 @@ class MonitorWidgets:
self.xml_gui.signal_connect( "on_display_x_scaling_combobox_changed", self.display_scaling_changed )
self.xml_gui.signal_connect( "on_display_y_scaling_combobox_changed", self.display_scaling_changed )
self.xml_gui.signal_connect( "on_display_save_data_as_text_button_clicked", self.save_display_data_as_text )
self.xml_gui.signal_connect("on_display_copy_data_to_clipboard_button_clicked", self.copy_display_data_to_clipboard)
self.xml_gui.signal_connect( "on_display_copy_data_to_clipboard_button_clicked",
self.copy_display_data_to_clipboard )
# data to observe
self.data_pool = None
@ -2065,7 +2101,8 @@ class MonitorWidgets:
self.display_source_treestore.clear( )
self.source_list_add( u'None' )
none_iter = self.source_list_find( [ u'None' ] )
if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter)
if none_iter is not None:
self.display_source_combobox.set_active_iter( none_iter )
def source_list_find_one( self, model, iter, what ):
"""find node in subcategory"""
@ -2172,7 +2209,8 @@ class MonitorWidgets:
"""
sort data as fast as possible and get rid of non-interesting data
"""
if event.subject.startswith("__"): return
if event.subject.startswith( "__" ):
return
if debug and self.update_counter < 0:
print "negative event count!", self.update_counter
if self.update_counter > 5:
@ -2195,7 +2233,8 @@ class MonitorWidgets:
gobject.idle_add( self.datapool_idle_listener, event, priority=gobject.PRIORITY_DEFAULT_IDLE )
else:
if event.what == DataPool.Event.updated_value and \
(displayed_object is object_to_display or displayed_object.__class__ is object_to_display.__class__):
(
displayed_object is object_to_display or displayed_object.__class__ is object_to_display.__class__):
# oh, another category
self.update_counter += 1
gobject.idle_add( self.update_display_idle_event, self.displayed_data[ 0 ][ : ],
@ -2226,11 +2265,13 @@ class MonitorWidgets:
threading.Event( ).wait( 0.05 )
while self.update_counter > 15:
threading.Event( ).wait( 0.05 )
if event.origin is not self.displayed_data[1]: return
if event.origin is not self.displayed_data[ 1 ]:
return
self.update_counter_lock.acquire( )
self.update_counter += 1
self.update_counter_lock.release( )
gobject.idle_add(self.update_display_idle_event,self.displayed_data[0][:],priority=gobject.PRIORITY_DEFAULT_IDLE)
gobject.idle_add( self.update_display_idle_event, self.displayed_data[ 0 ][ : ],
priority=gobject.PRIORITY_DEFAULT_IDLE )
################### consume idle events
@ -2258,7 +2299,8 @@ class MonitorWidgets:
gtk.gdk.threads_leave( )
else:
# unregister old one
if self.displayed_data[1] is not None and hasattr(self.displayed_data[1], "unregister_listener"):
if self.displayed_data[ 1 ] is not None and hasattr( self.displayed_data[ 1 ],
"unregister_listener" ):
self.displayed_data[ 1 ].unregister_listener( self.datastructures_listener )
self.displayed_data[ 1 ] = None
# register new one
@ -2286,7 +2328,8 @@ class MonitorWidgets:
self.displayed_data[ 0 ] == event.subject):
self.displayed_data = [ None, None ]
none_iter = self.source_list_find( [ u'None' ] )
if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter)
if none_iter is not None:
self.display_source_combobox.set_active_iter( none_iter )
# not necessary, because event will be submitted
#self.clear_display()
self.source_list_remove( event.subject )
@ -2322,8 +2365,10 @@ class MonitorWidgets:
def display_source_changed_event( self, widget, data=None ):
new_data_name = self.source_list_current( )
if (self.displayed_data[0] is None and new_data_name==u"None"): return
if (self.displayed_data[0]==new_data_name): return
if (self.displayed_data[ 0 ] is None and new_data_name == u"None"):
return
if (self.displayed_data[ 0 ] == new_data_name):
return
if self.displayed_data[ 1 ] is not None and hasattr( self.displayed_data[ 1 ], "unregister_listener" ):
self.displayed_data[ 1 ].unregister_listener( self.datastructures_listener )
self.displayed_data[ 1 ] = None
@ -2334,7 +2379,8 @@ class MonitorWidgets:
self.clear_display( )
elif self.data_pool is None or new_data_name not in self.data_pool:
none_iter = self.source_list_find( [ u'None' ] )
if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter)
if none_iter is not None:
self.display_source_combobox.set_active_iter( none_iter )
self.display_source_path_label.set_label( u"" )
else:
new_data_struct = self.data_pool[ new_data_name ]
@ -2411,7 +2457,8 @@ class MonitorWidgets:
dialog = gtk.FileChooserDialog( title=dialog_title,
parent=self.main_window,
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons = (gtk.STOCK_SAVE, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
buttons=(
gtk.STOCK_SAVE, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) )
dialog.set_default_response( gtk.RESPONSE_OK )
dialog.set_current_name( data_to_save[ 0 ] )
@ -2443,7 +2490,8 @@ class MonitorWidgets:
tmpstring = u""
tmpdata.seek( 0 )
for line in tmpdata:
if line[0]=="#": continue
if line[ 0 ] == "#":
continue
tmpstring += line
del tmpdata
clipboard = gtk.clipboard_get( )
@ -2552,7 +2600,8 @@ class MonitorWidgets:
xdata = in_result.get_xdata( )
chans = in_result.get_number_of_channels( )
data = [ ]
colors = [(0,0,0.8,1), (0.7,0,0,1), (0,0.7,0,1), (0.7,0.5,0,1), (0,0,0,1)] # rgba tuples: blue, red, green, yellow
colors = [ (0, 0, 0.8, 1), (0.7, 0, 0, 1), (0, 0.7, 0, 1), (0.7, 0.5, 0, 1),
(0, 0, 0, 1) ] # rgba tuples: blue, red, green, yellow
for i in xrange( chans ):
data.append( in_result.get_ydata( i ) )
@ -2571,11 +2620,14 @@ class MonitorWidgets:
if len( self.graphen ) == 0:
for i in xrange( chans ):
self.graphen.extend(self.matplot_axes.plot(xdata, data[i], linestyle="-", color=colors[i], linewidth = 2))
self.graphen.extend(
self.matplot_axes.plot( xdata, data[ i ], linestyle="-", color=colors[ i ], linewidth=2 ) )
for i in xrange( chans ):
# initialize error bars
self.graphen.extend(self.matplot_axes.plot([0.0], [0.0], linestyle="-", color=colors[i], linewidth = 0.5))
self.graphen.extend(self.matplot_axes.plot([0.0], [0.0], linestyle="-", color=colors[i], linewidth = 0.5))
self.graphen.extend(
self.matplot_axes.plot( [ 0.0 ], [ 0.0 ], linestyle="-", color=colors[ i ], linewidth=0.5 ) )
self.graphen.extend(
self.matplot_axes.plot( [ 0.0 ], [ 0.0 ], linestyle="-", color=colors[ i ], linewidth=0.5 ) )
else:
for i in xrange( chans ):
self.graphen[ i ].set_data( xdata, data[ i ] )
@ -2660,7 +2712,6 @@ class MonitorWidgets:
self.matplot_axes.lines.remove( self.measurementresultline[ 0 ] )
self.measurementresultline = None
[ k, v, e ] = in_result.get_errorplotdata( )
if k.shape[ 0 ] != 0:
xmin = k.min( )
@ -2729,7 +2780,6 @@ class MonitorWidgets:
self.measurementresultgraph = self.matplot_axes.errorbar( x=k, y=v, yerr=e, fmt="bx" )
[ k, v ] = in_result.get_lineplotdata( )
if k.shape[ 0 ] != 0 and v.shape == k.shape:
self.measurementresultline = self.matplot_axes.plot( k, v, 'r-' )
@ -2754,7 +2804,8 @@ class MonitorWidgets:
self.clear_display( )
to_draw = self.data_pool[ self.displayed_data[ 0 ] ]
if to_draw is None: return
if to_draw is None:
return
self.update_display( )
def begin_print( self, operation, context, print_data ):
@ -2800,12 +2851,15 @@ class MonitorWidgets:
renderer.height = height_in_points
# centered picture
renderer.matrix_flipy = cairo.Matrix( yy=-1, xx=1,
y0=page_setup.get_top_margin(gtk.UNIT_POINTS)+(height_in_points+freeheight_in*dpi)/2.0,
x0=page_setup.get_left_margin(gtk.UNIT_POINTS)+(freewidth_in*dpi-width_in_points)/2.0)
y0=page_setup.get_top_margin( gtk.UNIT_POINTS ) + (
height_in_points + freeheight_in * dpi) / 2.0,
x0=page_setup.get_left_margin( gtk.UNIT_POINTS ) + (
freewidth_in * dpi - width_in_points) / 2.0 )
renderer.set_ctx_from_surface( context.get_cairo_context( ).get_target( ) )
# unfortunateley there is need for extra treatment of text
renderer.ctx.translate(page_setup.get_left_margin(gtk.UNIT_POINTS)+(freewidth_in*dpi-width_in_points)/2.0,
renderer.ctx.translate(
page_setup.get_left_margin( gtk.UNIT_POINTS ) + (freewidth_in * dpi - width_in_points) / 2.0,
page_setup.get_top_margin( gtk.UNIT_POINTS ) - height_in_points / 2.0 + freeheight_in * dpi / 2.0 )
renderer.ctx.save( ) # important! there will be no effect of previous statement without save
fc.figure.draw( renderer )
@ -2815,12 +2869,14 @@ class MonitorWidgets:
fc.figure.set_facecolor( orig_f_color )
fc.figure.set_edgecolor( orig_e_color )
class ScriptInterface:
"""
texts or code objects are executed as experiment and result script the backend is started with sufficient arguments
"""
def __init__(self, exp_script=None, res_script=None, backend_executable=None, spool_dir="spool", clear_jobs=True, clear_results=True):
def __init__( self, exp_script=None, res_script=None, backend_executable=None, spool_dir="spool", clear_jobs=True,
clear_results=True ):
"""
run experiment scripts and result scripts
"""
@ -2835,17 +2891,24 @@ 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)
if self.exp_script: self.exp_writer=self.back_driver.get_exp_writer()
if self.res_script: self.res_reader=self.back_driver.get_res_reader()
self.back_driver = BackendDriver.BackendDriver( self.backend_executable, spool_dir, clear_jobs,
clear_results )
if self.exp_script:
self.exp_writer = self.back_driver.get_exp_writer( )
if self.res_script:
self.res_reader = self.back_driver.get_res_reader( )
elif self.exp_script and self.res_script:
self.back_driver = None
self.res_reader=ResultReader.BlockingResultReader(spool_dir, clear_jobs=self.clear_jobs, clear_results=self.clear_results)
self.res_reader = ResultReader.BlockingResultReader( spool_dir, clear_jobs=self.clear_jobs,
clear_results=self.clear_results )
self.exp_writer = ExperimentWriter.ExperimentWriter( spool_dir, inform_last_job=self.res_reader )
else:
self.back_driver = None
if self.exp_script: self.exp_writer=ExperimentWriter.ExperimentWriter(spool_dir)
if self.res_script: self.res_reader=ResultReader.ResultReader(spool_dir, clear_jobs=self.clear_jobs, clear_results=self.clear_results)
if self.exp_script:
self.exp_writer = ExperimentWriter.ExperimentWriter( spool_dir )
if self.res_script:
self.res_reader = ResultReader.ResultReader( spool_dir, clear_jobs=self.clear_jobs,
clear_results=self.clear_results )
self.data = DataPool( )
def runScripts( self ):
@ -2864,8 +2927,10 @@ class ScriptInterface:
while (not self.back_driver.quit_flag.isSet( ) and \
self.back_driver.core_pid is None and self.back_driver.core_pid <= 0):
self.back_driver.quit_flag.wait( 0.1 )
if self.exp_handling: self.exp_handling.start()
if self.res_handling: self.res_handling.start()
if self.exp_handling:
self.exp_handling.start( )
if self.res_handling:
self.res_handling.start( )
finally:
self.exp_writer = self.res_reader = None