Enable Colors for Windows 10 Build >= 10586

Windows 10 added support for ANSI colors since Build 10586.
From Build 14393 ANSI needs to enabled by executable, hence os.system('') is used

Source : 
https://stackoverflow.com/a/39675059
https://github.com/symfony/symfony/issues/17499
This commit is contained in:
Shobhit Bhosure
2019-02-03 17:26:43 +05:30
committed by GitHub
parent 97bdf5f3bd
commit 70d70ea2c9

View File

@@ -1,9 +1,15 @@
import sys
import os
import platform
colors = True # Output should be colored
machine = sys.platform # Detecting the os of current system
checkplatform = platform.platform() # Get current version of OS
if machine.lower().startswith(('os', 'win', 'darwin', 'ios')):
colors = False # Colors shouldn't be displayed in mac & windows
if checkplatform.startswith("Windows-10") and int(platform.version().split(".")[2]) >= 10586:
colors = True
os.system('') # Enables the ANSI
if not colors:
end = red = white = green = yellow = run = bad = good = info = que = ''
else: