in case no screensaver in scheduler_settings

This commit is contained in:
Justin 2023-08-23 22:30:26 +08:00 committed by GitHub
parent afa22d4518
commit fd0f2ec762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1674,6 +1674,28 @@ def saveSchedulerSettings():
try: try:
with open('csv/scheduler.json','r') as f: with open('csv/scheduler.json','r') as f:
scheduler_settings = json.load(f) scheduler_settings = json.load(f)
if 'screensaver' not in str(scheduler_settings):
scheduler_settings['screensaver1'] = {}
scheduler_settings['screensaver1']['hour'] = '00'
scheduler_settings['screensaver1']['minute'] = '00'
scheduler_settings['screensaver1']['endhour'] = '00'
scheduler_settings['screensaver1']['endminute'] = '00'
scheduler_settings['screensaver1']['type'] = 'World Clock'
scheduler_settings['screensaver1']['enabled'] = False
scheduler_settings['screensaver2'] = {}
scheduler_settings['screensaver2']['hour'] = '00'
scheduler_settings['screensaver2']['minute'] = '00'
scheduler_settings['screensaver2']['endhour'] = '00'
scheduler_settings['screensaver2']['endminute'] = '00'
scheduler_settings['screensaver2']['type'] = 'Clock 2'
scheduler_settings['screensaver2']['enabled'] = False
scheduler_settings['screensaver3'] = {}
scheduler_settings['screensaver3']['hour'] = '00'
scheduler_settings['screensaver3']['minute'] = '00'
scheduler_settings['screensaver3']['endhour'] = '00'
scheduler_settings['screensaver3']['endminute'] = '00'
scheduler_settings['screensaver3']['type'] = 'Clock 1'
scheduler_settings['screensaver3']['enabled'] = False
except: except:
scheduler_settings = {"shutdown": {"hour": "00", "minute": "00", "enabled": False}, "reboot":{"hour": "00", "minute": "00", "enabled": False}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "screensaver1":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"World Clock", "enabled": False}, "screensaver2":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 1", "enabled": False}, "screensaver3":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 2", "enabled": False}} scheduler_settings = {"shutdown": {"hour": "00", "minute": "00", "enabled": False}, "reboot":{"hour": "00", "minute": "00", "enabled": False}, "timezone": "GMT", "brightness1":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness2":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness3":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "brightness4":{"hour": "00", "minute": "00", "bright": "10", "enabled": False}, "screensaver1":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"World Clock", "enabled": False}, "screensaver2":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 1", "enabled": False}, "screensaver3":{"hour": "00", "minute": "00", "endhour": "00", "endminute": "00", "type":"Clock 2", "enabled": False}}