Fixes
This commit is contained in:
		
							
								
								
									
										47
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								main.py
									
									
									
									
									
								
							@@ -10,7 +10,6 @@ import bottle
 | 
			
		||||
from bottle import route, run, request, post
 | 
			
		||||
import time
 | 
			
		||||
import sys
 | 
			
		||||
import signal
 | 
			
		||||
import logging
 | 
			
		||||
import math
 | 
			
		||||
 | 
			
		||||
@@ -167,7 +166,8 @@ class SerialWriter(threading.Thread):
 | 
			
		||||
                time.sleep(5)
 | 
			
		||||
        logging.info("Closing SerialWriter")
 | 
			
		||||
    def join(self):
 | 
			
		||||
        self.cv.notify_all()
 | 
			
		||||
        with self.cv:
 | 
			
		||||
            self.cv.notify_all()
 | 
			
		||||
        super().join()
 | 
			
		||||
    def setGamma(self, r, g, b):
 | 
			
		||||
        with self.cv:
 | 
			
		||||
@@ -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()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user