IGN:Try to stop the endless PDF related tickets

This commit is contained in:
Kovid Goyal 2008-06-05 20:39:52 -07:00
parent 0b592ab2d5
commit fbc8832f27
3 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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>'