From 1bfcbd6086068ae9b9f2bce42fdeda230fe359e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Poulain?= Date: Sat, 8 Aug 2020 11:32:28 +0200 Subject: [PATCH] ref(import): attrape les exceptions --- .../base/management/commands/import.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drupal2spip_lal/base/management/commands/import.py b/drupal2spip_lal/base/management/commands/import.py index 83a243b..dca7c59 100644 --- a/drupal2spip_lal/base/management/commands/import.py +++ b/drupal2spip_lal/base/management/commands/import.py @@ -1,9 +1,14 @@ +import logging + from django.core.management.base import BaseCommand from drupal2spip_lal.base.convert import convert_node from drupal2spip_lal.drupal.models import Node +logger = logging.getLogger('drupal2spip_lal') + + class Command(BaseCommand): help = "Import Drupal nodes to SPIP articles." @@ -26,7 +31,10 @@ class Command(BaseCommand): ) def handle(self, **options): - [ - convert_node(n, options) - for n in Node.objects.filter(pk__in=options.get('node', [])) - ] + for n in Node.objects.filter(pk__in=options.get('node', [])): + try: + convert_node(n, options) + except Exception as e: + logger.critical( + "L'import du node {} a échoué : {}".format(n.pk, e) + )