X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/561a8ca7780e1efa80173e6f0dfd5339aaf0b689..4ca553d8a656c29444c0b54f9f2e33ad7f8f1cc1:/apps/catalogue/management/commands/importbooks.py diff --git a/apps/catalogue/management/commands/importbooks.py b/apps/catalogue/management/commands/importbooks.py index 323755e58..2a44d5aaf 100644 --- a/apps/catalogue/management/commands/importbooks.py +++ b/apps/catalogue/management/commands/importbooks.py @@ -11,7 +11,7 @@ from django.core.management.base import BaseCommand from django.core.management.color import color_style from django.core.files import File from catalogue.utils import trim_query_log - +from librarian.picture import ImageStore from wolnelektury_core.management.profile import profile from catalogue.models import Book @@ -60,8 +60,16 @@ class Command(BaseCommand): print "Importing %s.%s" % (file_base, ebook_format) book.save() - def import_picture(self, file_path, options): - picture = Picture.from_xml_file(file_path, overwrite=options.get('force')) + def import_picture(self, file_path, options, continue_on_error=True): + try: + image_store = ImageStore(os.path.dirname(file_path)) + picture = Picture.from_xml_file(file_path, image_store=image_store, overwrite=options.get('force')) + except Exception, ex: + if continue_on_error: + print "%s: %s" % (file_path, ex) + return + else: + raise ex return picture # @profile