made function (i.e., script name) enforced; clear entries on error

This commit is contained in:
gac-maloja
2021-09-30 14:50:13 +02:00
parent d7d766057f
commit d8e6d0a05f
2 changed files with 12 additions and 2 deletions

13
scam.py
View File

@ -18,9 +18,12 @@ SHOWN_SETTINGS = {
ENFORCED_SETTINGS = [ ENFORCED_SETTINGS = [
"image_background_enable", "image_background_enable",
"image_threshold" "image_threshold",
"function"
] ]
SCRIPT_NAME = "spectrometer.py"
import itertools import itertools
@ -97,6 +100,8 @@ class MainPanel(wx.Panel):
def on_select(self, event): def on_select(self, event):
self.entries.clear()
self.instance = instance = self.cb_pls.GetValue() self.instance = instance = self.cb_pls.GetValue()
cfg = pc.get_instance_config(instance) cfg = pc.get_instance_config(instance)
print(cfg) print(cfg)
@ -167,12 +172,18 @@ def check_incoming_cfg(cfg):
if thresh is None: if thresh is None:
print(f"Warning: found: threshold = None, will overwrite with value of image_threshold ({printable_img_thresh})") 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): def check_outgoing_cfg(cfg):
bkg = cfg["image_background"] bkg = cfg["image_background"]
cfg["image_background_enable"] = "passive" if bkg else None cfg["image_background_enable"] = "passive" if bkg else None
cfg["image_threshold"] = None cfg["image_threshold"] = None
cfg["function"] = SCRIPT_NAME
return cfg return cfg

View File

@ -15,7 +15,6 @@ class SettingsList(wx.GridSizer):
if names is None: if names is None:
names = {} names = {}
self.clear()
for k, v in sorted(cfg.items()): for k, v in sorted(cfg.items()):
n = names.get(k, k) n = names.get(k, k)
self.add(k, n, v) self.add(k, n, v)