From c1098577e167407bbeffdf131fcb61ebd334c1e5 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 3 Oct 2020 15:05:05 +0200 Subject: [PATCH] Ignore future media import errors --- media/management/commands/import_future_media.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/media/management/commands/import_future_media.py b/media/management/commands/import_future_media.py index 35f1a7e..d9af5de 100644 --- a/media/management/commands/import_future_media.py +++ b/media/management/commands/import_future_media.py @@ -1,3 +1,4 @@ +from random import random from time import sleep from django.core.exceptions import ValidationError @@ -31,7 +32,7 @@ class Command(BaseCommand): form = MediaAdminForm(instance=cl(), data={"isbn": isbn, "_isbn": True, }) # Don't DDOS any website - sleep(5) + sleep(5 + (4 * random() - 1)) try: form.full_clean() @@ -42,7 +43,7 @@ class Command(BaseCommand): self.stdout.write(self.style.SUCCESS( "Medium with ISBN {isbn} successfully imported" .format(isbn=isbn))) - except (ValidationError, ValueError) as e: + except Exception as e: self.stderr.write(self.style.WARNING( "An error occured while importing ISBN {isbn}: {error}" .format(isbn=isbn, error=str(e))))