try and except create json files if missing

This commit is contained in:
Justin 2023-08-17 18:21:04 +08:00 committed by GitHub
parent f7f8fff458
commit b9007f6d5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 5 deletions

View File

@ -270,7 +270,8 @@ def index():
f.close()
except:
ipo_settings = {"feature": "IPO", "speed": "medium", "speed2": "medium", "animation": "down", "title": True, "symbols": ["No Data"]}
with open('csv/ipo_settings.json', 'w') as f:
json.dump(ipo_settings, f)
try:
f = open('csv/forex_settings.json', 'r')
forex_settings = json.load(f)
@ -358,7 +359,8 @@ def index():
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": []}
with open('csv/economic_settings.json', 'w') as f:
json.dump(economic_settings, f)
try:
f = open('csv/jokes_settings.json', 'r')
jokes_settings = json.load(f)
@ -367,7 +369,8 @@ def index():
jokes_settings['categories'] = ['Any']
except:
jokes_settings = {"feature": "Jokes", "speed": "medium", "speed2": "medium", "animation": "up", "title": True, "safe": True, "categories": ["Any"], "blacklist": [], "amount": "5", "jokes": []}
with open('csv/jokes_settings.json', 'w') as f:
json.dump(jokes_settings, f)
try:
f = open('csv/place_settings.json', 'r')
place_settings = json.load(f)
@ -382,14 +385,16 @@ def index():
f.close()
except:
market_settings = {"feature": "Gainers, Losers, Active", "speed": "medium", "speed2": "medium", "animation": "up", "percent": True, "point": True, "logos": True, "chart": False, "title": True, "lohivol": False, "categories": ["Top Gainers", "Top Losers", "Most Active"], "gainers": {}, "losers": {}, "mostactive": {}}
with open('csv/market_settings.json', 'w') as f:
json.dump(market_settings, f)
try:
f = open('csv/sector_settings.json', 'r')
sector_settings = json.load(f)
f.close()
except:
sector_settings = {"feature": "Sector Performance", "speed": "medium", "speed2": "medium", "animation": "up", "logos": True, "title": True, "sectors": ["Energy", "Financials", "Real Estate", "Technology"], "data": {}}
with open('csv/sector_settings.json', 'w') as f:
json.dump(sector_settings, f)
try:
f = open('csv/scheduler.json','r')
scheduler_settings = json.load(f)