From 6b20e1c936588edbfe30e8a32d7c3aa8f66b9fca Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 27 Dec 2016 08:50:57 +0100 Subject: [PATCH 1/2] Code to check Strava behaviour --- rowers/stravastuff.py | 17 ++++++++++++----- rowers/views.py | 14 +++++++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/rowers/stravastuff.py b/rowers/stravastuff.py index 954f4dee..bc3c354f 100644 --- a/rowers/stravastuff.py +++ b/rowers/stravastuff.py @@ -247,13 +247,20 @@ def createstravaworkoutdata(w): def handle_stravaexport(file,workoutname,stravatoken,description=''): # w = Workout.objects.get(id=workoutid) client = stravalib.Client(access_token=stravatoken) - - act = client.upload_activity(file,'tcx',name=workoutname) - res = act.wait(poll_interval=5.0) + try: + act = client.upload_activity(file,'tcx',name=workoutname) + res = act.wait(poll_interval=5.0) - # description doesn't work yet. Have to wait for stravalib to update - act = client.update_activity(res.id,activity_type='Rowing',description=description) + # description doesn't work yet. Have to wait for stravalib to update + 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 diff --git a/rowers/views.py b/rowers/views.py index 6d480807..01c3116c 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -934,9 +934,17 @@ def workout_strava_upload_view(request,id=0): try: with open(tcxfile,'rb') as f: - res = stravastuff.handle_stravaexport(f,w.name, - r.stravatoken, - description=w.notes) + try: + res = stravastuff.handle_stravaexport(f,w.name, + 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.save() From 04aa40f19c28bbbc08b1507fdee6aecc6614b6c1 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 27 Dec 2016 08:52:30 +0100 Subject: [PATCH 2/2] Typo correction in dataprep --- rowers/dataprep.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index 9744b6b9..b6dbad35 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -518,7 +518,7 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True, try: drivespeed = drivelength/rowdatadf[' DriveTime (ms)']*1.0e3 except TypeError: - drivespeed = 0.0*rowdatadf['TimeStam (sec)'] + drivespeed = 0.0*rowdatadf['TimeStamp (sec)'] drivespeed = drivespeed.fillna(value=0) driveenergy = drivelength*averageforce*4.44822