nft-test: don't use colors if output is not a tty
PATCH 1/1 nft-test: don't use colors if output is not a tty
Signed-off-by Patrick McHardy <[email protected]>
--- tests/regression/nft-test.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
tests/regression/nft-test.py +12 -6
@@ -31,12 +31,18 @@ signal_received = 0 class Colors: - HEADER = '\033[95m' - GREEN = '\033[92m' - YELLOW = '\033[93m' - RED = '\033[91m' - ENDC = '\033[0m' - + if sys.stdout.isatty(): + HEADER = '\033[95m' + GREEN = '\033[92m' + YELLOW = '\033[93m' + RED = '\033[91m' + ENDC = '\033[0m' + else: + HEADER = '' + GREEN = '' + YELLOW = '' + RED = '' + ENDC = '' def print_error(reason, filename=None, lineno=None): '''
Signature · 1 line
2.1.0
tests/regression/nft-test.py signal_received = 0 · line 39
Quoted 6 lines
tests/regression/nft-test.py +6
-0+ if sys.stdout.isatty(): + HEADER = '\033[95m' + GREEN = '\033[92m' + YELLOW = '\033[93m' + RED = '\033[91m' + ENDC = '\033[0m'
Where did the values 91, 92, 93, 95 actually come from? They are nonstandard and, apparently, are a carry-over for AIX compatibility.