fail safe economic settings
This commit is contained in:
parent
5a0938a528
commit
528fc81c01
31
server.py
31
server.py
@ -266,9 +266,12 @@ def index():
|
||||
general_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
f = open('csv/economic_settings.json', 'r')
|
||||
economic_settings = json.load(f)
|
||||
f.close()
|
||||
try:
|
||||
f = open('csv/economic_settings.json', 'r')
|
||||
economic_settings = json.load(f)
|
||||
f.close()
|
||||
except:
|
||||
economic_settings = {"feature": "Economic Calendar", "speed": "medium", "speed2": "medium", "animation": "up", "importance": "Med - High", "title": True, "timezone": "US/Eastern", "countries": ["United States"], "events": []}
|
||||
|
||||
try:
|
||||
f = open('csv/scheduler.json','r')
|
||||
@ -1236,10 +1239,13 @@ def save_ipo_settings(input_settings):
|
||||
|
||||
|
||||
def save_economic_settings(input_settings):
|
||||
filename = 'economic_settings.json'
|
||||
f = open('csv/' + filename, 'r')
|
||||
current_settings = json.load(f)
|
||||
f.close()
|
||||
filename = 'economic_settings.json'
|
||||
try:
|
||||
f = open('csv/' + filename, 'r')
|
||||
current_settings = json.load(f)
|
||||
f.close()
|
||||
except:
|
||||
current_settings = {"feature": "Economic Calendar", "speed": "medium", "speed2": "medium", "animation": "up", "importance": "Med - High", "title": True, "timezone": "US/Eastern", "countries": ["United States"], "events": []}
|
||||
|
||||
current_settings['speed'] = input_settings['speed'].lower()
|
||||
current_settings['speed2'] = input_settings['speed2'].lower()
|
||||
@ -1249,9 +1255,14 @@ def save_economic_settings(input_settings):
|
||||
current_settings['countries'] = input_settings['countries']
|
||||
current_settings['importance'] = input_settings['importance']
|
||||
|
||||
f = open('csv/' + filename, 'w')
|
||||
json.dump(current_settings, f)
|
||||
f.close()
|
||||
try:
|
||||
f = open('csv/' + filename, 'w')
|
||||
json.dump(current_settings, f)
|
||||
f.close()
|
||||
except:
|
||||
with open('csv/economic_settings.json', 'w') as f:
|
||||
json.dump(all_economic_settings, f)
|
||||
|
||||
f = open('csv/last_updates.json', 'r')
|
||||
last_updates = json.load(f)
|
||||
f.close()
|
||||
|
Loading…
Reference in New Issue
Block a user