Ignore future media import errors

This commit is contained in:
Yohann D'ANELLO 2020-10-03 15:05:05 +02:00
parent e09b503ee1
commit c1098577e1
1 changed files with 3 additions and 2 deletions

View File

@ -1,3 +1,4 @@
from random import random
from time import sleep from time import sleep
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
@ -31,7 +32,7 @@ class Command(BaseCommand):
form = MediaAdminForm(instance=cl(), form = MediaAdminForm(instance=cl(),
data={"isbn": isbn, "_isbn": True, }) data={"isbn": isbn, "_isbn": True, })
# Don't DDOS any website # Don't DDOS any website
sleep(5) sleep(5 + (4 * random() - 1))
try: try:
form.full_clean() form.full_clean()
@ -42,7 +43,7 @@ class Command(BaseCommand):
self.stdout.write(self.style.SUCCESS( self.stdout.write(self.style.SUCCESS(
"Medium with ISBN {isbn} successfully imported" "Medium with ISBN {isbn} successfully imported"
.format(isbn=isbn))) .format(isbn=isbn)))
except (ValidationError, ValueError) as e: except Exception as e:
self.stderr.write(self.style.WARNING( self.stderr.write(self.style.WARNING(
"An error occured while importing ISBN {isbn}: {error}" "An error occured while importing ISBN {isbn}: {error}"
.format(isbn=isbn, error=str(e)))) .format(isbn=isbn, error=str(e))))