Strava uploads now use gzip
This commit is contained in:
@@ -14,6 +14,7 @@ import time
|
||||
import math
|
||||
from math import sin,cos,atan2,sqrt
|
||||
import os,sys
|
||||
import gzip
|
||||
|
||||
# Django
|
||||
from django.shortcuts import render_to_response
|
||||
@@ -230,6 +231,13 @@ def createstravaworkoutdata(w):
|
||||
row = rowingdata(filename)
|
||||
tcxfilename = filename[:-4]+'.tcx'
|
||||
row.exporttotcx(tcxfilename,notes=w.notes)
|
||||
gzfilename = tcxfilename+'.gz'
|
||||
with file(tcxfilename,'rb') as inF:
|
||||
s = inF.read()
|
||||
with gzip.GzipFile(gzfilename,'wb') as outF:
|
||||
outF.write(s)
|
||||
os.remove(tcxfilename)
|
||||
return gzfilename
|
||||
except:
|
||||
tcxfilename = 0
|
||||
|
||||
@@ -241,7 +249,7 @@ def handle_stravaexport(f2,workoutname,stravatoken,description=''):
|
||||
# w = Workout.objects.get(id=workoutid)
|
||||
client = stravalib.Client(access_token=stravatoken)
|
||||
|
||||
act = client.upload_activity(f2,'tcx',name=workoutname)
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user