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 = [
"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

View File

@ -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)