Merge pull request #1558 from baijum/non_tty_stdout

sys.stdout could be StringIO or fake object
This commit is contained in:
Thomas S Hatch 2012-07-01 07:16:55 -07:00
commit 24d39d34f6

View File

@ -92,7 +92,12 @@ def get_colors(use=True):
'ENDC': '\033[0m',
}
if not use or not os.isatty(sys.stdout.fileno()):
try:
fileno = sys.stdout.fileno()
except AttributeError:
fileno = -1 # sys.stdout is StringIO or fake
if not use or not os.isatty(fileno):
for color in colors:
colors[color] = ''