1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #13476 -- Added support for color in console output under Windows.

Detect and use the services of the ANSICON third-party tool if it's
available.
This commit is contained in:
Ramiro Morales
2013-12-02 23:11:59 -03:00
parent c75dd664cf
commit 12615dab78
3 changed files with 20 additions and 2 deletions

View File

@@ -13,10 +13,12 @@ def supports_color():
Returns True if the running system's terminal supports color, and False
otherwise.
"""
unsupported_platform = (sys.platform in ('win32', 'Pocket PC'))
plat = sys.platform
supported_platform = plat != 'Pocket PC' and (plat != 'win32' or
'ANSICON' in os.environ)
# isatty is not always implemented, #6223.
is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
if unsupported_platform or not is_a_tty:
if not supported_platform or not is_a_tty:
return False
return True