scheduler for screensaver added
This commit is contained in:
parent
79015ec7d1
commit
9e34a4edcc
123
server.py
123
server.py
@ -591,6 +591,122 @@ scheduled_b = Process(target=scheduled_brightness)
|
||||
scheduled_b.start()
|
||||
|
||||
|
||||
def scheduled_screensaver():
|
||||
|
||||
already_running_screensaver_1 = False
|
||||
already_running_screensaver_2 = False
|
||||
already_running_screensaver_3 = False
|
||||
try:
|
||||
while True:
|
||||
try:
|
||||
f = open('csv/scheduler.json','r')
|
||||
schedules = json.load(f)
|
||||
f.close()
|
||||
except:
|
||||
schedules = {"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}}
|
||||
|
||||
timezone_screensaver = schedules['timezone']
|
||||
|
||||
try:
|
||||
screensaver1_hour = schedules['screensaver1']['hour']
|
||||
screensaver1_minute = schedules['screensaver1']['minute']
|
||||
screensaver1_enabled = schedules['screensaver1']['enabled']
|
||||
screensaver1_type = [schedules['screensaver1']['type']]
|
||||
screensaver1_endhour = schedules['screensaver1']['endhour']
|
||||
screensaver1_endminute = schedules['screensaver1']['endminute']
|
||||
except:
|
||||
screensaver1_hour = '00'
|
||||
screensaver1_minute = '00'
|
||||
screensaver1_enabled = False
|
||||
screensaver1_type = ['World Clock']
|
||||
screensaver1_endhour = '00'
|
||||
screensaver1_endminute = '00'
|
||||
|
||||
try:
|
||||
screensaver2_hour = schedules['screensaver2']['hour']
|
||||
screensaver2_minute = schedules['screensaver2']['minute']
|
||||
screensaver2_enabled = schedules['screensaver2']['enabled']
|
||||
screensaver2_type = [schedules['screensaver2']['type']]
|
||||
screensaver2_endhour = schedules['screensaver2']['endhour']
|
||||
screensaver2_endminute = schedules['screensaver2']['endminute']
|
||||
except:
|
||||
screensaver2_hour = '00'
|
||||
screensaver2_minute = '00'
|
||||
screensaver2_enabled = False
|
||||
screensaver2_type = ['Clock 1']
|
||||
screensaver2_endhour = '00'
|
||||
screensaver2_endminute = '00'
|
||||
|
||||
try:
|
||||
screensaver3_hour = schedules['screensaver3']['hour']
|
||||
screensaver3_minute = schedules['screensaver3']['minute']
|
||||
screensaver3_enabled = schedules['screensaver3']['enabled']
|
||||
screensaver3_type = [schedules['screensaver3']['type']]
|
||||
screensaver3_endhour = schedules['screensaver3']['endhour']
|
||||
screensaver3_endminute = schedules['screensaver3']['endminute']
|
||||
except:
|
||||
screensaver3_hour = '00'
|
||||
screensaver3_minute = '00'
|
||||
screensaver3_enabled = False
|
||||
screensaver3_type = ['Clock 2']
|
||||
screensaver3_endhour = '00'
|
||||
screensaver3_endminute = '00'
|
||||
|
||||
time_now = datetime.datetime.now(pytz.timezone(timezone_screensaver)).strftime("%H:%M")
|
||||
|
||||
try:
|
||||
if screensaver1_enabled and time_now == screensaver1_hour+':'+screensaver1_minute and not already_running_screensaver_1:
|
||||
requests.post('http://fintic.local:1024/screensaver', json=screensaver1_type)
|
||||
already_running_screensaver_1 = True
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if screensaver1_enabled and time_now == screensaver1_endhour+':'+screensaver1_endminute and already_running_screensaver_1:
|
||||
already_running_screensaver_1 = False
|
||||
if ((time_now == screensaver2_hour+':'+screensaver2_minute and screensaver2_enabled) or (time_now == screensaver3_hour+':'+screensaver3_minute and screensaver3_enabled)):
|
||||
pass
|
||||
else:
|
||||
requests.put('http://fintic.local:1024/start')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if screensaver2_enabled and time_now == screensaver2_hour+':'+screensaver2_minute and not already_running_screensaver_2:
|
||||
requests.post('http://fintic.local:1024/screensaver', json=screensaver2_type)
|
||||
already_running_screensaver_2 = True
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if screensaver2_enabled and time_now == screensaver2_endhour+':'+screensaver2_endminute and already_running_screensaver_2:
|
||||
already_running_screensaver_2 = False
|
||||
if (time_now == screensaver1_hour+':'+screensaver1_minute and screensaver1_enabled) or (time_now == screensaver3_hour+':'+screensaver3_minute and screensaver3_enabled):
|
||||
pass
|
||||
else:
|
||||
requests.put('http://fintic.local:1024/start')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if screensaver3_enabled and time_now == screensaver3_hour+':'+screensaver3_minute and not already_running_screensaver_3:
|
||||
requests.post('http://fintic.local:1024/screensaver', json=screensaver3_type)
|
||||
already_running_screensaver_3 = True
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if screensaver3_enabled and time_now == screensaver3_endhour+':'+screensaver3_endminute and already_running_screensaver_3:
|
||||
already_running_screensaver_3 = False
|
||||
if (time_now == screensaver1_hour+':'+screensaver1_minute and screensaver1_enabled) or (time_now == screensaver2_hour+':'+screensaver2_minute and screensaver2_enabled):
|
||||
pass
|
||||
else:
|
||||
requests.put('http://fintic.local:1024/start')
|
||||
except:
|
||||
pass
|
||||
|
||||
time.sleep(20)
|
||||
except:
|
||||
pass
|
||||
|
||||
scheduled_s = Process(target=scheduled_screensaver)
|
||||
scheduled_s.start()
|
||||
|
||||
|
||||
def save_displaying(input_settings):
|
||||
|
||||
@ -644,6 +760,12 @@ def start():
|
||||
scheduled_b = Process(target=scheduled_brightness)
|
||||
scheduled_b.start()
|
||||
|
||||
global scheduled_s
|
||||
if scheduled_s.is_alive():
|
||||
scheduled_s.terminate()
|
||||
scheduled_s = Process(target=scheduled_screensaver)
|
||||
scheduled_s.start()
|
||||
|
||||
ticker.sendline('K')
|
||||
|
||||
ticker.sendline('A')
|
||||
@ -683,6 +805,7 @@ def stop():
|
||||
|
||||
|
||||
scheduled_b.terminate()
|
||||
scheduled_s.terminate()
|
||||
|
||||
return index()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user