From 24380c97d00c50365607c9acb50c0319c4e822d3 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 14 Jan 2021 19:58:02 +0100 Subject: [PATCH] logging for c2 import --- rowers/c2stuff.py | 10 +++++++++- rowers/management/commands/processemail.py | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 21bc4858..c9ce31e9 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -160,7 +160,9 @@ def get_c2_workouts(rower): try: thetoken = c2_open(rower.user) except NoTokenError: - return 0 + with open('c2_auto_import.log','a') as logfile: + logfile.write('c2_open fail \n') + return 0 res = get_c2_workout_list(rower.user,page=1) @@ -185,8 +187,14 @@ def get_c2_workouts(rower): newids = [c2id for c2id in c2ids if not c2id in knownc2ids] 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, rower.user,c2id) + with open('c2_auto_import.log','a') as logfile: + logfile.write('Local workout id {workoutid}\n'.format(workoutid=workoutid)) + return 1 diff --git a/rowers/management/commands/processemail.py b/rowers/management/commands/processemail.py index a14cf6b2..80de7dad 100644 --- a/rowers/management/commands/processemail.py +++ b/rowers/management/commands/processemail.py @@ -204,8 +204,12 @@ class Command(BaseCommand): # Concept2 rowers = Rower.objects.filter(c2_auto_import=True) for r in rowers: + with open('c2_auto_import.log','a') as logfile: + logfile.write(str(timezone.now())+" "+str(r.user)+" \n") if user_is_not_basic(r.user): - c2stuff.get_c2_workouts(r) + with open('c2_auto_import.log','a') as logfile: + logfile.write(' getting workouts \n') + c2stuff.get_c2_workouts(r) messages = Message.objects.filter(mailbox_id = workoutmailbox.id)