Merge branch 'hotfix/stravaerror2'
This commit is contained in:
@@ -13,6 +13,7 @@ from dateutil import parser
|
|||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
from math import sin,cos,atan2,sqrt
|
from math import sin,cos,atan2,sqrt
|
||||||
|
import os,sys
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
@@ -227,31 +228,16 @@ def createstravaworkoutdata(w):
|
|||||||
|
|
||||||
# Upload the TCX file to Strava and set the workout activity type
|
# Upload the TCX file to Strava and set the workout activity type
|
||||||
# to rowing on Strava
|
# to rowing on Strava
|
||||||
def handle_stravaexport(file,workoutname,stravatoken,description=''):
|
def handle_stravaexport(f2,workoutname,stravatoken,description=''):
|
||||||
# w = Workout.objects.get(id=workoutid)
|
# w = Workout.objects.get(id=workoutid)
|
||||||
try:
|
client = stravalib.Client(access_token=stravatoken)
|
||||||
client = stravalib.Client(access_token=stravatoken)
|
|
||||||
except:
|
|
||||||
with open("media/stravaerrors.log","a") as errorlog:
|
|
||||||
errorstring = str(sys.exc_info()[0])
|
|
||||||
timestr = time.strftime("%Y%m%d-%H%M%S")
|
|
||||||
errorlog.write(timestr+errorstring+"\r\n")
|
|
||||||
errorlog.write("stravastuff.py line 236\r\n")
|
|
||||||
return 0
|
|
||||||
|
|
||||||
try:
|
act = client.upload_activity(f2,'tcx',name=workoutname)
|
||||||
act = client.upload_activity(file,'tcx',name=workoutname)
|
res = act.wait(poll_interval=5.0)
|
||||||
res = act.wait(poll_interval=5.0)
|
|
||||||
|
|
||||||
|
|
||||||
# description doesn't work yet. Have to wait for stravalib to update
|
# description doesn't work yet. Have to wait for stravalib to update
|
||||||
act = client.update_activity(res.id,activity_type='Rowing',description=description)
|
act = client.update_activity(res.id,activity_type='Rowing',description=description)
|
||||||
except:
|
|
||||||
with open("media/stravaerrors.log","a") as errorlog:
|
|
||||||
errorstring = str(sys.exc_info()[0])
|
|
||||||
timestr = time.strftime("%Y%m%d-%H%M%S")
|
|
||||||
errorlog.write(timestr+errorstring+"\r\n")
|
|
||||||
errorlog.write("stravastuff.py line 262\r\n")
|
|
||||||
|
|
||||||
return res.id
|
return res.id
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user