tools (common): fixed tty detection when isatty is not available
This commit is contained in:
parent
a1def7f8f0
commit
4a36fba066
1 changed files with 6 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue