Skip to content

Commit

Permalink
remove fake device
Browse files Browse the repository at this point in the history
  • Loading branch information
NaturezzZ authored and Kugin committed Sep 13, 2024
1 parent 0eec8bd commit aa71336
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
21 changes: 6 additions & 15 deletions run_page/garmin_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,11 @@ async def upload_activities_original_from_strava(
print("garmin upload failed: ", e)
await self.req.aclose()

async def upload_activity_from_file(self, file, use_fake_garmin_device=False):
async def upload_activity_from_file(self, file):
print("Uploading " + str(file))
f = open(file, "rb")
# wrap fake garmin device to origin fit file, current not support gpx file
if use_fake_garmin_device:
file_body = wrap_device_info(f)
else:
file_body = BytesIO(f.read())

file_body = BytesIO(f.read())
files = {"file": (file, file_body)}

try:
Expand All @@ -179,18 +176,12 @@ async def upload_activity_from_file(self, file, use_fake_garmin_device=False):
except Exception as e:
print("garmin upload failed: ", e)

async def upload_activities_files(self, files, use_fake_garmin_device=False):
print(
"start upload activities to garmin!, use_fake_garmin_device:",
use_fake_garmin_device,
)
async def upload_activities_files(self, files):
print("start upload activities to garmin!")

await gather_with_concurrency(
10,
[
self.upload_activity_from_file(file=f, use_fake_garmin_device=False)
for f in files
],
[self.upload_activity_from_file(file=f) for f in files],
)

await self.req.aclose()
Expand Down
2 changes: 1 addition & 1 deletion run_page/garmin_sync_cn_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
)
loop = asyncio.get_event_loop()
future = asyncio.ensure_future(
garmin_global_client.upload_activities_files(to_upload_files, False)
garmin_global_client.upload_activities_files(to_upload_files)
)
loop.run_until_complete(future)

Expand Down

0 comments on commit aa71336

Please sign in to comment.