Code to check Strava behaviour
This commit is contained in:
@@ -247,13 +247,20 @@ def createstravaworkoutdata(w):
|
|||||||
def handle_stravaexport(file,workoutname,stravatoken,description=''):
|
def handle_stravaexport(file,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)
|
||||||
|
try:
|
||||||
act = client.upload_activity(file,'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")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# w.uploadedtostrava = res.id
|
# w.uploadedtostrava = res.id
|
||||||
|
|||||||
@@ -934,9 +934,17 @@ def workout_strava_upload_view(request,id=0):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(tcxfile,'rb') as f:
|
with open(tcxfile,'rb') as f:
|
||||||
res = stravastuff.handle_stravaexport(f,w.name,
|
try:
|
||||||
r.stravatoken,
|
res = stravastuff.handle_stravaexport(f,w.name,
|
||||||
description=w.notes)
|
r.stravatoken,
|
||||||
|
description=w.notes)
|
||||||
|
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("views.py line 946\r\n")
|
||||||
|
|
||||||
|
|
||||||
w.uploadedtostrava = res
|
w.uploadedtostrava = res
|
||||||
w.save()
|
w.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user