Merge tag 'c2error' into develop
strava/sporttracks warning for no data
This commit is contained in:
@@ -176,7 +176,11 @@ def get_sporttracks_workout(user,sporttracksid):
|
||||
|
||||
def createsporttracksworkoutdata(w):
|
||||
filename = w.csvfilename
|
||||
row = rowingdata(filename)
|
||||
try:
|
||||
row = rowingdata(filename)
|
||||
except:
|
||||
return 0
|
||||
|
||||
averagehr = int(row.df[' HRCur (bpm)'].mean())
|
||||
maxhr = int(row.df[' HRCur (bpm)'].max())
|
||||
|
||||
|
||||
@@ -238,9 +238,12 @@ def get_strava_workout(user,stravaid):
|
||||
|
||||
def createstravaworkoutdata(w):
|
||||
filename = w.csvfilename
|
||||
row = rowingdata(filename)
|
||||
tcxfilename = filename[:-4]+'.tcx'
|
||||
row.exporttotcx(tcxfilename,notes=w.notes)
|
||||
try:
|
||||
row = rowingdata(filename)
|
||||
tcxfilename = filename[:-4]+'.tcx'
|
||||
row.exporttotcx(tcxfilename,notes=w.notes)
|
||||
except:
|
||||
tcxfilename = 0
|
||||
|
||||
return tcxfilename
|
||||
|
||||
|
||||
@@ -924,34 +924,42 @@ def workout_strava_upload_view(request,id=0):
|
||||
if (checkworkoutuser(request.user,w)):
|
||||
try:
|
||||
tcxfile = stravastuff.createstravaworkoutdata(w)
|
||||
|
||||
with open(tcxfile,'rb') as f:
|
||||
try:
|
||||
res = stravastuff.handle_stravaexport(f,w.name,
|
||||
if tcxfile:
|
||||
with open(tcxfile,'rb') as f:
|
||||
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 = strftime("%Y%m%d-%H%M%S")
|
||||
errorlog.write(timestr+errorstring+"\r\n")
|
||||
errorlog.write("views.py line 937\r\n")
|
||||
message = 'Error: '+errorstring
|
||||
res = 0
|
||||
try:
|
||||
w.uploadedtostrava = res
|
||||
w.save()
|
||||
os.remove(tcxfile)
|
||||
url = "/rowers/workout/"+str(w.id)+"/edit"
|
||||
successmessage = 'Workout sent to Strava.'
|
||||
except:
|
||||
with open("media/stravaerrors.log","a") as errorlog:
|
||||
errorstring = str(sys.exc_info()[0])
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
errorlog.write(timestr+errorstring+"\r\n")
|
||||
errorlog.write("views.py line 952\r\n")
|
||||
message = 'Error: '+errorstring
|
||||
|
||||
except:
|
||||
with open("media/stravaerrors.log","a") as errorlog:
|
||||
errorstring = str(sys.exc_info()[0])
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
errorlog.write(timestr+errorstring+"\r\n")
|
||||
errorlog.write("views.py line 937\r\n")
|
||||
message = 'Error: '+errorstring
|
||||
res = 0
|
||||
try:
|
||||
w.uploadedtostrava = res
|
||||
w.save()
|
||||
os.remove(tcxfile)
|
||||
url = "/rowers/workout/"+str(w.id)+"/edit"
|
||||
successmessage = 'Workout sent to Strava.'
|
||||
except:
|
||||
with open("media/stravaerrors.log","a") as errorlog:
|
||||
errorstring = str(sys.exc_info()[0])
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
errorlog.write(timestr+errorstring+"\r\n")
|
||||
errorlog.write("views.py line 952\r\n")
|
||||
message = 'Error: '+errorstring
|
||||
else:
|
||||
message = "Strava Upload error"
|
||||
w.uploadedtostrava = -1
|
||||
w.save()
|
||||
url = reverse(workout_export_view,
|
||||
kwargs = {
|
||||
'id':str(w.id),
|
||||
})
|
||||
response = HttpResponseRedirect(url)
|
||||
|
||||
|
||||
url = reverse(workout_export_view,
|
||||
@@ -1063,6 +1071,15 @@ def workout_sporttracks_upload_view(request,id=0):
|
||||
w = Workout.objects.get(id=id)
|
||||
if (checkworkoutuser(request.user,w)):
|
||||
data = sporttracksstuff.createsporttracksworkoutdata(w)
|
||||
if not data:
|
||||
message = "Data error"
|
||||
url = reverse(workout_export_view,
|
||||
kwargs = {
|
||||
'message':str(message),
|
||||
'id':str(w.id),
|
||||
})
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
authorizationstring = str('Bearer ' + thetoken)
|
||||
headers = {'Authorization': authorizationstring,
|
||||
'user-agent': 'sanderroosendaal',
|
||||
|
||||
Reference in New Issue
Block a user