bugfixes
This commit is contained in:
78
server.py
78
server.py
@@ -18,6 +18,7 @@ import json
|
||||
from multiprocessing import Process
|
||||
from subprocess import Popen, PIPE
|
||||
import numpy as np
|
||||
import copy
|
||||
#stock_ticker = StockTicker()
|
||||
#print('API CALLER NOT STARTED')
|
||||
api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 api_caller.py")
|
||||
@@ -118,6 +119,34 @@ def index():
|
||||
return render_template('index.html', **templateData)
|
||||
|
||||
|
||||
|
||||
def save_displaying(input_settings):
|
||||
|
||||
|
||||
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)',
|
||||
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages']
|
||||
|
||||
if professional:
|
||||
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'News']
|
||||
|
||||
|
||||
positions = []
|
||||
display_settings = []
|
||||
|
||||
if professional:
|
||||
input_settings[0] = [i for i in input_settings[0] if i in all_settings]
|
||||
input_settings[1] = [i for i in input_settings[1] if i in all_settings]
|
||||
|
||||
|
||||
|
||||
s = "Professional" if professional else "Standard"
|
||||
display_settings = [s] + [input_settings]
|
||||
|
||||
with open('csv/display_settings.json', 'w+') as f:
|
||||
json.dump(list(display_settings), f)
|
||||
|
||||
|
||||
|
||||
@app.route ("/start", methods = ['PUT', 'POST'])
|
||||
def start():
|
||||
global displaying_screensaver
|
||||
@@ -129,36 +158,6 @@ def start():
|
||||
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||
api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 api_caller.py")
|
||||
displaying_screensaver = False
|
||||
|
||||
|
||||
|
||||
data = str(request.data)
|
||||
|
||||
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)',
|
||||
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages']
|
||||
|
||||
if professional:
|
||||
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'News']
|
||||
|
||||
print(professional)
|
||||
positions = []
|
||||
display_settings = []
|
||||
data = str(request.data.decode('utf-8'))
|
||||
|
||||
input_settings = json.loads(data)
|
||||
print(input_settings)
|
||||
print(all_settings)
|
||||
if professional:
|
||||
input_settings[0] = [i for i in input_settings[0] if i in all_settings]
|
||||
input_settings[1] = [i for i in input_settings[1] if i in all_settings]
|
||||
|
||||
print(input_settings)
|
||||
|
||||
s = "Professional" if professional else "Standard"
|
||||
display_settings = [s] + [input_settings]
|
||||
|
||||
with open('csv/display_settings.json', 'w+') as f:
|
||||
json.dump(list(display_settings), f)
|
||||
|
||||
ticker.sendline('K')
|
||||
|
||||
@@ -202,14 +201,19 @@ def display_format():
|
||||
print(professional)
|
||||
return index()
|
||||
|
||||
@app.route("/feature_settings", methods = ['PUT', 'POST', 'GET'])
|
||||
def feature_settings():
|
||||
@app.route("/save", methods = ['PUT', 'POST', 'GET'])
|
||||
def save():
|
||||
|
||||
data = str(request.data.decode('utf-8'))
|
||||
|
||||
input_settings = json.loads(data)
|
||||
print(input_settings)
|
||||
|
||||
|
||||
save_displaying(input_settings['displaying'])
|
||||
|
||||
input_settings= input_settings['feature_settings']
|
||||
|
||||
feature = input_settings['feature']
|
||||
if feature in ['Stocks', 'Crypto', 'Forex']:
|
||||
save_trade_settings(input_settings)
|
||||
@@ -377,20 +381,24 @@ def screensaver():
|
||||
|
||||
def combine_dict(current_settings, input_symbols, current_key):
|
||||
# removes keys not in input from current_settings[current_key] and adds keys not in current from input
|
||||
new_settings = copy.deepcopy(current_settings)
|
||||
new_settings[current_key] = {}
|
||||
|
||||
current_symbols = list(current_settings[current_key].keys())
|
||||
|
||||
# add any stock that arent current in the settings
|
||||
for IS in input_symbols:
|
||||
if IS not in current_symbols:
|
||||
current_settings[current_key][IS] = []
|
||||
new_settings[current_key][IS] = []
|
||||
else:
|
||||
new_settings[current_key][IS] = current_settings[current_key][IS]
|
||||
|
||||
# remove stocks not in settings
|
||||
for CS in current_symbols:
|
||||
if CS not in input_symbols:
|
||||
del current_settings[current_key][CS]
|
||||
del new_settings[current_key][CS]
|
||||
|
||||
return current_settings
|
||||
return new_settings
|
||||
|
||||
def save_trade_settings(input_settings):
|
||||
|
||||
|
Reference in New Issue
Block a user