mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor applehelp: Use subprocess.run() instead of Popen
This commit is contained in:
parent
bf62a96831
commit
041da498aa
@ -12,6 +12,7 @@ import plistlib
|
|||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
from os import path, environ
|
from os import path, environ
|
||||||
|
from subprocess import CalledProcessError, PIPE, STDOUT
|
||||||
|
|
||||||
from sphinx import package_dir
|
from sphinx import package_dir
|
||||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||||
@ -207,18 +208,12 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
' '.join([shlex.quote(arg) for arg in args]))
|
' '.join([shlex.quote(arg) for arg in args]))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(args,
|
subprocess.run(args, stdout=PIPE, stderr=STDOUT, check=True)
|
||||||
stdout=subprocess.PIPE,
|
logger.info(__('done'))
|
||||||
stderr=subprocess.STDOUT)
|
|
||||||
|
|
||||||
output = p.communicate()[0]
|
|
||||||
|
|
||||||
if p.returncode != 0:
|
|
||||||
raise AppleHelpIndexerFailed(output)
|
|
||||||
else:
|
|
||||||
logger.info(__('done'))
|
|
||||||
except OSError:
|
except OSError:
|
||||||
raise AppleHelpIndexerFailed(__('Command not found: %s') % args[0])
|
raise AppleHelpIndexerFailed(__('Command not found: %s') % args[0])
|
||||||
|
except CalledProcessError as exc:
|
||||||
|
raise AppleHelpCodeSigningFailed(exc.stdout)
|
||||||
|
|
||||||
def do_codesign(self):
|
def do_codesign(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
@ -242,18 +237,12 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
' '.join([shlex.quote(arg) for arg in args]))
|
' '.join([shlex.quote(arg) for arg in args]))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(args,
|
subprocess.run(args, stdout=PIPE, stderr=STDOUT, check=True)
|
||||||
stdout=subprocess.PIPE,
|
logger.info(__('done'))
|
||||||
stderr=subprocess.STDOUT)
|
|
||||||
|
|
||||||
output = p.communicate()[0]
|
|
||||||
|
|
||||||
if p.returncode != 0:
|
|
||||||
raise AppleHelpCodeSigningFailed(output)
|
|
||||||
else:
|
|
||||||
logger.info(__('done'))
|
|
||||||
except OSError:
|
except OSError:
|
||||||
raise AppleHelpCodeSigningFailed(__('Command not found: %s') % args[0])
|
raise AppleHelpCodeSigningFailed(__('Command not found: %s') % args[0])
|
||||||
|
except CalledProcessError as exc:
|
||||||
|
raise AppleHelpCodeSigningFailed(exc.stdout)
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
Loading…
Reference in New Issue
Block a user