drop the scheduler from the config if it's empty
This commit is contained in:
parent
bdf1ed4709
commit
3f7a93acfc
@ -1,7 +1,5 @@
|
|||||||
from owrx.form.input import Input, CheckboxInput, DropdownInput, DropdownEnum, TextInput
|
from owrx.form.input import Input, CheckboxInput, DropdownInput, DropdownEnum, TextInput
|
||||||
from owrx.soapy import SoapySettings
|
from owrx.soapy import SoapySettings
|
||||||
from functools import reduce
|
|
||||||
from operator import and_
|
|
||||||
|
|
||||||
|
|
||||||
class GainInput(Input):
|
class GainInput(Input):
|
||||||
@ -343,19 +341,20 @@ class SchedulerInput(Input):
|
|||||||
if select_id in data:
|
if select_id in data:
|
||||||
if data[select_id][0] == "static":
|
if data[select_id][0] == "static":
|
||||||
keys = ["{}-{}".format(self.id, x) for x in ["time-start", "time-end", "profile"]]
|
keys = ["{}-{}".format(self.id, x) for x in ["time-start", "time-end", "profile"]]
|
||||||
keys_present = reduce(and_, [key in data for key in keys], True)
|
lists = [data[key] for key in keys if key in data]
|
||||||
if not keys_present:
|
|
||||||
return {}
|
|
||||||
lists = [data[key] for key in keys]
|
|
||||||
settings_dict = {
|
settings_dict = {
|
||||||
"{}{}-{}{}".format(start[0:2], start[3:5], end[0:2], end[3:5]): profile
|
"{}{}-{}{}".format(start[0:2], start[3:5], end[0:2], end[3:5]): profile
|
||||||
for start, end, profile in zip(*lists)
|
for start, end, profile in zip(*lists)
|
||||||
}
|
}
|
||||||
|
# only apply scheduler if any slots are available
|
||||||
|
if settings_dict:
|
||||||
return {self.id: {"type": "static", "schedule": settings_dict}}
|
return {self.id: {"type": "static", "schedule": settings_dict}}
|
||||||
elif data[select_id][0] == "daylight":
|
elif data[select_id][0] == "daylight":
|
||||||
settings_dict = {s: getStageValue(s) for s in ["day", "night", "greyline"]}
|
settings_dict = {s: getStageValue(s) for s in ["day", "night", "greyline"]}
|
||||||
# filter out empty ones
|
# filter out empty ones
|
||||||
settings_dict = {s: v for s, v in settings_dict.items() if v}
|
settings_dict = {s: v for s, v in settings_dict.items() if v}
|
||||||
|
# only apply scheduler if any of the slots are in use
|
||||||
|
if settings_dict:
|
||||||
return {self.id: {"type": "daylight", "schedule": settings_dict}}
|
return {self.id: {"type": "daylight", "schedule": settings_dict}}
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
Loading…
Reference in New Issue
Block a user