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):
|
||||
pass
|
||||
|
||||
def __init__(self, msg, only_msg=False):
|
||||
Exception.__init__(self, msg)
|
||||
self.only_msg = only_msg
|
||||
|
||||
class UnknownFormatError(Exception):
|
||||
pass
|
||||
|
@ -38,7 +38,7 @@ def generate_html(pathtopdf, logger):
|
||||
p = popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
except OSError, err:
|
||||
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:
|
||||
raise
|
||||
logger.info(p.stdout.read())
|
||||
@ -47,10 +47,10 @@ def generate_html(pathtopdf, logger):
|
||||
err = p.stderr.read()
|
||||
raise ConversionError, err
|
||||
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)
|
||||
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:
|
||||
os.chdir(cwd)
|
||||
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
|
||||
except:
|
||||
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>Failed to perform <b>job</b>: '+description
|
||||
msg += u'<p>Detailed <b>traceback</b>:<pre>'
|
||||
|
Loading…
x
Reference in New Issue
Block a user