From 04ebf0380ab2590b3d023818e6ef670d9f98664f Mon Sep 17 00:00:00 2001 From: oldnapalm <38410858+oldnapalm@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:55:54 -0300 Subject: [PATCH] Move data files --- bot.txt => data/bot.txt | 0 economy_config.txt => data/economy_config.txt | 0 events.txt => data/events.txt | 0 game_info.txt => data/game_info.txt | 0 start_lines.csv => data/start_lines.csv | 0 variants.txt => data/variants.txt | 0 standalone.py | 4 ++-- standalone.spec | 8 +------- zwift_offline.py | 10 +++++----- 9 files changed, 8 insertions(+), 14 deletions(-) rename bot.txt => data/bot.txt (100%) rename economy_config.txt => data/economy_config.txt (100%) rename events.txt => data/events.txt (100%) rename game_info.txt => data/game_info.txt (100%) rename start_lines.csv => data/start_lines.csv (100%) rename variants.txt => data/variants.txt (100%) diff --git a/bot.txt b/data/bot.txt similarity index 100% rename from bot.txt rename to data/bot.txt diff --git a/economy_config.txt b/data/economy_config.txt similarity index 100% rename from economy_config.txt rename to data/economy_config.txt diff --git a/events.txt b/data/events.txt similarity index 100% rename from events.txt rename to data/events.txt diff --git a/game_info.txt b/data/game_info.txt similarity index 100% rename from game_info.txt rename to data/game_info.txt diff --git a/start_lines.csv b/data/start_lines.csv similarity index 100% rename from start_lines.csv rename to data/start_lines.csv diff --git a/variants.txt b/data/variants.txt similarity index 100% rename from variants.txt rename to data/variants.txt diff --git a/standalone.py b/standalone.py index 94c22c0a..b66efbb4 100644 --- a/standalone.py +++ b/standalone.py @@ -458,7 +458,7 @@ def load_ghosts(player_id, state, ghosts): load_ghosts_folder('%s/%s' % (folder, state.route), ghosts) ghosts.start_road = zo.road_id(state) ghosts.start_rt = state.roadTime - with open('%s/start_lines.csv' % SCRIPT_DIR) as fd: + with open('%s/data/start_lines.csv' % SCRIPT_DIR) as fd: sl = [tuple(line) for line in csv.reader(fd)] rt = [t for t in sl if t[0] == str(state.route)] if rt: @@ -524,7 +524,7 @@ def load_bots(): pass bots_file = '%s/bot.txt' % STORAGE_DIR if not os.path.isfile(bots_file): - bots_file = '%s/bot.txt' % SCRIPT_DIR + bots_file = '%s/data/bot.txt' % SCRIPT_DIR with open(bots_file) as f: data = json.load(f) i = 1 diff --git a/standalone.spec b/standalone.spec index f5bc5601..d8e5e95c 100644 --- a/standalone.spec +++ b/standalone.spec @@ -10,13 +10,7 @@ version = ET.parse('cdn/gameassets/Zwift_Updates_Root/Zwift_ver_cur.xml').getroo a = Analysis(['standalone.py'], pathex=['protobuf'], binaries=[], - datas=[('ssl/*', 'ssl'), - ('start_lines.csv', '.'), - ('game_info.txt', '.'), - ('events.txt', '.'), - ('variants.txt', '.'), - ('economy_config.txt', '.'), - ('bot.txt', '.')], + datas=[('ssl/*', 'ssl'), ('data/*', 'data')], hiddenimports=[], hookspath=[], runtime_hooks=[], diff --git a/zwift_offline.py b/zwift_offline.py index 43eb7168..aa1ff2f1 100644 --- a/zwift_offline.py +++ b/zwift_offline.py @@ -1249,14 +1249,14 @@ def api_proto_empty(): @app.route('/api/game_info/version', methods=['GET']) def api_gameinfo_version(): - game_info_file = os.path.join(SCRIPT_DIR, "game_info.txt") + game_info_file = os.path.join(SCRIPT_DIR, "data", "game_info.txt") with open(game_info_file, mode="r", encoding="utf-8-sig") as f: data = json.load(f) return {"version": data['gameInfoHash']} @app.route('/api/game_info', methods=['GET']) def api_gameinfo(): - game_info_file = os.path.join(SCRIPT_DIR, "game_info.txt") + game_info_file = os.path.join(SCRIPT_DIR, "data", "game_info.txt") with open(game_info_file, mode="r", encoding="utf-8-sig") as f: r = make_response(f.read()) r.mimetype = 'application/json' @@ -1285,7 +1285,7 @@ def api_users_login(): profile_dir = os.path.join(STORAGE_DIR, str(current_user.player_id)) config_file = os.path.join(profile_dir, 'economy_config.txt') if not os.path.isfile(config_file): - with open(os.path.join(SCRIPT_DIR, 'economy_config.txt')) as f: + with open(os.path.join(SCRIPT_DIR, 'data', 'economy_config.txt')) as f: economy_config = json.load(f) profile_file = os.path.join(profile_dir, 'profile.bin') if os.path.isfile(profile_file): @@ -1352,7 +1352,7 @@ def api_per_session_info(): return info.SerializeToString(), 200 def get_events(limit=None, sport=None): - with open(os.path.join(SCRIPT_DIR, 'events.txt')) as f: + with open(os.path.join(SCRIPT_DIR, 'data', 'events.txt')) as f: events_list = json.load(f) events = events_pb2.Events() eventStart = int(time.time()) * 1000 + 2 * 60000 @@ -3385,7 +3385,7 @@ def experimentation_v1_variant(): req = variants_pb2.FeatureRequest() req.ParseFromString(request.stream.read()) variants = {} - with open(os.path.join(SCRIPT_DIR, "variants.txt")) as f: + with open(os.path.join(SCRIPT_DIR, "data", "variants.txt")) as f: vs = variants_pb2.FeatureResponse() Parse(f.read(), vs) for v in vs.variants: