From b9007f6d5fca274541556a5963014f7189536050 Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 17 Aug 2023 18:21:04 +0800 Subject: [PATCH] try and except create json files if missing --- server.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index b2ef5fa..319b973 100755 --- a/server.py +++ b/server.py @@ -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)