changeset 2165:a0fbb2b11fd0

tools (common): fixed tty detection when isatty is not available
author Goffi <goffi@goffi.org>
date Thu, 23 Feb 2017 07:33:30 +0100 (2017-02-23)
parents 63d191c05ecd
children 1b3fbb76984b
files src/tools/common/ansi.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/tools/common/ansi.py	Tue Feb 21 21:01:40 2017 +0100
+++ b/src/tools/common/ansi.py	Thu Feb 23 07:33:30 2017 +0100
@@ -42,8 +42,13 @@
         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