professional diaply working
This commit is contained in:
91
server.py
91
server.py
@@ -56,34 +56,45 @@ def process_file(path, filename):
|
||||
app = Flask(__name__)
|
||||
@app.route("/", methods=['GET', 'POST'])
|
||||
def index():
|
||||
global command
|
||||
all_features = ['Current Weather','Daily Forecast','News', 'Sports (Upcoming Games)','Sports (Past Games)','Sports (Live Games)',
|
||||
global command
|
||||
all_features = ['Current Weather','Daily Forecast','News', 'Sports (Upcoming Games)','Sports (Past Games)','Sports (Live Games)',
|
||||
'Sports (Team Stats)','Custom Images', 'Custom GIFs', 'Custom Messages', 'Stocks', 'Crypto', 'Forex']
|
||||
|
||||
currently_displaying = json.load(open('csv/display_settings.json', 'r'))
|
||||
not_displaying = [f for f in all_features if f not in currently_displaying]
|
||||
|
||||
now = datetime.datetime.now()
|
||||
timeString = now.strftime("%Y-%m-%d %H:%M")
|
||||
logos_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos')
|
||||
LogoList = os.listdir(logos_path)
|
||||
|
||||
stocks_settings = json.load(open('csv/stocks_settings.json', 'r'))
|
||||
crypto_settings = json.load(open('csv/crypto_settings.json', 'r'))
|
||||
forex_settings = json.load(open('csv/forex_settings.json', 'r'))
|
||||
current_weather= json.load(open('csv/current_weather.json', 'r'))
|
||||
daily_weather = json.load(open('csv/daily_weather.json', 'r'))
|
||||
news_settings = json.load(open('csv/news_settings.json', 'r'))
|
||||
upcoming_games = json.load(open('csv/upcoming_games.json', 'r'))
|
||||
live_games = json.load(open('csv/live_games.json', 'r'))
|
||||
past_games = json.load(open('csv/past_games.json', 'r'))
|
||||
team_stats = json.load(open('csv/league_tables.json', 'r'))
|
||||
image_settings = json.load(open('csv/image_settings.json', 'r'))
|
||||
GIF_settings = json.load(open('csv/GIF_settings.json', 'r'))
|
||||
message_settings = json.load(open('csv/message_settings.json', 'r'))
|
||||
|
||||
|
||||
templateData = {
|
||||
|
||||
global professional
|
||||
|
||||
feature_settings = json.load(open('csv/display_settings.json', 'r'))
|
||||
|
||||
if not professional:
|
||||
currently_displaying = json.load(open('csv/display_settings.json', 'r'))[1]
|
||||
not_displaying = [f for f in all_features if f not in currently_displaying]
|
||||
|
||||
elif professional:
|
||||
currently_displaying = json.load(open('csv/display_settings.json', 'r'))[1]
|
||||
not_displaying = [f for f in all_features if f not in currently_displaying[0] and f not in currently_displaying[1]]
|
||||
|
||||
|
||||
|
||||
now = datetime.datetime.now()
|
||||
timeString = now.strftime("%Y-%m-%d %H:%M")
|
||||
logos_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos')
|
||||
LogoList = os.listdir(logos_path)
|
||||
|
||||
stocks_settings = json.load(open('csv/stocks_settings.json', 'r'))
|
||||
crypto_settings = json.load(open('csv/crypto_settings.json', 'r'))
|
||||
forex_settings = json.load(open('csv/forex_settings.json', 'r'))
|
||||
current_weather= json.load(open('csv/current_weather.json', 'r'))
|
||||
daily_weather = json.load(open('csv/daily_weather.json', 'r'))
|
||||
news_settings = json.load(open('csv/news_settings.json', 'r'))
|
||||
upcoming_games = json.load(open('csv/upcoming_games.json', 'r'))
|
||||
live_games = json.load(open('csv/live_games.json', 'r'))
|
||||
past_games = json.load(open('csv/past_games.json', 'r'))
|
||||
team_stats = json.load(open('csv/league_tables.json', 'r'))
|
||||
image_settings = json.load(open('csv/image_settings.json', 'r'))
|
||||
GIF_settings = json.load(open('csv/GIF_settings.json', 'r'))
|
||||
message_settings = json.load(open('csv/message_settings.json', 'r'))
|
||||
|
||||
|
||||
templateData = {
|
||||
'currently_displaying': currently_displaying,
|
||||
'not_displaying': not_displaying,
|
||||
'stocks_settings': stocks_settings,
|
||||
@@ -98,9 +109,10 @@ def index():
|
||||
'team_stats': team_stats,
|
||||
'image_settings':image_settings,
|
||||
'GIF_settings':GIF_settings,
|
||||
'message_settings':message_settings
|
||||
'message_settings':message_settings,
|
||||
'professional':professional
|
||||
}
|
||||
return render_template('index.html', **templateData)
|
||||
return render_template('index.html', **templateData)
|
||||
|
||||
|
||||
|
||||
@@ -110,6 +122,7 @@ def start():
|
||||
global displaying_screensaver
|
||||
global ticker
|
||||
global api_caller
|
||||
global professional
|
||||
if displaying_screensaver:
|
||||
screensaver_p.close()
|
||||
api_caller = pexpect.spawn("sudo -E python3 api_caller.py")
|
||||
@@ -117,7 +130,7 @@ def start():
|
||||
displaying_screensaver = False
|
||||
|
||||
|
||||
print(professional)
|
||||
|
||||
data = str(request.data)
|
||||
|
||||
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)',
|
||||
@@ -126,21 +139,15 @@ def start():
|
||||
if professional:
|
||||
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'News']
|
||||
|
||||
|
||||
print(professional)
|
||||
positions = []
|
||||
display_settings = []
|
||||
data = str(request.data.decode('utf-8'))
|
||||
|
||||
for setting in all_settings:
|
||||
pos = data.find(setting)
|
||||
if pos != -1:
|
||||
if professional:
|
||||
setting += ' Prof'
|
||||
display_settings.append(setting)
|
||||
positions.append(pos)
|
||||
|
||||
# sort settings by display
|
||||
inds = np.argsort(positions)
|
||||
display_settings = np.array(display_settings)[inds]
|
||||
input_settings = json.loads(data)
|
||||
|
||||
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)
|
||||
|
Reference in New Issue
Block a user