[UPD] script replace subprocess.check_output to subprocess.run
This commit is contained in:
parent
2513c1b8e9
commit
5b87769e2e
3 changed files with 27 additions and 9 deletions
|
|
@ -74,13 +74,15 @@ def main():
|
||||||
no_tab = 0
|
no_tab = 0
|
||||||
|
|
||||||
# Validate file format
|
# Validate file format
|
||||||
out = subprocess.check_output(
|
out = subprocess.run(
|
||||||
f"python -m tabnanny {config.file}",
|
f"python -m tabnanny {config.file}",
|
||||||
stderr=subprocess.STDOUT,
|
|
||||||
shell=True,
|
shell=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
)
|
)
|
||||||
if out:
|
result = (out.stdout or "") + (out.stderr or "")
|
||||||
print(out)
|
if result:
|
||||||
|
print(result)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# with tokenize.open(config.file) as f:
|
# with tokenize.open(config.file) as f:
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,14 @@ _logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def execute_shell(cmd):
|
def execute_shell(cmd):
|
||||||
out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
|
result = subprocess.run(
|
||||||
return out.decode().strip() if out else ""
|
cmd,
|
||||||
|
shell=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
output = (result.stdout or "") + (result.stderr or "")
|
||||||
|
return result.returncode, output.strip()
|
||||||
|
|
||||||
|
|
||||||
def get_config():
|
def get_config():
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,21 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
IGNORE_EXTENSION = []
|
IGNORE_EXTENSION = []
|
||||||
IGNORE_FILE_NAME = ["Makefile"]
|
IGNORE_FILE_NAME = ["Makefile"]
|
||||||
|
|
||||||
|
|
||||||
def execute_shell(cmd):
|
def execute_shell(cmd):
|
||||||
out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
|
result = subprocess.run(
|
||||||
return out.decode().strip() if out else ""
|
cmd,
|
||||||
|
shell=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
output = (result.stdout or "") + (result.stderr or "")
|
||||||
|
return result.returncode, output.strip()
|
||||||
|
|
||||||
|
|
||||||
def get_modified_files():
|
def get_modified_files():
|
||||||
|
|
@ -152,4 +159,7 @@ if __name__ == "__main__":
|
||||||
has_file = True
|
has_file = True
|
||||||
if has_file:
|
if has_file:
|
||||||
print(cmd_format)
|
print(cmd_format)
|
||||||
execute_shell(cmd_format)
|
status, output = execute_shell(cmd_format)
|
||||||
|
if status != 0:
|
||||||
|
print(output)
|
||||||
|
sys.exit(status)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue