Some more C2 api forensics
This commit is contained in:
@@ -7,6 +7,7 @@ import json
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import time
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
@@ -250,7 +251,10 @@ def do_refresh_token(refreshtoken):
|
|||||||
refresh_token = token_json['refresh_token']
|
refresh_token = token_json['refresh_token']
|
||||||
except:
|
except:
|
||||||
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+"\r\n")
|
||||||
|
errorlog.write(str(token_json)+"\r\n")
|
||||||
thetoken = None
|
thetoken = None
|
||||||
expires_in = None
|
expires_in = None
|
||||||
refresh_token = None
|
refresh_token = None
|
||||||
|
|||||||
@@ -515,8 +515,11 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
|||||||
|
|
||||||
p2 = p.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
|
p2 = p.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
|
||||||
|
|
||||||
|
try:
|
||||||
drivespeed = drivelength/rowdatadf[' DriveTime (ms)']*1.0e3
|
drivespeed = drivelength/rowdatadf[' DriveTime (ms)']*1.0e3
|
||||||
|
except TypeError:
|
||||||
|
drivespeed = 0.0*drivelength
|
||||||
|
|
||||||
drivespeed = drivespeed.fillna(value=0)
|
drivespeed = drivespeed.fillna(value=0)
|
||||||
driveenergy = drivelength*averageforce*4.44822
|
driveenergy = drivelength*averageforce*4.44822
|
||||||
distance = rowdatadf.ix[:,'cum_dist']
|
distance = rowdatadf.ix[:,'cum_dist']
|
||||||
|
|||||||
@@ -997,7 +997,7 @@ def workout_c2_upload_view(request,id=0):
|
|||||||
with open("media/c2errors.log","a") as errorlog:
|
with open("media/c2errors.log","a") as errorlog:
|
||||||
errorstring = str(sys.exc_info()[0])
|
errorstring = str(sys.exc_info()[0])
|
||||||
timestr = time.strftime("%Y%m%d-%H%M%S")
|
timestr = time.strftime("%Y%m%d-%H%M%S")
|
||||||
errorlog.write(timestr+errorstring+"\n")
|
errorlog.write(timestr+errorstring+"\r\n")
|
||||||
|
|
||||||
# check for duplicate error first
|
# check for duplicate error first
|
||||||
if (response.status_code == 409 ):
|
if (response.status_code == 409 ):
|
||||||
@@ -1017,7 +1017,7 @@ def workout_c2_upload_view(request,id=0):
|
|||||||
with open("media/c2errors.log","a") as errorlog:
|
with open("media/c2errors.log","a") as errorlog:
|
||||||
errorstring = str(sys.exc_info()[0])
|
errorstring = str(sys.exc_info()[0])
|
||||||
timestr = time.strftime("%Y%m%d-%H%M%S")
|
timestr = time.strftime("%Y%m%d-%H%M%S")
|
||||||
errorlog.write(timestr+errorstring+"\n")
|
errorlog.write(timestr+errorstring+"\r\n")
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -1026,7 +1026,7 @@ def workout_c2_upload_view(request,id=0):
|
|||||||
with open("media/c2errors.log","a") as errorlog:
|
with open("media/c2errors.log","a") as errorlog:
|
||||||
errorstring = str(sys.exc_info()[0])
|
errorstring = str(sys.exc_info()[0])
|
||||||
timestr = time.strftime("%Y%m%d-%H%M%S")
|
timestr = time.strftime("%Y%m%d-%H%M%S")
|
||||||
errorlog.write(timestr+errorstring+"\n")
|
errorlog.write(timestr+errorstring+"\r\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