aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2017-07-05 10:25:01 -0500
committerAndy Doan <andy.doan@linaro.org>2017-07-05 15:30:11 +0000
commit8dfa8a83523dc5076c9e54deeb6495e185d11d2e (patch)
tree337686b291153b0d6bddce8e2bff821acdee51e5
parent1513aaa2f1b65a2923928900c800b7da5176b86a (diff)
download report: just skip bad download entries
We get these about once a week where a single download entry will have some invalid utf8 junk in it. Its almost always just a single row, so lets just discard it for now. We'll still get a single email so we could in theory add the entry into the DB if we think its legit. Change-Id: Icb8eebcae0f7b3f04756a3e22ea447a07a210bc2 Reviewed-on: https://review.linaro.org/20505 Reviewed-by: Ben Copeland <ben.copeland@linaro.org>
-rw-r--r--license_protected_downloads/management/commands/report_process.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/license_protected_downloads/management/commands/report_process.py b/license_protected_downloads/management/commands/report_process.py
index 4382b14..288a6d0 100644
--- a/license_protected_downloads/management/commands/report_process.py
+++ b/license_protected_downloads/management/commands/report_process.py
@@ -1,7 +1,7 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from license_protected_downloads.models import Download
-from django.db import DatabaseError
+from django.db import DataError, DatabaseError
import os
import time
import glob
@@ -45,9 +45,13 @@ class Command(BaseCommand):
# This looks odd, but we sometimes get URLs with newlines
# in them and we need the real file name
download = row[1].replace('\n', '')
- Download.objects.create(
- ip=row[0], name=download, link=str2bool(row[2]),
- ref=row[3])
+ try:
+ Download.objects.create(
+ ip=row[0], name=download, link=str2bool(row[2]),
+ ref=row[3])
+ except DataError:
+ logging.error(
+ 'Skipping invalid download entry: %s', row)
os.remove(name)
except (csv.Error, DatabaseError):
logging.exception('unable to process csv %s', name)