Some error catching
This commit is contained in:
@@ -830,26 +830,42 @@ def list_c2_upload_view(request,id=0):
|
|||||||
@login_required()
|
@login_required()
|
||||||
def workout_tcxemail_view(request,id=0):
|
def workout_tcxemail_view(request,id=0):
|
||||||
message = ""
|
message = ""
|
||||||
|
successmessage = ""
|
||||||
r = Rower.objects.get(user=request.user)
|
r = Rower.objects.get(user=request.user)
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
if (checkworkoutuser(request.user,w)):
|
if (checkworkoutuser(request.user,w)):
|
||||||
tcxfile = stravastuff.createstravaworkoutdata(w)
|
try:
|
||||||
if settings.DEBUG:
|
tcxfile = stravastuff.createstravaworkoutdata(w)
|
||||||
res = handle_sendemailtcx.delay(r.user.first_name,
|
if settings.DEBUG:
|
||||||
r.user.last_name,
|
res = handle_sendemailtcx.delay(r.user.first_name,
|
||||||
r.user.email,tcxfile)
|
r.user.last_name,
|
||||||
|
r.user.email,tcxfile)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
res = queuehigh.enqueue(handle_sendemailtcx,r.user.first_name,
|
res = queuehigh.enqueue(handle_sendemailtcx,r.user.first_name,
|
||||||
r.user.last_name,
|
r.user.last_name,
|
||||||
r.user.email,tcxfile)
|
r.user.email,tcxfile)
|
||||||
|
|
||||||
successmessage = "The TCX file was sent to you per email"
|
successmessage = "The TCX file was sent to you per email"
|
||||||
url = reverse(workout_export_view,
|
url = reverse(workout_export_view,
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'id':str(w.id),
|
'id':str(w.id),
|
||||||
'successmessage':successmessage,
|
'successmessage':successmessage,
|
||||||
})
|
})
|
||||||
|
except:
|
||||||
|
successmessage = ""
|
||||||
|
message = "Something went wrong (strava export) "+str(sys.exc_info()[0])
|
||||||
|
with open("media/c2errors.log","a") as errorlog:
|
||||||
|
errorstring = str(sys.exc_info()[0])
|
||||||
|
timestr = strftime("%Y%m%d-%H%M%S")
|
||||||
|
errorlog.write(timestr+errorstring+"\r\n")
|
||||||
|
|
||||||
|
url = reverse(workout_export_view,
|
||||||
|
kwargs = {
|
||||||
|
'id':str(w.id),
|
||||||
|
'message':message,
|
||||||
|
})
|
||||||
|
|
||||||
response = HttpResponseRedirect(url)
|
response = HttpResponseRedirect(url)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -978,7 +994,9 @@ def workout_c2_upload_view(request,id=0):
|
|||||||
except:
|
except:
|
||||||
message = "Unexpected Error: "+str(sys.exc_info()[0])
|
message = "Unexpected Error: "+str(sys.exc_info()[0])
|
||||||
with open("media/c2errors.log","a") as errorlog:
|
with open("media/c2errors.log","a") as errorlog:
|
||||||
errorlog.write("Unexpected Error: "+str(sys.exc_info()[0]))
|
errorstring = str(sys.exc_info()[0])
|
||||||
|
timestr = time.strftime("%Y%m%d-%H%M%S")
|
||||||
|
errorlog.write(timestr+errorstring+"\n")
|
||||||
|
|
||||||
# check for duplicate error first
|
# check for duplicate error first
|
||||||
if (response.status_code == 409 ):
|
if (response.status_code == 409 ):
|
||||||
@@ -996,13 +1014,18 @@ def workout_c2_upload_view(request,id=0):
|
|||||||
except:
|
except:
|
||||||
message = "Something went wrong in workout_c2_upload_view. Response code 200/201 but C2 sync failed: "+response.text
|
message = "Something went wrong in workout_c2_upload_view. Response code 200/201 but C2 sync failed: "+response.text
|
||||||
with open("media/c2errors.log","a") as errorlog:
|
with open("media/c2errors.log","a") as errorlog:
|
||||||
errorlog.write("Unexpected Error: "+str(sys.exc_info()[0]))
|
errorstring = str(sys.exc_info()[0])
|
||||||
|
timestr = time.strftime("%Y%m%d-%H%M%S")
|
||||||
|
errorlog.write(timestr+errorstring+"\n")
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
s = response
|
s = response
|
||||||
message = "Something went wrong in workout_c2_upload_view. C2 sync failed."
|
message = "Something went wrong in workout_c2_upload_view. C2 sync failed."
|
||||||
with open("media/c2errors.log","a") as errorlog:
|
with open("media/c2errors.log","a") as errorlog:
|
||||||
errorlog.write("Unexpected Error: "+response.text())
|
errorstring = str(sys.exc_info()[0])
|
||||||
|
timestr = time.strftime("%Y%m%d-%H%M%S")
|
||||||
|
errorlog.write(timestr+errorstring+"\n")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
message = "You are not authorized to upload this workout"
|
message = "You are not authorized to upload this workout"
|
||||||
|
|||||||
Reference in New Issue
Block a user