linter: Update external_linter visual output.

This commit is contained in:
Tommy Ip 2017-07-06 12:48:26 +08:00 committed by Tim Abbott
parent e0d4a007e8
commit 766abaa1a3
1 changed files with 23 additions and 6 deletions

View File

@ -8,6 +8,8 @@ import sys
import optparse import optparse
import subprocess import subprocess
from linter_lib.printer import print_err, colors
# check for the venv # check for the venv
from lib import sanity_check from lib import sanity_check
sanity_check.check_venv(__file__) sanity_check.check_venv(__file__)
@ -128,14 +130,29 @@ def run():
If target_langs is empty, just runs the linter unconditionally. If target_langs is empty, just runs the linter unconditionally.
""" """
color = next(colors)
def run_linter(): def run_linter():
# type: () -> int # type: () -> int
if len(target_langs) == 0: targets = [] # type: List[str]
return subprocess.call(command) if len(target_langs) != 0:
targets = [target for lang in target_langs for target in by_lang[lang]] targets = [target for lang in target_langs for target in by_lang[lang]]
if len(targets) == 0: if len(targets) == 0:
return 0 # If we this linter has a list of languages, and
return subprocess.call(command + targets) # no files in those languages are to be checked,
# then we can safely return success without
# invoking the external linter.
return 0
p = subprocess.Popen(command + targets,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
for line in iter(p.stdout.readline, b''):
print_err(name, color, line)
return p.wait() # Linter exit code
lint_functions[name] = run_linter lint_functions[name] = run_linter
with bright_red_output(): with bright_red_output():