mirror of
https://github.com/zoffline/zwift-offline.git
synced 2026-03-12 21:23:00 -07:00
Move data files
This commit is contained in:
@@ -46,5 +46,5 @@ for directory in os.listdir(worlds):
|
||||
data.append(event)
|
||||
event_id += 1000
|
||||
|
||||
with open('../events.txt', 'w') as f:
|
||||
with open('../data/events.txt', 'w') as f:
|
||||
json.dump(sorted(data, key=lambda row: row['name']), f, indent=2)
|
||||
|
||||
@@ -115,7 +115,7 @@ def main(argv):
|
||||
session = requests.session()
|
||||
access_token, refresh_token, expired_in = post_credentials(session, username, password)
|
||||
game_info = get_game_info(session, access_token).decode('utf-8')
|
||||
with open('../game_info.txt', 'wb') as f:
|
||||
with open('../data/game_info.txt', 'wb') as f:
|
||||
f.write(game_info.encode('utf-8-sig'))
|
||||
|
||||
logout(session, refresh_token)
|
||||
|
||||
@@ -8,5 +8,5 @@ with open("login", "rb") as f:
|
||||
login = login_pb2.LoginResponse()
|
||||
login.ParseFromString(f.read())
|
||||
|
||||
with open('../economy_config.txt', 'w') as f:
|
||||
with open('../data/economy_config.txt', 'w') as f:
|
||||
json.dump(MessageToDict(login, preserving_proto_field_name=True)['economy_config'], f)
|
||||
|
||||
@@ -10,7 +10,7 @@ with open("variant", "rb") as f:
|
||||
|
||||
keep = ['zwift_launcher_']
|
||||
|
||||
with open("../variants.txt") as f:
|
||||
with open("../data/variants.txt") as f:
|
||||
vs = [d for d in json.load(f)['variants'] if any(d['name'].startswith(s) for s in keep)]
|
||||
|
||||
for v in MessageToDict(variants)['variants']:
|
||||
@@ -18,5 +18,5 @@ for v in MessageToDict(variants)['variants']:
|
||||
v['values']['fields'] = dict(sorted(v['values']['fields'].items()))
|
||||
vs.append(v)
|
||||
|
||||
with open("../variants.txt", "w") as f:
|
||||
with open("../data/variants.txt", "w") as f:
|
||||
json.dump({'variants': sorted(vs, key=lambda x: x['name'])}, f, indent=2)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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=[],
|
||||
@@ -25,9 +19,6 @@ a = Analysis(['standalone.py'],
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
a.binaries = [x for x in a.binaries
|
||||
if not os.path.dirname(x[1]).lower().startswith("c:\\program files")
|
||||
and not os.path.dirname(x[1]).lower().startswith("c:\\windows")]
|
||||
a.datas += Tree('cdn', prefix='cdn')
|
||||
pyz = PYZ(a.pure, a.zipped_data,
|
||||
cipher=block_cipher)
|
||||
@@ -42,7 +33,7 @@ exe = EXE(pyz,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=['greenlet\*.pyd'],
|
||||
upx_exclude=['greenlet\\*.pyd', '_uuid.pyd', 'python3.dll', 'api-ms-win-*.dll'],
|
||||
runtime_tmpdir=None,
|
||||
console=True )
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user