mirror of https://github.com/zulip/zulip.git
tools: Add bright_red_output() to tools/lint-all
This commit is contained in:
parent
ffe648baa8
commit
f955991120
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from contextlib import contextmanager
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
@ -11,7 +12,7 @@ import traceback
|
|||
|
||||
try:
|
||||
import lister
|
||||
from typing import cast, Any, Callable, Dict, List, Optional
|
||||
from typing import cast, Any, Callable, Dict, List, Optional, Generator
|
||||
except ImportError as e:
|
||||
print("ImportError: {}".format(e))
|
||||
print("You need to run the Zulip linters inside a Zulip dev environment.")
|
||||
|
@ -36,6 +37,19 @@ zproject/settings.py
|
|||
zproject/test_settings.py
|
||||
""".split()
|
||||
|
||||
@contextmanager
|
||||
def bright_red_output():
|
||||
# type: () -> Generator[None, None, None]
|
||||
# Make the lint output bright red
|
||||
sys.stdout.write('\x1B[1;31m')
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
# Restore normal terminal colors
|
||||
sys.stdout.write('\x1B[0m')
|
||||
|
||||
|
||||
def check_pyflakes(options, by_lang):
|
||||
# type: (Any, Dict[str, List[str]]) -> bool
|
||||
if not by_lang['py']:
|
||||
|
@ -393,11 +407,7 @@ def run():
|
|||
lint_functions[func.__name__] = func
|
||||
return func
|
||||
|
||||
try:
|
||||
# Make the lint output bright red
|
||||
sys.stdout.write('\x1B[1;31m')
|
||||
sys.stdout.flush()
|
||||
|
||||
with bright_red_output():
|
||||
@lint
|
||||
def templates():
|
||||
# type: () -> int
|
||||
|
@ -456,9 +466,5 @@ def run():
|
|||
|
||||
sys.exit(1 if failed else 0)
|
||||
|
||||
finally:
|
||||
# Restore normal terminal colors
|
||||
sys.stdout.write('\x1B[0m')
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
|
Loading…
Reference in New Issue