From 05b4d913c4a6a3c5f8c4c027387c9bd4333f123f Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 2 Mar 2021 19:06:12 +0100 Subject: [PATCH 1/2] more logging --- rowers/c2stuff.py | 6 ++++++ rowers/tasks.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 2ad32bd1..1f01438d 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -196,6 +196,12 @@ def get_c2_workouts(rower,do_async=True): knownc2ids = uniqify(knownc2ids+tombstones+parkedids) newids = [c2id for c2id in c2ids if not c2id in knownc2ids] + with open("c2_auto_import.log","a") as errorlog: + timestr = time.strftime("%Y%m%d-%H%M%S") + newidjson = json.dumps(newids) + errorlog.write(timestr+'New IDs found \r\n') + errorlog.write(newidjson) + errorlog.write('\r\n') newparkedids = uniqify(newids+parkedids) diff --git a/rowers/tasks.py b/rowers/tasks.py index 29be0770..fb4608c7 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -2955,7 +2955,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone time.sleep(delaysec) with open("c2_auto_import.log","a") as errorlog: timestr = time.strftime("%Y%m%d-%H%M%S") - errorlog.write(timestr+' '+str(c2id)+'for userid '+str(userid)+'\r\n') + errorlog.write(timestr+' '+str(c2id)+' for userid '+str(userid)+'\r\n') data = alldata[c2id] splitdata = None From 6d66bf20550ee9a33630cecd193f58ea677d8095 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 2 Mar 2021 19:15:24 +0100 Subject: [PATCH 2/2] tz improveme --- rowers/tasks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rowers/tasks.py b/rowers/tasks.py index fb4608c7..f22a3aab 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -2991,6 +2991,10 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone except: timezone_str = defaulttimezone + startdatetime = startdatetime.replace(tzinfo=None) + tz = pytz.timezone(timezone_str) + startdatetime = tz.localize(startdatetime) + workoutdate = startdatetime.astimezone( pytz.timezone(timezone_str) ).strftime('%Y-%m-%d')