Skip to content

Commit b36bd32

Browse files
authored
Print subprocess's stdout output if subprocess was exit with non-zero (#511)
status code.
1 parent 1662958 commit b36bd32

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

generate-code.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
import os
22
import subprocess
3+
import sys
34

45
def run_command(command):
5-
output = subprocess.check_output(command, shell=True)
6-
return output.decode('utf-8').strip()
6+
proc = subprocess.run(command, shell=True, text=True, capture_output=True)
7+
8+
if len(proc.stderr) != 0:
9+
print("\n\nSTDERR:\n\n")
10+
print(proc.stderr)
11+
print("\n\n")
12+
13+
if proc.returncode != 0:
14+
print("\n\nSTDOUT:\n\n")
15+
print(proc.stdout)
16+
print(f"\n\nCommand '{command}' returned non-zero exit status {proc.returncode}.")
17+
sys.exit(1)
18+
19+
return proc.stdout.strip()
720

821

922
def rewrite_liff_function_name_backward_compats():

0 commit comments

Comments
 (0)