From d8e6d0a05fb5e7371317759447dff361a89b4024 Mon Sep 17 00:00:00 2001 From: gac-maloja Date: Thu, 30 Sep 2021 14:50:13 +0200 Subject: [PATCH] made function (i.e., script name) enforced; clear entries on error --- scam.py | 13 ++++++++++++- settings.py | 1 - 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scam.py b/scam.py index 7e196aa..062d35c 100755 --- a/scam.py +++ b/scam.py @@ -18,9 +18,12 @@ SHOWN_SETTINGS = { ENFORCED_SETTINGS = [ "image_background_enable", - "image_threshold" + "image_threshold", + "function" ] +SCRIPT_NAME = "spectrometer.py" + import itertools @@ -97,6 +100,8 @@ class MainPanel(wx.Panel): def on_select(self, event): + self.entries.clear() + self.instance = instance = self.cb_pls.GetValue() cfg = pc.get_instance_config(instance) print(cfg) @@ -167,12 +172,18 @@ def check_incoming_cfg(cfg): if thresh is None: print(f"Warning: found: threshold = None, will overwrite with value of image_threshold ({printable_img_thresh})") + script = cfg.get("function") + if script != SCRIPT_NAME: + printable_script = printable(script) + print(f"Warning: found: function = {printable_script}, this will be set to \"{SCRIPT_NAME}\" upon saving") + def check_outgoing_cfg(cfg): bkg = cfg["image_background"] cfg["image_background_enable"] = "passive" if bkg else None cfg["image_threshold"] = None + cfg["function"] = SCRIPT_NAME return cfg diff --git a/settings.py b/settings.py index 0312649..6fc4b6b 100644 --- a/settings.py +++ b/settings.py @@ -15,7 +15,6 @@ class SettingsList(wx.GridSizer): if names is None: names = {} - self.clear() for k, v in sorted(cfg.items()): n = names.get(k, k) self.add(k, n, v)