Private
Public Access
1
0

additional logging

This commit is contained in:
Sander Roosendaal
2021-01-15 19:24:23 +01:00
parent b5e708804e
commit c47302b350

View File

@@ -167,6 +167,8 @@ def get_c2_workouts(rower):
res = get_c2_workout_list(rower.user,page=1)
if (res.status_code != 200):
with open('c2_auto_import.log') as logfile:
logfile.write('Status code != 200\n')
return 0
else:
c2ids = [item['id'] for item in res.json()['data']]
@@ -804,9 +806,14 @@ def get_c2_workout_list(user,page=1):
r = Rower.objects.get(user=user)
if (r.c2token == '') or (r.c2token is None):
s = "Token doesn't exist. Need to authorize"
with open('c2_auto_import.log') as logfile:
logfile.write('get_c2_workout_list - token does not exist\n')
return custom_exception_handler(401,s)
elif (timezone.now()>r.tokenexpirydate):
s = "Token expired. Needs to refresh."
with open('c2_auto_import.log') as logfile:
logfile.write('get_c2_workout_list - token expires\n')
return custom_exception_handler(401,s)
else:
# ready to fetch. Hurray