Skip to content

Commit 74c73d3

Browse files
committed
pylint_all: Use subprocess module instead of os.system()
- As a bonus this makes the script properly stop on Ctrl+C
1 parent 0746f2a commit 74c73d3

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

scripts/pylint_all.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"""
66

77
from argparse import ArgumentParser
8-
from os import path, walk, system
8+
from os import path, walk
99
from sys import exit as exitwith
1010
from textwrap import dedent
11+
import subprocess
1112

1213
PROJECT_ROOT = path.dirname(path.dirname(path.realpath(__file__)))
1314
PYLINT_RCFILE = f"{PROJECT_ROOT}/scripts/pylintrc"
@@ -28,11 +29,20 @@ def pylint_all_filenames(dev_mode, rootdirs):
2829
failed = []
2930
for filename in filenames:
3031
checked_count += 1
31-
cmdline = "pylint --rcfile=\"{}\" \"{}\"".format(PYLINT_RCFILE, filename)
32-
print("{}[{}/{}] Running pylint on file: {}{}".format(SGR_INFO, checked_count, len(filenames),
33-
filename, SGR_CLEAR))
34-
exit_code = system(cmdline)
35-
if exit_code != 0:
32+
command_line = [
33+
"pylint",
34+
f"--rcfile={PYLINT_RCFILE}",
35+
f"{filename}",
36+
]
37+
print(
38+
f"{SGR_INFO}"
39+
f"[{checked_count}/{len(filenames)}] "
40+
f"Running pylint on file: {filename}{SGR_CLEAR}"
41+
)
42+
43+
process = subprocess.run(command_line)
44+
45+
if process.returncode != 0:
3646
if dev_mode:
3747
return 1, checked_count
3848
failed.append(filename)

0 commit comments

Comments
 (0)