communication between server and matrix process working
This commit is contained in:
35
server.py
35
server.py
@@ -12,9 +12,10 @@ import os
|
||||
import datetime
|
||||
import threading
|
||||
import csv
|
||||
|
||||
|
||||
stock_ticker = StockTicker()
|
||||
import pexpect
|
||||
from multiprocessing import Process
|
||||
from subprocess import Popen, PIPE
|
||||
#stock_ticker = StockTicker()
|
||||
|
||||
command = 300
|
||||
tickerList = 0
|
||||
@@ -26,6 +27,13 @@ LOGO_FOLDER = 'logos/'
|
||||
CSV_FOLDER = 'csv/new/'
|
||||
ALLOWED_EXTENSIONS = {'csv', 'png'}
|
||||
|
||||
#ticker.stdin.write(b'from server')
|
||||
#print(ticker.stdout.readlines())
|
||||
#(output, errs)
|
||||
child = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||
|
||||
#stock_ticker = StockTicker()
|
||||
|
||||
def allowed_file(filename):
|
||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||
|
||||
@@ -38,7 +46,7 @@ def process_file(path, filename):
|
||||
|
||||
def ShutdownPI():
|
||||
print('SHUTTING DOWN')
|
||||
os.system("sudo shutdown --poweroff")
|
||||
os.system("sudo shutdown now")
|
||||
|
||||
app = Flask(__name__)
|
||||
@app.route("/", methods=['GET', 'POST'])
|
||||
@@ -128,14 +136,27 @@ def matrix():
|
||||
global LastCommand
|
||||
if "Run Display" in request.form:
|
||||
pass
|
||||
print('run display')
|
||||
#stock_ticker.runStockTicker(command, DelayTime, speedTime)
|
||||
stock_ticker.displayMatrix()
|
||||
#stock_ticker.displayMatrix()
|
||||
#os.system("sudo -E python3 test.py")
|
||||
#
|
||||
#child.sendline('sent from server')
|
||||
|
||||
#process = Popen(["sudo", "-E", "python3", "stockTicker.py"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||
child.sendline('R')
|
||||
|
||||
print('back in flask')
|
||||
|
||||
|
||||
LastCommand = 'Run display'
|
||||
elif "Stop Display (at next refresh)" in request.form:
|
||||
pass
|
||||
#ticker.kill()
|
||||
try:
|
||||
stock_ticker.stopStockTicker()
|
||||
#stock_ticker.stopStockTicker()
|
||||
LastCommand = 'Stop display at next checkpoint'
|
||||
child.sendline('K')
|
||||
except:
|
||||
print("none running")
|
||||
elif "Shutdown the pi" in request.form:
|
||||
@@ -148,6 +169,6 @@ def matrix():
|
||||
return hello()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host='0.0.0.0', port=1024, debug=True)
|
||||
app.run(host='0.0.0.0', port=1024, debug=False) # the debuggger causes flickering
|
||||
|
||||
#sudo ./demo -D1 final.ppm -t 50 -m 25 --led-gpio-mapping=adafruit-hat --led-rows=32 --led-cols=256 --led-slowdown-gpio=4
|
||||
|
Reference in New Issue
Block a user