mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix ebook-viewer not working when launched as a standalone program for PDF files on windows.
This commit is contained in:
parent
e78cf6de20
commit
57d0a310b2
@ -12,6 +12,7 @@ import subprocess
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre.ebooks import ConversionError, DRMError
|
from calibre.ebooks import ConversionError, DRMError
|
||||||
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre import isosx, iswindows, islinux
|
from calibre import isosx, iswindows, islinux
|
||||||
from calibre import CurrentDir
|
from calibre import CurrentDir
|
||||||
|
|
||||||
@ -45,8 +46,10 @@ def pdftohtml(output_dir, pdf_path, no_images):
|
|||||||
if no_images:
|
if no_images:
|
||||||
cmd.append('-i')
|
cmd.append('-i')
|
||||||
|
|
||||||
|
logf = PersistentTemporaryFile('pdftohtml_log')
|
||||||
try:
|
try:
|
||||||
p = popen(cmd, stderr=subprocess.PIPE)
|
p = popen(cmd, stderr=logf._fd, stdout=logf._fd,
|
||||||
|
stdin=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'))
|
||||||
@ -62,10 +65,13 @@ def pdftohtml(output_dir, pdf_path, no_images):
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
logf.flush()
|
||||||
|
logf.close()
|
||||||
|
out = open(logf.name, 'rb').read()
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
err = p.stderr.read()
|
raise ConversionError(out)
|
||||||
raise ConversionError(err)
|
print "pdftohtml log:"
|
||||||
|
print out
|
||||||
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 DRMError()
|
raise DRMError()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user