mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
pylint_all: Use subprocess module instead of os.system()
- As a bonus this makes the script properly stop on Ctrl+C
This commit is contained in:
parent
0746f2adf9
commit
74c73d396a
@ -5,9 +5,10 @@ Runs pylint on all Python files in project directories known to contain Python s
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from os import path, walk, system
|
from os import path, walk
|
||||||
from sys import exit as exitwith
|
from sys import exit as exitwith
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
import subprocess
|
||||||
|
|
||||||
PROJECT_ROOT = path.dirname(path.dirname(path.realpath(__file__)))
|
PROJECT_ROOT = path.dirname(path.dirname(path.realpath(__file__)))
|
||||||
PYLINT_RCFILE = f"{PROJECT_ROOT}/scripts/pylintrc"
|
PYLINT_RCFILE = f"{PROJECT_ROOT}/scripts/pylintrc"
|
||||||
@ -28,11 +29,20 @@ def pylint_all_filenames(dev_mode, rootdirs):
|
|||||||
failed = []
|
failed = []
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
checked_count += 1
|
checked_count += 1
|
||||||
cmdline = "pylint --rcfile=\"{}\" \"{}\"".format(PYLINT_RCFILE, filename)
|
command_line = [
|
||||||
print("{}[{}/{}] Running pylint on file: {}{}".format(SGR_INFO, checked_count, len(filenames),
|
"pylint",
|
||||||
filename, SGR_CLEAR))
|
f"--rcfile={PYLINT_RCFILE}",
|
||||||
exit_code = system(cmdline)
|
f"{filename}",
|
||||||
if exit_code != 0:
|
]
|
||||||
|
print(
|
||||||
|
f"{SGR_INFO}"
|
||||||
|
f"[{checked_count}/{len(filenames)}] "
|
||||||
|
f"Running pylint on file: {filename}{SGR_CLEAR}"
|
||||||
|
)
|
||||||
|
|
||||||
|
process = subprocess.run(command_line)
|
||||||
|
|
||||||
|
if process.returncode != 0:
|
||||||
if dev_mode:
|
if dev_mode:
|
||||||
return 1, checked_count
|
return 1, checked_count
|
||||||
failed.append(filename)
|
failed.append(filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user