Skip to content

Commit 8f49923

Browse files
Merge pull request #38 from chrisjbillington/config-fix
Use labconfig.save_appconfig and load_appconfig
2 parents df88849 + 189619b commit 8f49923

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

runviewer/__main__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
from labscript_utils.connections import ConnectionTable
6666
import labscript_devices
6767

68-
from labscript_utils.labconfig import LabConfig
68+
from labscript_utils.labconfig import LabConfig, save_appconfig, load_appconfig
6969
from labscript_utils.ls_zprocess import ZMQServer, ProcessTree
7070
process_tree = ProcessTree.instance()
7171
process_tree.zlock_client.set_process_name('runviewer')
@@ -592,11 +592,8 @@ def on_load_channel_config(self):
592592
if isinstance(config_file, tuple):
593593
config_file, _ = config_file
594594
if config_file:
595-
runviewer_config = LabConfig(config_file)
596-
try:
597-
channels = ast.literal_eval(runviewer_config.get('runviewer_state', 'Channels'))
598-
except (LabConfig.NoOptionError, LabConfig.NoSectionError):
599-
channels = {}
595+
runviewer_config = load_appconfig(config_file).get('runviewer_state', {})
596+
channels = runviewer_config.get('channels', {})
600597

601598
for row, (channel, checked) in enumerate(channels):
602599
check_items = self.channel_model.findItems(channel)
@@ -621,14 +618,13 @@ def on_save_channel_config(self):
621618
save_file, _ = save_file
622619

623620
if save_file:
624-
runviewer_config = LabConfig(save_file)
625621

626622
channels = []
627623
for row in range(self.channel_model.rowCount()):
628624
item = self.channel_model.item(row)
629625
channels.append((item.text(), item.checkState() == Qt.Checked))
630626

631-
runviewer_config.set('runviewer_state', 'Channels', pprint.pformat(channels))
627+
save_appconfig(save_file, {'runviewer_state': {'channels': channels}})
632628

633629
def on_toggle_shutter(self, checked, current_shot):
634630
for channel in self.shutter_lines:

0 commit comments

Comments
 (0)