X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/d157af1061e9f03f59ea909d7d25f4a0b41f1c0e..ab8ffbde2df33d9c699e029ba613d2b014ba44b8:/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