netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [nft PATCH] tests: py: Don't colorize output if stderr is redirected
@ 2022-04-08 13:47 Phil Sutter
  2022-04-08 14:16 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Sutter @ 2022-04-08 13:47 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Cover for calls with '2>/tmp/log' and avoid printing escape sequences to
that file. One could still keep colored output on stdout, but that
required a printing routine for non-errors.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tests/py/nft-test.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
index 04dac8d77b25f..b66a33c21f661 100755
--- a/tests/py/nft-test.py
+++ b/tests/py/nft-test.py
@@ -39,7 +39,7 @@ signal_received = 0
 
 
 class Colors:
-    if sys.stdout.isatty():
+    if sys.stdout.isatty() and sys.stderr.isatty():
         HEADER = '\033[95m'
         GREEN = '\033[92m'
         YELLOW = '\033[93m'
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [nft PATCH] tests: py: Don't colorize output if stderr is redirected
  2022-04-08 13:47 [nft PATCH] tests: py: Don't colorize output if stderr is redirected Phil Sutter
@ 2022-04-08 14:16 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2022-04-08 14:16 UTC (permalink / raw)
  To: Phil Sutter; +Cc: Pablo Neira Ayuso, netfilter-devel

Phil Sutter <phil@nwl.cc> wrote:
> Cover for calls with '2>/tmp/log' and avoid printing escape sequences to
> that file. One could still keep colored output on stdout, but that
> required a printing routine for non-errors.

Thanks!  Please push.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-08 14:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-08 13:47 [nft PATCH] tests: py: Don't colorize output if stderr is redirected Phil Sutter
2022-04-08 14:16 ` Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).