* [PATCH] nft-test: don't use colors if output is not a tty
@ 2015-03-25 7:31 Patrick McHardy
2015-03-25 8:27 ` Jan Engelhardt
0 siblings, 1 reply; 2+ messages in thread
From: Patrick McHardy @ 2015-03-25 7:31 UTC (permalink / raw)
To: pablo, anarey; +Cc: netfilter-devel
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
tests/regression/nft-test.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/tests/regression/nft-test.py b/tests/regression/nft-test.py
index 2677127..559ad41 100755
--- a/tests/regression/nft-test.py
+++ b/tests/regression/nft-test.py
@@ -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):
'''
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nft-test: don't use colors if output is not a tty
2015-03-25 7:31 [PATCH] nft-test: don't use colors if output is not a tty Patrick McHardy
@ 2015-03-25 8:27 ` Jan Engelhardt
0 siblings, 0 replies; 2+ messages in thread
From: Jan Engelhardt @ 2015-03-25 8:27 UTC (permalink / raw)
To: Patrick McHardy; +Cc: pablo, anarey, netfilter-devel
>+ 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-25 8:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-25 7:31 [PATCH] nft-test: don't use colors if output is not a tty Patrick McHardy
2015-03-25 8:27 ` Jan Engelhardt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.