Skip to content

Commit

Permalink
Print subprocess's stdout output if subprocess was exit with non-zero (
Browse files Browse the repository at this point in the history
…#511)

status code.
  • Loading branch information
tokuhirom committed Aug 28, 2023
1 parent 1662958 commit b36bd32
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions generate-code.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import os
import subprocess
import sys

def run_command(command):
output = subprocess.check_output(command, shell=True)
return output.decode('utf-8').strip()
proc = subprocess.run(command, shell=True, text=True, capture_output=True)

if len(proc.stderr) != 0:
print("\n\nSTDERR:\n\n")
print(proc.stderr)
print("\n\n")

if proc.returncode != 0:
print("\n\nSTDOUT:\n\n")
print(proc.stdout)
print(f"\n\nCommand '{command}' returned non-zero exit status {proc.returncode}.")
sys.exit(1)

return proc.stdout.strip()


def rewrite_liff_function_name_backward_compats():
Expand Down

0 comments on commit b36bd32

Please sign in to comment.