mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
IGN:Try to stop the endless PDF related tickets
This commit is contained in:
parent
0b592ab2d5
commit
fbc8832f27
@ -7,7 +7,10 @@ from various formats.
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
class ConversionError(Exception):
|
class ConversionError(Exception):
|
||||||
pass
|
|
||||||
|
def __init__(self, msg, only_msg=False):
|
||||||
|
Exception.__init__(self, msg)
|
||||||
|
self.only_msg = only_msg
|
||||||
|
|
||||||
class UnknownFormatError(Exception):
|
class UnknownFormatError(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -38,7 +38,7 @@ def generate_html(pathtopdf, logger):
|
|||||||
p = popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
p = popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
except OSError, err:
|
except OSError, err:
|
||||||
if err.errno == 2:
|
if err.errno == 2:
|
||||||
raise ConversionError(_('Could not find pdftohtml, check it is in your PATH'))
|
raise ConversionError(_('Could not find pdftohtml, check it is in your PATH'), True)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
logger.info(p.stdout.read())
|
logger.info(p.stdout.read())
|
||||||
@ -47,10 +47,10 @@ def generate_html(pathtopdf, logger):
|
|||||||
err = p.stderr.read()
|
err = p.stderr.read()
|
||||||
raise ConversionError, err
|
raise ConversionError, err
|
||||||
if not os.path.exists(index) or os.stat(index).st_size < 100:
|
if not os.path.exists(index) or os.stat(index).st_size < 100:
|
||||||
raise ConversionError(os.path.basename(pathtopdf) + _(' does not allow copying of text.'))
|
raise ConversionError(os.path.basename(pathtopdf) + _(' does not allow copying of text.'), True)
|
||||||
raw = open(index).read(4000)
|
raw = open(index).read(4000)
|
||||||
if not '<br' in raw:
|
if not '<br' in raw:
|
||||||
raise ConversionError(os.path.basename(pathtopdf) + _(' is an image based PDF. Only conversion of text based PDFs is supported.'))
|
raise ConversionError(os.path.basename(pathtopdf) + _(' is an image based PDF. Only conversion of text based PDFs is supported.'), True)
|
||||||
finally:
|
finally:
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
return index
|
return index
|
||||||
|
@ -1076,6 +1076,9 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
print >>sys.stderr, formatted_traceback.encode('utf8', 'ignore') if isinstance(formatted_traceback, unicode) else formatted_traceback
|
print >>sys.stderr, formatted_traceback.encode('utf8', 'ignore') if isinstance(formatted_traceback, unicode) else formatted_traceback
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
if getattr(exception, 'only_msg', False):
|
||||||
|
error_dialog(self, _('Conversion Error'), unicode(exception)).exec_()
|
||||||
|
return
|
||||||
msg = u'<p><b>%s</b>: %s</p>'%exception
|
msg = u'<p><b>%s</b>: %s</p>'%exception
|
||||||
msg += u'<p>Failed to perform <b>job</b>: '+description
|
msg += u'<p>Failed to perform <b>job</b>: '+description
|
||||||
msg += u'<p>Detailed <b>traceback</b>:<pre>'
|
msg += u'<p>Detailed <b>traceback</b>:<pre>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user