removing logging
This commit is contained in:
@@ -160,20 +160,14 @@ def get_c2_workouts(rower):
|
|||||||
try:
|
try:
|
||||||
thetoken = c2_open(rower.user)
|
thetoken = c2_open(rower.user)
|
||||||
except NoTokenError:
|
except NoTokenError:
|
||||||
with open('c2_auto_import.log','a') as logfile:
|
return 0
|
||||||
logfile.write('c2_open fail \n')
|
|
||||||
return 0
|
|
||||||
|
|
||||||
res = get_c2_workout_list(rower.user,page=1)
|
res = get_c2_workout_list(rower.user,page=1)
|
||||||
|
|
||||||
if (res.status_code != 200):
|
if (res.status_code != 200):
|
||||||
with open('c2_auto_import.log') as logfile:
|
|
||||||
logfile.write('Status code != 200\n')
|
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
c2ids = [item['id'] for item in res.json()['data']]
|
c2ids = [item['id'] for item in res.json()['data']]
|
||||||
with open('c2_auto_import.log','a') as logfile:
|
|
||||||
logfile.write(json.dumps(c2ids)+'\n')
|
|
||||||
alldata = {}
|
alldata = {}
|
||||||
for item in res.json()['data']:
|
for item in res.json()['data']:
|
||||||
alldata[item['id']] = item
|
alldata[item['id']] = item
|
||||||
@@ -191,13 +185,8 @@ def get_c2_workouts(rower):
|
|||||||
newids = [c2id for c2id in c2ids if not c2id in knownc2ids]
|
newids = [c2id for c2id in c2ids if not c2id in knownc2ids]
|
||||||
|
|
||||||
for c2id in newids:
|
for c2id in newids:
|
||||||
with open('c2_auto_import.log','a') as logfile:
|
|
||||||
logfile.write('Creating async workout for c2id {c2id}\n'.format(c2id=c2id))
|
|
||||||
|
|
||||||
workoutid = create_async_workout(alldata,
|
workoutid = create_async_workout(alldata,
|
||||||
rower.user,c2id)
|
rower.user,c2id)
|
||||||
with open('c2_auto_import.log','a') as logfile:
|
|
||||||
logfile.write('Local workout id {workoutid}\n'.format(workoutid=workoutid))
|
|
||||||
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
@@ -808,14 +797,10 @@ def get_c2_workout_list(user,page=1):
|
|||||||
r = Rower.objects.get(user=user)
|
r = Rower.objects.get(user=user)
|
||||||
if (r.c2token == '') or (r.c2token is None):
|
if (r.c2token == '') or (r.c2token is None):
|
||||||
s = "Token doesn't exist. Need to authorize"
|
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)
|
return custom_exception_handler(401,s)
|
||||||
elif (timezone.now()>r.tokenexpirydate):
|
elif (timezone.now()>r.tokenexpirydate):
|
||||||
s = "Token expired. Needs to refresh."
|
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)
|
return custom_exception_handler(401,s)
|
||||||
else:
|
else:
|
||||||
# ready to fetch. Hurray
|
# ready to fetch. Hurray
|
||||||
|
|||||||
@@ -205,10 +205,7 @@ class Command(BaseCommand):
|
|||||||
rowers = Rower.objects.filter(c2_auto_import=True)
|
rowers = Rower.objects.filter(c2_auto_import=True)
|
||||||
for r in rowers:
|
for r in rowers:
|
||||||
if user_is_not_basic(r.user):
|
if user_is_not_basic(r.user):
|
||||||
with open('c2_auto_import.log','a') as logfile:
|
c2stuff.get_c2_workouts(r)
|
||||||
logfile.write(str(timezone.now())+" "+str(r.user)+" \n")
|
|
||||||
logfile.write(' getting workouts \n')
|
|
||||||
c2stuff.get_c2_workouts(r)
|
|
||||||
|
|
||||||
|
|
||||||
messages = Message.objects.filter(mailbox_id = workoutmailbox.id)
|
messages = Message.objects.filter(mailbox_id = workoutmailbox.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user