Skip to content
This repository was archived by the owner on Jun 28, 2023. It is now read-only.

Commit edb4620

Browse files
committed
Use subprocess.run to capture stderr
1 parent ea8d13a commit edb4620

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

build_doc.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
from subprocess import check_output, STDOUT
3+
from subprocess import run, PIPE
44
import shlex
55
import os
66
import logging
@@ -22,12 +22,17 @@ def run_cmd(cmd, quiet=False):
2222
logging.info('command: {}'.format(cmd))
2323

2424
# use shlex to keep quoted substrings
25-
result = check_output(shlex.split(cmd), stderr=STDOUT).strip()
25+
result = run(shlex.split(cmd), stdout=PIPE, stderr=PIPE)
26+
stdout = result.stdout.strip().decode()
27+
stderr = result.stderr.strip().decode()
2628

27-
if result and not quiet:
28-
logging.debug(result.decode())
29+
if stdout and not quiet:
30+
logging.debug(stdout)
2931

30-
return result
32+
if stderr:
33+
logging.warning(stderr)
34+
35+
return result.stdout.strip()
3136

3237

3338
def build_docstring_rst():

0 commit comments

Comments
 (0)