From 9c7990585733afd36181294cbc5a8717d470c9c6 Mon Sep 17 00:00:00 2001 From: Kelley Spoon Date: Fri, 4 Jun 2021 11:09:57 -0500 Subject: report_process: support alternate timestamp format Previously the cron job to process the download report CSV file was choking because the timestamp in the CSV didn't have the fractional milisecond field on it. This change will catch the ValueError that gets raised, and tries an alternate timestamp so that processing can continue. Change-Id: Ied59f40eebc5e2be692aba5f87872f7e652e0e9d Reviewed-on: https://review.linaro.org/c/infrastructure/linaro-license-protection/+/38859 Reviewed-by: Kelley Spoon --- license_protected_downloads/management/commands/report_process.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/license_protected_downloads/management/commands/report_process.py b/license_protected_downloads/management/commands/report_process.py index 806f34e..f8b5d80 100644 --- a/license_protected_downloads/management/commands/report_process.py +++ b/license_protected_downloads/management/commands/report_process.py @@ -53,6 +53,10 @@ class Command(BaseCommand): try: download_timestamp = datetime.strptime( row[4], "%Y-%m-%d %H:%M:%S.%f") + except ValueError as e: + # handle timestamp in a different format + download_timestamp = datetime.strptime( + row[4], "%Y-%m-%d %H:%M:%S") except IndexError as e: download_timestamp = datetime.now() -- cgit v1.2.3