X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/1ca6872afcca0bb6fb4c0c11fdad3b760a2362a1..939f115b73778ebcd99e99abc04e94dbe16d17ff:/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