Merge pull request #942 from dagwieers/color-capability

Check for terminal capabilities if curses is available
This commit is contained in:
Michael DeHaan 2012-08-24 16:44:29 -07:00
commit 98483f5252

View file

@ -21,8 +21,20 @@ import sys
ANSIBLE_COLOR=True
if os.getenv("ANSIBLE_NOCOLOR") is not None:
ANSIBLE_COLOR=False
if not sys.stdout.isatty():
elif not sys.stdout.isatty():
ANSIBLE_COLOR=False
else:
try:
import curses
curses.setupterm()
if curses.tigetnum('colors') < 0:
ANSIBLE_COLOR=False
except ImportError:
# curses library was not found
pass
except curses.error:
# curses returns an error (e.g. could not find terminal)
ANSIBLE_COLOR=False
# --- begin "pretty"
#