mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-04 20:16:11 +01:00
Improved error reporting for comic conversion
This commit is contained in:
parent
033de33a99
commit
480da4436f
2 changed files with 9 additions and 5 deletions
|
|
@ -8,6 +8,7 @@
|
|||
'''
|
||||
|
||||
import os, shutil, traceback, textwrap, time
|
||||
from ctypes import byref
|
||||
from Queue import Empty
|
||||
|
||||
from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
|
||||
|
|
@ -75,7 +76,10 @@ def render(self):
|
|||
if img < 0:
|
||||
raise RuntimeError('Cannot create wand.')
|
||||
if not pw.MagickReadImage(img, self.path_to_page):
|
||||
raise IOError('Failed to read image from: %'%self.path_to_page)
|
||||
severity = pw.ExceptionType(0)
|
||||
msg = pw.MagickGetException(img, byref(severity))
|
||||
raise IOError('Failed to read image from: %s: %s'
|
||||
%(self.path_to_page, msg))
|
||||
width = pw.MagickGetImageWidth(img)
|
||||
height = pw.MagickGetImageHeight(img)
|
||||
if self.num == 0: # First image so create a thumbnail from it
|
||||
|
|
@ -363,14 +367,14 @@ def get_pages(self, comic, tdir2):
|
|||
else:
|
||||
new_pages, failures = process_pages(new_pages, self.opts,
|
||||
self.report_progress, tdir2)
|
||||
if not new_pages:
|
||||
raise ValueError('Could not find any valid pages in comic: %s'
|
||||
% comic)
|
||||
if failures:
|
||||
self.log.warning('Could not process the following pages '
|
||||
'(run with --verbose to see why):')
|
||||
for f in failures:
|
||||
self.log.warning('\t', f)
|
||||
if not new_pages:
|
||||
raise ValueError('Could not find any valid pages in comic: %s'
|
||||
% comic)
|
||||
thumbnail = os.path.join(tdir2,
|
||||
'thumbnail.'+self.opts.output_format.lower())
|
||||
if not os.access(thumbnail, os.R_OK):
|
||||
|
|
|
|||
|
|
@ -828,7 +828,7 @@ class MagickWand(ctypes.c_void_p): pass
|
|||
IsMagickWand = _magick.IsMagickWand
|
||||
# MagickGetException
|
||||
try:
|
||||
_magick.MagickGetException.restype = ctypes.POINTER(ctypes.c_char)
|
||||
_magick.MagickGetException.restype = ctypes.c_char_p
|
||||
_magick.MagickGetException.argtypes = (MagickWand,ctypes.POINTER(ExceptionType))
|
||||
except AttributeError,e:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in a new issue