From 20543b373b990eb66b2512f0f5b2fb989d9bcf55 Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 8 Mar 2023 15:04:23 +0800 Subject: [PATCH] ipo calendar --- server.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 1d0ef24..666dbc3 100755 --- a/server.py +++ b/server.py @@ -152,7 +152,13 @@ def index(): movie_api = f.readlines() except: movie_api = '' - + + try: + with open('ipo_api_key.txt', 'r') as f: + ipo_api = f.readlines() + except: + ipo_api = '' + with open('/etc/wpa_supplicant/wpa_supplicant.conf', 'r') as f: wifiline = f.readlines() @@ -180,6 +186,10 @@ def index(): f= open('csv/movie_settings.json', 'r') movie_settings = json.load(f) f.close() + + f= open('csv/ipo_settings.json', 'r') + ipo_settings = json.load(f) + f.close() f = open('csv/forex_settings.json', 'r') forex_settings = json.load(f) @@ -240,7 +250,12 @@ def index(): movie_api_key = movie_api[0] except: movie_api_key = '' - + + try: + ipo_api_key = ipo_api[0] + except: + ipo_api_key = '' + try: wifi_SSID = wifiline[5][6:].replace('"','') except: @@ -266,6 +281,7 @@ def index(): 'current_weather': current_weather, 'daily_weather': daily_weather, 'movie_settings': movie_settings, + 'ipo_settings': ipo_settings, 'news_settings': news_settings, 'upcoming_games': upcoming_games, 'past_games': past_games, @@ -278,6 +294,7 @@ def index(): 'general_settings':general_settings, 'api_keys':api_keys, 'movie_api_key':movie_api_key, + 'ipo_api_key':ipo_api_key, 'wifi_SSID':wifi_SSID, 'wifi_PSK':wifi_PSK } @@ -438,6 +455,8 @@ def save(): save_news_settings(input_settings) elif feature == 'Movies': save_movie_settings(input_settings) + elif feature == 'IPO Calendar': + save_ipo_settings(input_settings) elif 'Sports' in feature: save_sports_settings(input_settings) @@ -661,6 +680,18 @@ def saveMovieAPIKey(): return index() +@app.route("/saveIpoAPIKey", methods = ['PUT', 'POST']) +def saveIpoAPIKey(): + + data= request.data.decode('utf-8') + settings = json.loads(data) + + key = settings['api_key'] + + with open('ipo_api_key.txt', 'w') as f: + f.write(str(key)) + + return index() @app.route("/screensaver", methods = ['PUT', 'POST']) def screensaver(): @@ -878,8 +909,34 @@ def save_movie_settings(input_settings): f = open('csv/last_updates.json', 'w') json.dump(last_updates, f) f.close() + + +def save_ipo_settings(input_settings): + filename = 'ipo_settings.json' + f = open('csv/' + filename, 'r') + current_settings = json.load(f) + f.close() + current_settings['speed'] = input_settings['speed'].lower() + current_settings['speed2'] = input_settings['speed2'].lower() + current_settings['animation'] = input_settings['animation'].lower() + current_settings['title'] = input_settings['title'] + + f = open('csv/' + filename, 'w') + json.dump(current_settings, f) + f.close() + #api_caller.sendline('n') + f = open('csv/last_updates.json', 'r') + last_updates = json.load(f) + f.close() + last_updates['ipo']['force'] = True + + f = open('csv/last_updates.json', 'w') + json.dump(last_updates, f) + f.close() + + def save_sports_settings(input_settings): feature = input_settings['feature']