comparison src/tools/common/ansi.py @ 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
parents 7cbffd754b4a
children 4b78b4c7f805
comparison
equal deleted inserted replaced
2164:63d191c05ecd 2165:a0fbb2b11fd0
40 args = list(args) 40 args = list(args)
41 args.append(cls.RESET) 41 args.append(cls.RESET)
42 return u''.join(args) 42 return u''.join(args)
43 43
44 44
45 if not sys.stdout.isatty(): 45 try:
46 tty = sys.stdout.isatty()
47 except AttributeError:
48 tty = False
49 if not tty:
46 # we don't want ANSI escape codes if we are not outputing to a tty! 50 # we don't want ANSI escape codes if we are not outputing to a tty!
47 for attr in dir(ANSI): 51 for attr in dir(ANSI):
48 if isinstance(getattr(ANSI, attr), basestring): 52 if isinstance(getattr(ANSI, attr), basestring):
49 setattr(ANSI, attr, u'') 53 setattr(ANSI, attr, u'')
54 del tty