Skip to content

Commit

Permalink
Move data files
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnapalm committed Feb 15, 2024
1 parent 5dd7cbf commit 04ebf03
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 14 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions standalone.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
Expand Down
10 changes: 5 additions & 5 deletions zwift_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 04ebf03

Please sign in to comment.