aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelley Spoon <kelley.spoon@linaro.org>2021-06-04 11:09:57 -0500
committerKelley Spoon <kelley.spoon@linaro.org>2021-06-07 12:52:29 +0000
commit9c7990585733afd36181294cbc5a8717d470c9c6 (patch)
tree128e16d6438c1e724c66acc94448f1dc79d45ef7
parent682ca606179a078cb11fd7fea62a54413bd2b38d (diff)
downloadlinaro-license-protection-9c7990585733afd36181294cbc5a8717d470c9c6.tar.gz
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 <kelley.spoon@linaro.org>
-rw-r--r--license_protected_downloads/management/commands/report_process.py4
1 files changed, 4 insertions, 0 deletions
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()