Private
Public Access
1
0

faster strava sync

This commit is contained in:
Sander Roosendaal
2020-03-01 17:36:06 +01:00
parent 08f644c3fc
commit e559710756
5 changed files with 13 additions and 14 deletions

View File

@@ -439,15 +439,19 @@ def createstravaworkoutdata(w,dozip=True):
# Upload the TCX file to Strava and set the workout activity type
# to rowing on Strava
def handle_stravaexport(f2,workoutname,stravatoken,description='',
activity_type='Rowing'):
activity_type='Rowing',async=False):
# w = Workout.objects.get(id=workoutid)
client = stravalib.Client(access_token=stravatoken)
act = client.upload_activity(f2,'tcx.gz',name=workoutname)
try:
res = act.wait(poll_interval=5.0,timeout=30)
message = 'Workout successfully synchronized to Strava'
if async:
res = act.wait(poll_interval=1.0, timeout=10)
message = 'Workout successfully synchronized to Strava'
else:
res = act.wait(poll_interval=5.0,timeout=30)
message = 'Workout successfully synchronized to Strava'
except:
res = 0
message = 'Strava upload timed out'
@@ -621,7 +625,7 @@ def add_workout_from_data(user,importid,data,strokedata,
return id,message
def workout_strava_upload(user,w):
def workout_strava_upload(user,w, async=False):
try:
thetoken = strava_open(user)
except NoTokenError:
@@ -644,7 +648,7 @@ def workout_strava_upload(user,w):
f,w.name,
r.stravatoken,
description=w.notes+'\n from '+w.workoutsource+' via rowsandall.com',
activity_type=r.stravaexportas)
activity_type=r.stravaexportas,async=async)
if res==0:
message = mes
w.uploadedtostrava = -1