commands: ignore timezone errors when importing redmine data

This commit is contained in:
Frédéric Péters 2020-08-05 13:54:50 +02:00
parent 72eff97d29
commit 138ce73290
1 changed files with 11 additions and 5 deletions

View File

@ -4,6 +4,8 @@ from django.core.management.base import BaseCommand
from django.utils.dateparse import parse_datetime
from django.utils.timezone import make_aware
import pytz
from eodb.events.models import Redmine
@ -16,8 +18,12 @@ class Command(BaseCommand):
for row in csv.reader(open(options['filename'])):
if not row[2]:
continue
redmine, created = Redmine.objects.get_or_create(journal_id=int(row[0]),
defaults={
'author_datetime': make_aware(parse_datetime(row[1])),
'module': row[2],
'author_email': row[3]})
try:
redmine, created = Redmine.objects.get_or_create(journal_id=int(row[0]),
defaults={
'author_datetime': make_aware(parse_datetime(row[1])),
'module': row[2],
'author_email': row[3]})
except pytz.exceptions.Error:
# ignore that one
continue