From b08fd37013795e99defbe9606d7d639ef7b7f394 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 25 Sep 2023 22:08:25 +0800 Subject: [PATCH] save globalstocks settings --- server.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/server.py b/server.py index 94925c8..7c56e79 100755 --- a/server.py +++ b/server.py @@ -932,6 +932,8 @@ def save(): save_worldclock_settings(input_settings) elif feature == 'Inspirational Quotes': save_quotes_settings(input_settings) + elif feature == 'Global Stocks': + save_globalstocks_settings(input_settings) elif feature in ['Custom GIFs', 'Custom Images']: images = request.files @@ -1808,6 +1810,44 @@ def save_quotes_settings(input_settings): json.dump(current_settings, f) +def save_globalstocks_settings(input_settings): + filename = 'globalstocks_settings.json' + try: + f = open('csv/' + filename, 'r') + current_settings = json.load(f) + f.close() + except: + current_settings = {"feature": "Global Stocks", "speed": "medium", "speed2": "medium", "animation": "continuous", "percent": True, "point": True, "logos": True, "chart": False, "title": True, "lohivol": True, "display_name": False, "symbols": []} + + current_settings['speed'] = input_settings['speed'].lower() + current_settings['speed2'] = input_settings['speed2'].lower() + current_settings['animation'] = input_settings['animation'].lower() + current_settings['percent'] = input_settings['percent'] + current_settings['point'] = input_settings['point'] + current_settings['logos'] = input_settings['logos'] + current_settings['title'] = input_settings['title'] + current_settings['chart'] = input_settings['chart'] + current_settings['lohivol'] = input_settings['lohivol'] + current_settings['display_name'] = input_settings['display_name'] + current_settings = combine_dict(current_settings, input_settings['symbols'], 'symbols') + try: + f = open('csv/' + filename, 'w') + json.dump(current_settings, f) + f.close() + except: + with open('csv/globalstocks_settings.json', 'w') as f: + json.dump(current_settings, f) + + if any([current_settings['symbols'][k] == [] for k in input_settings['symbols']]): + f = open('csv/last_updates.json', 'r') + last_updates = json.load(f) + f.close() + last_updates['globalstocks']['force'] = True + f = open('csv/last_updates.json', 'w') + json.dump(last_updates, f) + f.close() + + def save_place_settings(input_settings): filename = 'place_settings.json' try: