Private
Public Access
1
0

Merge branch 'develop' into feature/stravadevice

This commit is contained in:
Sander Roosendaal
2017-04-23 09:58:11 +02:00
37 changed files with 1235 additions and 457 deletions

View File

@@ -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'