tools (common): fixed tty detection when isatty is not available

This commit is contained in:
Goffi 2017-02-23 07:33:30 +01:00
commit 4a36fba066

View file

@ -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