From 5f583e95bc9919833b87d853fed7f182868db0f9 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 29 Aug 2023 21:00:54 +0800 Subject: [PATCH] added save worldclock and clock2 settings --- server.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index 359ba3c..3d56220 100755 --- a/server.py +++ b/server.py @@ -147,7 +147,7 @@ def index(): 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', 'Commodities', 'Indices', 'Movies', - 'IPO Calendar', 'Economic Calendar', 'Jokes', 'Gainers, Losers, Active', 'Sector Performance', 'Place (Reddit)', 'Clock 1'] + 'IPO Calendar', 'Economic Calendar', 'Jokes', 'Gainers, Losers, Active', 'Sector Performance', 'Place (Reddit)', 'Clock 1' , 'Clock 2', 'World Clock'] global professional @@ -740,11 +740,11 @@ def save_displaying(input_settings): global professional all_settings = ['Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)', - 'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages', 'Movies', 'IPO Calendar', 'Economic Calendar', 'Jokes', 'Gainers, Losers, Active', 'Sector Performance', 'Place (Reddit)', 'Clock 1'] + 'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages', 'Movies', 'IPO Calendar', 'Economic Calendar', 'Jokes', 'Gainers, Losers, Active', 'Sector Performance', 'Place (Reddit)', 'Clock 1', 'Clock 2', 'World Clock'] professional = len(input_settings) == 2 if professional: all_settings = ['Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Current Weather', 'News', 'Daily Forecast', 'Sports (Upcoming Games)', - 'Sports (Past Games)', 'Sports (Team Stats)', 'Sports (Live Games)', 'Custom Messages', 'Custom Images', 'Movies', 'IPO Calendar', 'Economic Calendar', 'Jokes', 'Gainers, Losers, Active', 'Sector Performance', 'Place (Reddit)', 'Clock 1'] + 'Sports (Past Games)', 'Sports (Team Stats)', 'Sports (Live Games)', 'Custom Messages', 'Custom Images', 'Movies', 'IPO Calendar', 'Economic Calendar', 'Jokes', 'Gainers, Losers, Active', 'Sector Performance', 'Place (Reddit)', 'Clock 1', 'Clock 2', 'World Clock'] positions = [] display_settings = [] @@ -908,6 +908,10 @@ def save(): save_place_settings(input_settings) elif feature == 'Clock 1': save_clock1_settings(input_settings) + elif feature == 'Clock 2': + save_clock2_settings(input_settings) + elif feature == 'World Clock': + save_worldclock_settings(input_settings) elif feature in ['Custom GIFs', 'Custom Images']: images = request.files @@ -1708,6 +1712,47 @@ def save_clock1_settings(input_settings): with open('csv/clock1_settings.json', 'w') as f: json.dump(current_settings, f) +def save_clock2_settings(input_settings): + filename = 'clock2_settings.json' + try: + f = open('csv/' + filename, 'r') + current_settings = json.load(f) + f.close() + except: + current_settings = {"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"} + + current_settings['speed'] = input_settings['speed'].lower() + current_settings['speed2'] = input_settings['speed2'].lower() + current_settings['transition'] = input_settings['animation'].lower() + current_settings['pause'] = input_settings['pause'] + try: + f = open('csv/' + filename, 'w') + json.dump(current_settings, f) + f.close() + except: + with open('csv/clock2_settings.json', 'w') as f: + json.dump(current_settings, f) + +def save_worldclock_settings(input_settings): + filename = 'worldclock_settings.json' + try: + f = open('csv/' + filename, 'r') + current_settings = json.load(f) + f.close() + except: + current_settings = {"speed": "fast", "speed2": "fast", "transition": "up", "pause": "20"} + + current_settings['speed'] = input_settings['speed'].lower() + current_settings['speed2'] = input_settings['speed2'].lower() + current_settings['transition'] = input_settings['animation'].lower() + current_settings['pause'] = input_settings['pause'] + try: + f = open('csv/' + filename, 'w') + json.dump(current_settings, f) + f.close() + except: + with open('csv/worldclock_settings.json', 'w') as f: + json.dump(current_settings, f) def save_place_settings(input_settings): filename = 'place_settings.json'