Skip to content

Commit

Permalink
Merge branch 'zoffline:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnapalm authored Nov 29, 2024
2 parents c360334 + d564f7c commit e37ad8b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 154 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ To enable support for multiple users perform the steps below:

* Create a file ``enable_bots.txt`` inside the ``storage`` folder to load ghosts as bots, they will keep riding around regardless of the route you are riding.
* Optionally, ``enable_bots.txt`` can contain a multiplier value (be careful, if the resulting number of bots is too high, it may cause performance issues or not work at all).
* Names, nationalities and equipment can be customized by creating a file ``bot.txt`` inside the ``storage`` folder. The scripts ``get_pro_names.py`` and ``get_strava_names.py`` can be used to populate this file.
* Names, nationalities and equipment can be customized by creating a file ``bot.txt`` inside the ``storage`` folder. The script ``get_pro_names.py`` can be used to populate this file.
* If you want some random bots, check [this repository](https://github.com/oldnapalm/zoffline-bots).

#### RoboPacers (formerly known as Pace Partners)
Expand Down
146 changes: 0 additions & 146 deletions scripts/get_strava_names.py

This file was deleted.

20 changes: 13 additions & 7 deletions zwift_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2239,17 +2239,21 @@ def garmin_upload(player_id, activity):
except Exception as exc:
logger.warning("Failed to read %s. Skipping Garmin upload attempt: %s" % (garmin_credentials, repr(exc)))
return
garmin_domain = '%s/garmin_domain.txt' % STORAGE_DIR
if os.path.exists(garmin_domain):
domain = 'garmin.com'
domain_file = '%s/garmin_domain.txt' % STORAGE_DIR
if os.path.exists(domain_file):
try:
with open(garmin_domain) as f:
garth.configure(domain=f.readline().rstrip('\r\n'))
with open(domain_file) as f:
domain = f.readline().rstrip('\r\n')
garth.configure(domain=domain)
except Exception as exc:
logger.warning("Failed to read %s: %s" % (garmin_domain, repr(exc)))
logger.warning("Failed to read %s: %s" % (domain_file, repr(exc)))
tokens_dir = '%s/garth' % profile_dir
try:
garth.resume(tokens_dir)
garth.client.username
if garth.client.oauth2_token.expired:
garth.client.refresh_oauth2()
garth.save(tokens_dir)
except:
try:
garth.login(username, password)
Expand All @@ -2258,7 +2262,9 @@ def garmin_upload(player_id, activity):
logger.warning("Garmin login failed: %s" % repr(exc))
return
try:
garth.client.post("connectapi", "/upload-service/upload", api=True, files={"file": (activity.fit_filename, BytesIO(activity.fit))})
requests.post('https://connectapi.%s/upload-service/upload' % domain,
files={"file": (activity.fit_filename, BytesIO(activity.fit))},
headers={'authorization': str(garth.client.oauth2_token)})
except Exception as exc:
logger.warning("Garmin upload failed. No internet? %s" % repr(exc))

Expand Down

0 comments on commit e37ad8b

Please sign in to comment.