Merge branch 'release/stravaerrors3'
This commit is contained in:
@@ -226,7 +226,16 @@ def createstravaworkoutdata(w):
|
|||||||
# to rowing on Strava
|
# to rowing on Strava
|
||||||
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)
|
try:
|
||||||
|
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:
|
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)
|
||||||
|
|||||||
@@ -868,6 +868,18 @@ def workout_strava_upload_view(request,id=0):
|
|||||||
res = stravastuff.handle_stravaexport(f,w.name,
|
res = stravastuff.handle_stravaexport(f,w.name,
|
||||||
r.stravatoken,
|
r.stravatoken,
|
||||||
description=w.notes)
|
description=w.notes)
|
||||||
|
if res==0:
|
||||||
|
message = "Strava Upload error: %s" % e
|
||||||
|
w.uploadedtostrava = -1
|
||||||
|
w.save()
|
||||||
|
os.remove(tcxfile)
|
||||||
|
url = reverse(workout_export_view,
|
||||||
|
kwargs = {
|
||||||
|
'id':str(w.id),
|
||||||
|
})
|
||||||
|
response = HttpResponseRedirect(url)
|
||||||
|
return response
|
||||||
|
|
||||||
except:
|
except:
|
||||||
with open("media/stravaerrors.log","a") as errorlog:
|
with open("media/stravaerrors.log","a") as errorlog:
|
||||||
errorstring = str(sys.exc_info()[0])
|
errorstring = str(sys.exc_info()[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user