This commit is contained in:
Andreas Völker 2018-12-30 20:48:46 +01:00
parent f200a954b1
commit 352df31f8f

45
main.py
View File

@ -10,7 +10,6 @@ import bottle
from bottle import route, run, request, post
import time
import sys
import signal
import logging
import math
@ -167,6 +166,7 @@ class SerialWriter(threading.Thread):
time.sleep(5)
logging.info("Closing SerialWriter")
def join(self):
with self.cv:
self.cv.notify_all()
super().join()
def setGamma(self, r, g, b):
@ -304,26 +304,6 @@ class AppRunner(threading.Thread):
def setGamma(self, r, g, b):
self.serial.setGamma(r, g, b)
########################################################################
# Startup #
########################################################################
#normalize config
for app in config.Apps:
if "persistent" not in app.keys():
app["persistent"] = False
if "guiname" not in app.keys():
app["guiname"] = app["name"]
#remove non existing apps
for app in config.Apps:
cmd = app["cmd"]
if type(cmd) == str and not os.path.isfile(cmd):
config.Apps.remove(app)
logging.warning("Removed app "+app["name"])
runner = AppRunner()
runner.start()
########################################################################
# Web Api #
########################################################################
@ -408,9 +388,30 @@ def setGamma(r, g, b):
runner.setGamma(r, g, b)
return "ok"
########################################################################
# Startup #
########################################################################
#normalize config
for app in config.Apps:
if "persistent" not in app.keys():
app["persistent"] = False
if "guiname" not in app.keys():
app["guiname"] = app["name"]
#remove non existing apps
for app in config.Apps:
cmd = app["cmd"]
if type(cmd) == str and not os.path.isfile(cmd):
config.Apps.remove(app)
logging.warning("Removed app "+app["name"])
runner = AppRunner()
runner.start()
run(host=config.WebHost, port=config.WebPort)
########################################################################
# Shutdown #
########################################################################
run(host=config.WebHost, port=config.WebPort)
running = False
runner.join()