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)
|
general_settings = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
f = open('csv/economic_settings.json', 'r')
|
try:
|
||||||
economic_settings = json.load(f)
|
f = open('csv/economic_settings.json', 'r')
|
||||||
f.close()
|
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:
|
try:
|
||||||
f = open('csv/scheduler.json','r')
|
f = open('csv/scheduler.json','r')
|
||||||
@ -1236,10 +1239,13 @@ def save_ipo_settings(input_settings):
|
|||||||
|
|
||||||
|
|
||||||
def save_economic_settings(input_settings):
|
def save_economic_settings(input_settings):
|
||||||
filename = 'economic_settings.json'
|
filename = 'economic_settings.json'
|
||||||
f = open('csv/' + filename, 'r')
|
try:
|
||||||
current_settings = json.load(f)
|
f = open('csv/' + filename, 'r')
|
||||||
f.close()
|
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['speed'] = input_settings['speed'].lower()
|
||||||
current_settings['speed2'] = input_settings['speed2'].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['countries'] = input_settings['countries']
|
||||||
current_settings['importance'] = input_settings['importance']
|
current_settings['importance'] = input_settings['importance']
|
||||||
|
|
||||||
f = open('csv/' + filename, 'w')
|
try:
|
||||||
json.dump(current_settings, f)
|
f = open('csv/' + filename, 'w')
|
||||||
f.close()
|
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')
|
f = open('csv/last_updates.json', 'r')
|
||||||
last_updates = json.load(f)
|
last_updates = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user