mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #4797 from tk0miya/4789_imgconverter_misdetects_convert_command
Fix #4789: imgconverter: confused by converter.exe of Windows
This commit is contained in:
commit
095b178cc3
1
CHANGES
1
CHANGES
@ -19,6 +19,7 @@ Bugs fixed
|
||||
* #4769: autodoc loses the first staticmethod parameter
|
||||
* #4790: autosummary: too wide two column tables in PDF builds
|
||||
* #4795: Latex customization via ``_templates/longtable.tex_t`` is broken
|
||||
* #4789: imgconverter: confused by convert.exe of Windows
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -37,17 +37,28 @@ class ImagemagickConverter(ImageConverter):
|
||||
try:
|
||||
args = [self.config.image_converter, '-version']
|
||||
logger.debug('Invoking %r ...', args)
|
||||
ret = subprocess.call(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
if ret == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
except (OSError, IOError):
|
||||
logger.warning(__('convert command %r cannot be run.'
|
||||
'check the image_converter setting'),
|
||||
self.config.image_converter)
|
||||
return False
|
||||
|
||||
try:
|
||||
stdout, stderr = p.communicate()
|
||||
except (OSError, IOError) as err:
|
||||
if err.errno not in (EPIPE, EINVAL):
|
||||
raise
|
||||
stdout, stderr = p.stdout.read(), p.stderr.read()
|
||||
p.wait()
|
||||
if p.returncode != 0:
|
||||
logger.warning(__('convert exited with error:\n'
|
||||
'[stderr]\n%s\n[stdout]\n%s'),
|
||||
(stderr, stdout))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def convert(self, _from, _to):
|
||||
# type: (unicode, unicode) -> bool
|
||||
"""Converts the image to expected one."""
|
||||
|
Loading…
Reference in New Issue
Block a user