Commit c1098577 authored by ynerant's avatar ynerant

Ignore future media import errors

parent e09b503e
Pipeline #4235 passed with stages
in 5 minutes and 7 seconds
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))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment