bug fix
This commit is contained in:
63
server.py
63
server.py
@@ -36,6 +36,7 @@ CSV_FOLDER = 'csv/new/'
|
||||
ALLOWED_EXTENSIONS = {'csv', 'png'}
|
||||
|
||||
ticker = pexpect.spawn("sudo -E taskset -c 3 python3 stockTicker.py")
|
||||
ticker.sendline('*') # run by default
|
||||
ticker.sendline('A') # run by default
|
||||
|
||||
|
||||
@@ -104,7 +105,7 @@ def index():
|
||||
|
||||
|
||||
|
||||
@app.route("/start", methods = ['PUT', 'POST'])
|
||||
@app.route ("/start", methods = ['PUT', 'POST'])
|
||||
def start():
|
||||
global displaying_screensaver
|
||||
global ticker
|
||||
@@ -149,6 +150,24 @@ def start():
|
||||
ticker.sendline('A')
|
||||
return index()
|
||||
|
||||
@app.route("/stop")
|
||||
def stop():
|
||||
print('stop')
|
||||
global ticker
|
||||
global displaying_screensaver
|
||||
if not displaying_screensaver:
|
||||
ticker.sendline('K')
|
||||
else:
|
||||
screensaver_p.close()
|
||||
|
||||
|
||||
if displaying_screensaver:
|
||||
screensaver_p.close()
|
||||
api_caller = pexpect.spawn("sudo -E python3 api_caller.py")
|
||||
ticker = pexpect.spawn("sudo -E taskset -c 3 python3 stockTicker.py")
|
||||
displaying_screensaver = False
|
||||
return index()
|
||||
|
||||
@app.route("/display_format", methods = ['PUT', 'POST', 'GET'])
|
||||
def display_format():
|
||||
global professional
|
||||
@@ -208,7 +227,32 @@ def upload():
|
||||
|
||||
return index()
|
||||
|
||||
|
||||
@app.route("/brightness", methods=['PUT','POST'])
|
||||
def brightness():
|
||||
global brightness
|
||||
|
||||
data= request.data.decode('utf-8')
|
||||
settings = json.loads(data)
|
||||
print(settings)
|
||||
brightness =settings['brightness']
|
||||
print(str(int(brightness) - 1))
|
||||
ticker.sendline(str(int(brightness) - 1))
|
||||
|
||||
f = open('csv/settings.csv', 'r')
|
||||
CSV = csv.reader(f)
|
||||
next(CSV)
|
||||
for line in CSV:
|
||||
speed, _ = line
|
||||
f.close()
|
||||
|
||||
f = open('csv/settings.csv', 'w+')
|
||||
f.write('speed,brightness\n')
|
||||
f.write(str(speed) + ',' + str(brightness))
|
||||
f.close()
|
||||
|
||||
global LastCommand
|
||||
LastCommand = 'Change Brightness'
|
||||
return index()
|
||||
|
||||
@app.route("/screensaver", methods = ['PUT', 'POST'])
|
||||
def screensaver():
|
||||
@@ -220,6 +264,9 @@ def screensaver():
|
||||
ticker.close()
|
||||
data = str(request.data)
|
||||
|
||||
if displaying_screensaver:
|
||||
screensaver_p.close()
|
||||
|
||||
|
||||
if "Pulsating Colors" in data:
|
||||
screensaver_p = pexpect.spawn("sudo -E python3 ./rpi-rgb-led-matrix/bindings/python/samples/pulsing-colors.py")
|
||||
@@ -368,17 +415,7 @@ def save_message_settings(input_settings):
|
||||
|
||||
json.dump(input_settings, open('csv/message_settings.json', 'w+'))
|
||||
|
||||
@app.route("/stop")
|
||||
def stop():
|
||||
print('stop')
|
||||
ticker.sendline('K')
|
||||
global displaying_screensaver
|
||||
if displaying_screensaver:
|
||||
screensaver.close()
|
||||
api_caller = pexpect.spawn("sudo -E python3 api_caller.py")
|
||||
ticker = pexpect.spawn("sudo -E taskset -c 3 python3 stockTicker.py")
|
||||
displaying_screensaver = False
|
||||
return index()
|
||||
|
||||
|
||||
@app.route("/shutdown")
|
||||
def shutdown():
|
||||
|
Reference in New Issue
Block a user