mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 13:06:23 +00:00
launcher: Automatically disable output coloration if not supported
This commit is contained in:
parent
598128fc0c
commit
4dc95f0fc2
1 changed files with 13 additions and 0 deletions
|
@ -75,6 +75,16 @@ class Protocols(object):
|
|||
return False
|
||||
|
||||
|
||||
def supports_ansi_colors():
|
||||
platform = sys.platform
|
||||
supported_platform = platform != 'win32' or 'ANSICON' in os.environ
|
||||
# isatty is not always implemented, #6223.
|
||||
is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
|
||||
if not supported_platform or not is_a_tty:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class Colors(object):
|
||||
HEADER = '\033[95m'
|
||||
OKBLUE = '\033[94m'
|
||||
|
@ -92,6 +102,9 @@ def desactivate_colors():
|
|||
Colors.FAIL = ''
|
||||
Colors.ENDC = ''
|
||||
|
||||
if not supports_ansi_colors():
|
||||
desactivate_colors()
|
||||
|
||||
|
||||
def mkdir(directory):
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue