From 4a36fba066e3253837bdf78b7fefba23b6d8922a Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 23 Feb 2017 07:33:30 +0100 Subject: [PATCH] tools (common): fixed tty detection when isatty is not available --- src/tools/common/ansi.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tools/common/ansi.py b/src/tools/common/ansi.py index a66accd3..5c7788b7 100644 --- a/src/tools/common/ansi.py +++ b/src/tools/common/ansi.py @@ -42,8 +42,13 @@ class ANSI(object): return u''.join(args) -if not sys.stdout.isatty(): +try: + tty = sys.stdout.isatty() +except AttributeError: + tty = False +if not tty: # we don't want ANSI escape codes if we are not outputing to a tty! for attr in dir(ANSI): if isinstance(getattr(ANSI, attr), basestring): setattr(ANSI, attr, u'') +del tty