[UPD] script replace subprocess.check_output to subprocess.run

This commit is contained in:
Mathieu Benoit 2025-11-26 22:20:43 -05:00
parent 2513c1b8e9
commit 5b87769e2e
3 changed files with 27 additions and 9 deletions

View file

@ -74,13 +74,15 @@ def main():
no_tab = 0
# Validate file format
out = subprocess.check_output(
out = subprocess.run(
f"python -m tabnanny {config.file}",
stderr=subprocess.STDOUT,
shell=True,
capture_output=True,
text=True,
)
if out:
print(out)
result = (out.stdout or "") + (out.stderr or "")
if result:
print(result)
sys.exit(1)
# with tokenize.open(config.file) as f:

View file

@ -12,8 +12,14 @@ _logger = logging.getLogger(__name__)
def execute_shell(cmd):
out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
return out.decode().strip() if out else ""
result = subprocess.run(
cmd,
shell=True,
capture_output=True,
text=True,
)
output = (result.stdout or "") + (result.stderr or "")
return result.returncode, output.strip()
def get_config():

View file

@ -4,14 +4,21 @@
import os
import subprocess
import sys
IGNORE_EXTENSION = []
IGNORE_FILE_NAME = ["Makefile"]
def execute_shell(cmd):
out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
return out.decode().strip() if out else ""
result = subprocess.run(
cmd,
shell=True,
capture_output=True,
text=True,
)
output = (result.stdout or "") + (result.stderr or "")
return result.returncode, output.strip()
def get_modified_files():
@ -152,4 +159,7 @@ if __name__ == "__main__":
has_file = True
if has_file:
print(cmd_format)
execute_shell(cmd_format)
status, output = execute_shell(cmd_format)
if status != 0:
print(output)
sys.exit(status)