@@ -2114,24 +2114,28 @@ def _unmultiplied_rgba8888_to_premultiplied_argb32(rgba8888):
2114
2114
2115
2115
def _check_and_log_subprocess (command , logger , ** kwargs ):
2116
2116
"""
2117
- Run *command* using `subprocess.check_output`. If it succeeds, return the
2118
- output (stdout and stderr); if not, raise an exception whose text includes
2119
- the failed command and captured output. Both the command and the output
2120
- are logged at DEBUG level on *logger*.
2117
+ Run *command*, returning its stdout output if it succeeds.
2118
+
2119
+ If it fails (exits with nonzero return code), raise an exception whose text
2120
+ includes the failed command and captured stdout and stderr output.
2121
+
2122
+ Regardless of the return code, the command is logged at DEBUG level on
2123
+ *logger*. In case of success, the output is likewise logged.
2121
2124
"""
2122
- logger .debug (command )
2123
- try :
2124
- report = subprocess .check_output (
2125
- command , stderr = subprocess .STDOUT , ** kwargs )
2126
- except subprocess .CalledProcessError as exc :
2125
+ logger .debug ('%s' , str (command ))
2126
+ proc = subprocess .run (
2127
+ command , stdout = subprocess .PIPE , stderr = subprocess .PIPE , ** kwargs )
2128
+ if proc .returncode :
2127
2129
raise RuntimeError (
2128
- 'The command\n '
2129
- ' {}\n '
2130
- 'failed and generated the following output:\n '
2131
- '{}'
2132
- .format (command , exc .output .decode ('utf-8' )))
2133
- logger .debug (report )
2134
- return report
2130
+ f"The command\n "
2131
+ f" { str (command )} \n "
2132
+ f"failed and generated the following output:\n "
2133
+ f"{ proc .stdout .decode ('utf-8' )} \n "
2134
+ f"and the following error:\n "
2135
+ f"{ proc .stderr .decode ('utf-8' )} " )
2136
+ logger .debug ("stdout:\n %s" , proc .stdout )
2137
+ logger .debug ("stderr:\n %s" , proc .stderr )
2138
+ return proc .stdout
2135
2139
2136
2140
2137
2141
def _check_not_matrix (** kwargs ):
0 commit comments