added save worldclock and clock2 settings

This commit is contained in:
Justin 2023-08-29 21:00:54 +08:00 committed by GitHub
parent d29f793e6d
commit 5f583e95bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -147,7 +147,7 @@ def index():
global command global command
all_features = ['Current Weather','Daily Forecast','News', 'Sports (Upcoming Games)','Sports (Past Games)','Sports (Live Games)', 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', '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 global professional
@ -740,11 +740,11 @@ def save_displaying(input_settings):
global professional global professional
all_settings = ['Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)', 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 professional = len(input_settings) == 2
if professional: if professional:
all_settings = ['Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Current Weather', 'News', 'Daily Forecast', 'Sports (Upcoming Games)', 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 = [] positions = []
display_settings = [] display_settings = []
@ -908,6 +908,10 @@ def save():
save_place_settings(input_settings) save_place_settings(input_settings)
elif feature == 'Clock 1': elif feature == 'Clock 1':
save_clock1_settings(input_settings) 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']: elif feature in ['Custom GIFs', 'Custom Images']:
images = request.files images = request.files
@ -1708,6 +1712,47 @@ def save_clock1_settings(input_settings):
with open('csv/clock1_settings.json', 'w') as f: with open('csv/clock1_settings.json', 'w') as f:
json.dump(current_settings, 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): def save_place_settings(input_settings):
filename = 'place_settings.json' filename = 'place_settings.json'