48
48
49
49
splash .update_text ('importing labscript suite modules' )
50
50
from labscript_utils .ls_zprocess import zmq_get , ProcessTree , ZMQServer
51
- from labscript_utils .labconfig import LabConfig
51
+ from labscript_utils .labconfig import LabConfig , save_appconfig , load_appconfig
52
52
from labscript_utils .setup_logging import setup_logging
53
53
import labscript_utils .shared_drive as shared_drive
54
54
from labscript_utils import dedent
@@ -3040,10 +3040,10 @@ def get_save_data(self):
3040
3040
shot_output_folder = ''
3041
3041
3042
3042
# Get the server hostnames:
3043
- BLACS_host = self .ui .lineEdit_BLACS_hostname .text ()
3043
+ blacs_host = self .ui .lineEdit_BLACS_hostname .text ()
3044
3044
3045
3045
send_to_runviewer = self .ui .checkBox_view_shots .isChecked ()
3046
- send_to_BLACS = self .ui .checkBox_run_shots .isChecked ()
3046
+ send_to_blacs = self .ui .checkBox_run_shots .isChecked ()
3047
3047
shuffle = self .ui .pushButton_shuffle .isChecked ()
3048
3048
3049
3049
# axes tab information
@@ -3062,19 +3062,17 @@ def get_save_data(self):
3062
3062
'shot_output_folder' : shot_output_folder ,
3063
3063
'is_using_default_shot_output_folder' : is_using_default_shot_output_folder ,
3064
3064
'send_to_runviewer' : send_to_runviewer ,
3065
- 'send_to_BLACS ' : send_to_BLACS ,
3065
+ 'send_to_blacs ' : send_to_blacs ,
3066
3066
'shuffle' : shuffle ,
3067
3067
'axes' : axes ,
3068
- 'BLACS_host ' : BLACS_host }
3068
+ 'blacs_host ' : blacs_host }
3069
3069
return save_data
3070
3070
3071
3071
def save_configuration (self , save_file ):
3072
- runmanager_config = LabConfig (save_file )
3073
3072
save_data = self .get_save_data ()
3074
3073
self .last_save_config_file = save_file
3075
3074
self .last_save_data = save_data
3076
- for key , value in save_data .items ():
3077
- runmanager_config .set ('runmanager_state' , key , pprint .pformat (value ))
3075
+ save_appconfig (save_file , {'runmanager_state' : save_data })
3078
3076
3079
3077
def on_load_configuration_triggered (self ):
3080
3078
save_data = self .get_save_data ()
@@ -3117,7 +3115,7 @@ def load_configuration(self, filename):
3117
3115
self .close_globals_file (globals_file , confirm = False )
3118
3116
# Ensure folder exists, if this was opened programmatically we are
3119
3117
# creating the file, so the directory had better exist!
3120
- runmanager_config = LabConfig (filename )
3118
+ runmanager_config = load_appconfig (filename ). get ( 'runmanager_state' , {} )
3121
3119
3122
3120
has_been_a_warning = [False ]
3123
3121
def warning (message ):
@@ -3126,118 +3124,82 @@ def warning(message):
3126
3124
self .output_box .output ('\n ' )
3127
3125
self .output_box .output ('Warning: %s\n ' % message , red = True )
3128
3126
3129
- try :
3130
- h5_files_open = ast .literal_eval (runmanager_config .get ('runmanager_state' , 'h5_files_open' ))
3131
- except Exception :
3132
- pass
3133
- else :
3134
- for globals_file in h5_files_open :
3135
- if os .path .exists (globals_file ):
3136
- try :
3137
- self .open_globals_file (globals_file )
3138
- self .last_opened_globals_folder = os .path .dirname (globals_file )
3139
- except Exception :
3140
- raise_exception_in_thread (sys .exc_info ())
3141
- continue
3142
- else :
3143
- self .output_box .output ('\n Warning: globals file %s no longer exists\n ' % globals_file , red = True )
3144
- try :
3145
- active_groups = ast .literal_eval (runmanager_config .get ('runmanager_state' , 'active_groups' ))
3146
- except Exception :
3147
- pass
3148
- else :
3149
- for globals_file , group_name in active_groups :
3150
- try :
3151
- group_active_item = self .get_group_item_by_name (globals_file , group_name , self .GROUPS_COL_ACTIVE )
3152
- group_active_item .setCheckState (QtCore .Qt .Checked )
3153
- except LookupError :
3154
- warning ("previously active group '%s' in %s no longer exists" % (group_name , globals_file ))
3155
- try :
3156
- groups_open = ast .literal_eval (runmanager_config .get ('runmanager_state' , 'groups_open' ))
3157
- except Exception :
3158
- pass
3159
- else :
3160
- for globals_file , group_name in groups_open :
3161
- # First check if it exists:
3127
+ for globals_file in runmanager_config .get ('h5_files_open' , []):
3128
+ if os .path .exists (globals_file ):
3162
3129
try :
3163
- self .get_group_item_by_name (globals_file , group_name , self .GROUPS_COL_NAME )
3164
- except LookupError :
3165
- warning ("previously open group '%s' in %s no longer exists" % (group_name , globals_file ))
3166
- else :
3167
- self .open_group (globals_file , group_name )
3130
+ self .open_globals_file (globals_file )
3131
+ self .last_opened_globals_folder = os .path .dirname (globals_file )
3132
+ except Exception :
3133
+ raise_exception_in_thread (sys .exc_info ())
3134
+ continue
3135
+ else :
3136
+ self .output_box .output ('\n Warning: globals file %s no longer exists\n ' % globals_file , red = True )
3168
3137
3169
- try :
3170
- current_labscript_file = ast .literal_eval (
3171
- runmanager_config .get ('runmanager_state' , 'current_labscript_file' ))
3172
- except Exception :
3173
- pass
3174
- else :
3138
+ for globals_file , group_name in runmanager_config .get ('active_groups' , []):
3139
+ try :
3140
+ group_active_item = self .get_group_item_by_name (globals_file , group_name , self .GROUPS_COL_ACTIVE )
3141
+ group_active_item .setCheckState (QtCore .Qt .Checked )
3142
+ except LookupError :
3143
+ warning ("previously active group '%s' in %s no longer exists" % (group_name , globals_file ))
3144
+
3145
+ for globals_file , group_name in runmanager_config .get ('groups_open' , []):
3146
+ # First check if it exists:
3147
+ try :
3148
+ self .get_group_item_by_name (globals_file , group_name , self .GROUPS_COL_NAME )
3149
+ except LookupError :
3150
+ warning ("previously open group '%s' in %s no longer exists" % (group_name , globals_file ))
3151
+ else :
3152
+ self .open_group (globals_file , group_name )
3153
+
3154
+ current_labscript_file = runmanager_config .get ('current_labscript_file' )
3155
+ if current_labscript_file is not None :
3175
3156
if os .path .exists (current_labscript_file ):
3176
3157
self .ui .lineEdit_labscript_file .setText (current_labscript_file )
3177
3158
self .last_opened_labscript_folder = os .path .dirname (current_labscript_file )
3178
3159
elif current_labscript_file :
3179
3160
warning ('previously selected labscript file %s no longer exists' % current_labscript_file )
3180
- try :
3181
- shot_output_folder = ast .literal_eval (runmanager_config .get ('runmanager_state' , 'shot_output_folder' ))
3182
- except Exception :
3183
- pass
3184
- else :
3161
+
3162
+ shot_output_folder = runmanager_config .get ('shot_output_folder' )
3163
+ if shot_output_folder is not None :
3185
3164
self .ui .lineEdit_shot_output_folder .setText (shot_output_folder )
3186
3165
self .last_selected_shot_output_folder = os .path .dirname (shot_output_folder )
3187
- try :
3188
- is_using_default_shot_output_folder = ast .literal_eval (
3189
- runmanager_config .get ('runmanager_state' , 'is_using_default_shot_output_folder' ))
3190
- except Exception :
3191
- pass
3192
- else :
3193
- if is_using_default_shot_output_folder :
3194
- default_output_folder = self .get_default_output_folder ()
3195
- self .ui .lineEdit_shot_output_folder .setText (default_output_folder )
3196
- self .last_selected_shot_output_folder = os .path .dirname (default_output_folder )
3197
- try :
3198
- send_to_runviewer = ast .literal_eval (runmanager_config .get ('runmanager_state' , 'send_to_runviewer' ))
3199
- except Exception :
3200
- pass
3201
- else :
3166
+
3167
+ if runmanager_config .get ('is_using_default_shot_output_folder' , False ):
3168
+ default_output_folder = self .get_default_output_folder ()
3169
+ self .ui .lineEdit_shot_output_folder .setText (default_output_folder )
3170
+ self .last_selected_shot_output_folder = os .path .dirname (default_output_folder )
3171
+
3172
+ send_to_runviewer = runmanager_config .get ('send_to_runviewer' )
3173
+ if send_to_runviewer is not None :
3202
3174
self .ui .checkBox_view_shots .setChecked (send_to_runviewer )
3203
- try :
3204
- send_to_BLACS = ast .literal_eval (runmanager_config .get ('runmanager_state' , 'send_to_BLACS' ))
3205
- except Exception :
3206
- pass
3207
- else :
3208
- self .ui .checkBox_run_shots .setChecked (send_to_BLACS )
3175
+
3176
+ send_to_blacs = runmanager_config .get ('send_to_blacs' )
3177
+ if send_to_blacs is not None :
3178
+ self .ui .checkBox_run_shots .setChecked (send_to_blacs )
3209
3179
3210
3180
# clear the axes model first
3211
3181
if self .axes_model .rowCount ():
3212
3182
self .axes_model .removeRows (0 , self .axes_model .rowCount ())
3183
+
3213
3184
# set the state of the global shuffle button. This ensure that if no axes items get loaded afterwards
3214
3185
# (e.g. because the globals in the .ini file are no longer expansion globals), then we still have
3215
3186
# an approximate state for the shuffle button that will apply to whatever globals are to be expanded.
3216
- try :
3217
- shuffle = ast .literal_eval (runmanager_config .get ('runmanager_state' , 'shuffle' ))
3218
- except Exception :
3219
- pass
3220
- else :
3221
- if shuffle :
3222
- self .ui .pushButton_shuffle .setChecked (True )
3187
+ if runmanager_config .get ('shuffle' , False ):
3188
+ self .ui .pushButton_shuffle .setChecked (True )
3189
+
3223
3190
# Now load the axes states (order and shuffle). This will also ensure the shuffle button matches the
3224
3191
# state of these items (since we don't save/restore the tri-state nature of the global shuffle button
3225
- try :
3226
- axes = ast .literal_eval (runmanager_config .get ('runmanager_state' , 'axes' ))
3227
- except Exception :
3228
- pass
3229
- else :
3230
- if isinstance (axes , list ):
3231
- # clear model
3232
- for name , shuffle in axes :
3233
- self .add_item_to_axes_model (name , shuffle )
3234
- self .update_axes_indentation ()
3235
- try :
3236
- BLACS_host = ast .literal_eval (runmanager_config .get ('runmanager_state' , 'BLACS_host' ))
3237
- except Exception :
3238
- pass
3239
- else :
3240
- self .ui .lineEdit_BLACS_hostname .setText (BLACS_host )
3192
+ axes = runmanager_config .get ('axes' )
3193
+ if axes is not None and isinstance (axes , list ):
3194
+ # clear model
3195
+ for name , shuffle in axes :
3196
+ self .add_item_to_axes_model (name , shuffle )
3197
+ self .update_axes_indentation ()
3198
+
3199
+ blacs_host = runmanager_config .get ('blacs_host' )
3200
+ if blacs_host is not None :
3201
+ self .ui .lineEdit_BLACS_hostname .setText (blacs_host )
3202
+
3241
3203
# Set as self.last_save_data:
3242
3204
save_data = self .get_save_data ()
3243
3205
self .last_save_data = save_data
0 commit comments