strava upload improvements
This commit is contained in:
@@ -257,11 +257,12 @@ def createstravaworkoutdata(w):
|
||||
with gzip.GzipFile(gzfilename,'wb') as outF:
|
||||
outF.write(s)
|
||||
os.remove(tcxfilename)
|
||||
return gzfilename
|
||||
return gzfilename,""
|
||||
except:
|
||||
message = str(sys.exc_info()[0])
|
||||
tcxfilename = 0
|
||||
|
||||
return tcxfilename
|
||||
return tcxfilename,message
|
||||
|
||||
# Upload the TCX file to Strava and set the workout activity type
|
||||
# to rowing on Strava
|
||||
@@ -282,8 +283,8 @@ def handle_stravaexport(f2,workoutname,stravatoken,description=''):
|
||||
if res:
|
||||
act = client.update_activity(res.id,activity_type='Rowing',description=description,device_name='Rowsandall.com')
|
||||
else:
|
||||
message = 'Strava upload timed out.'
|
||||
return (0,message)
|
||||
message = 'Strava activity update timed out.'
|
||||
return (res.id,message)
|
||||
|
||||
return (res.id,message)
|
||||
|
||||
@@ -299,7 +300,7 @@ def workout_strava_upload(user,w):
|
||||
else:
|
||||
if (checkworkoutuser(user,w)):
|
||||
try:
|
||||
tcxfile = createstravaworkoutdata(w)
|
||||
tcxfile,tcxmesg = createstravaworkoutdata(w)
|
||||
if tcxfile:
|
||||
with open(tcxfile,'rb') as f:
|
||||
res,mes = handle_stravaexport(f,w.name,
|
||||
@@ -326,7 +327,7 @@ def workout_strava_upload(user,w):
|
||||
stravaid = res
|
||||
return message,stravaid
|
||||
else:
|
||||
message = "Strava Upload error"
|
||||
message = "Strava TCX data error "+tcxmesg
|
||||
w.uploadedtostrava = -1
|
||||
stravaid = -1
|
||||
w.save()
|
||||
|
||||
Reference in New Issue
Block a user