Strava uploads now use gzip
This commit is contained in:
@@ -14,6 +14,7 @@ import time
|
|||||||
import math
|
import math
|
||||||
from math import sin,cos,atan2,sqrt
|
from math import sin,cos,atan2,sqrt
|
||||||
import os,sys
|
import os,sys
|
||||||
|
import gzip
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
@@ -230,6 +231,13 @@ def createstravaworkoutdata(w):
|
|||||||
row = rowingdata(filename)
|
row = rowingdata(filename)
|
||||||
tcxfilename = filename[:-4]+'.tcx'
|
tcxfilename = filename[:-4]+'.tcx'
|
||||||
row.exporttotcx(tcxfilename,notes=w.notes)
|
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:
|
except:
|
||||||
tcxfilename = 0
|
tcxfilename = 0
|
||||||
|
|
||||||
@@ -241,7 +249,7 @@ def handle_stravaexport(f2,workoutname,stravatoken,description=''):
|
|||||||
# w = Workout.objects.get(id=workoutid)
|
# w = Workout.objects.get(id=workoutid)
|
||||||
client = stravalib.Client(access_token=stravatoken)
|
client = stravalib.Client(access_token=stravatoken)
|
||||||
|
|
||||||
act = client.upload_activity(f2,'tcx',name=workoutname)
|
act = client.upload_activity(f2,'tcx.gz',name=workoutname)
|
||||||
try:
|
try:
|
||||||
res = act.wait(poll_interval=5.0,timeout=30)
|
res = act.wait(poll_interval=5.0,timeout=30)
|
||||||
message = 'Workout successfully synchronized to Strava'
|
message = 'Workout successfully synchronized to Strava'
|
||||||
|
|||||||
Reference in New Issue
Block a user