diff options
| author | Peter A. Bigot <pab@pabigot.com> | 2024-03-11 18:08:49 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-03-22 16:26:45 +0000 |
| commit | adb0ea98d1fbdb2f9d863db1072deba199c0ae0e (patch) | |
| tree | 05386d33822ac937495af8c4621d0ee19e49aab2 | |
| parent | 2eeef2800b309e68f54855e4425d151e663a3f59 (diff) | |
| download | poky-adb0ea98d1fbdb2f9d863db1072deba199c0ae0e.tar.gz | |
bitbake: lib/bb: support NO_COLOR
Red text on a black background can make it difficult for people with
visual impairments to read the text of error messages. Respect the
presence of a non-empty NO_COLOR environment variable as an indication
the user doesn't want colorization to be automatically enabled.
See: https://no-color.org/
(Bitbake rev: d9986c54cd3d67ed1f7cb636b17696c8d0d4db85)
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | bitbake/lib/bb/msg.py | 2 | ||||
| -rw-r--r-- | bitbake/lib/bb/ui/knotty.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py index 93575d89c4..3e18596faa 100644 --- a/bitbake/lib/bb/msg.py +++ b/bitbake/lib/bb/msg.py | |||
| @@ -230,7 +230,7 @@ def logger_create(name, output=sys.stderr, level=logging.INFO, preserve_handlers | |||
| 230 | console = logging.StreamHandler(output) | 230 | console = logging.StreamHandler(output) |
| 231 | console.addFilter(bb.msg.LogFilterShowOnce()) | 231 | console.addFilter(bb.msg.LogFilterShowOnce()) |
| 232 | format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") | 232 | format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") |
| 233 | if color == 'always' or (color == 'auto' and output.isatty()): | 233 | if color == 'always' or (color == 'auto' and output.isatty() and os.environ.get('NO_COLOR', '') == ''): |
| 234 | format.enable_color() | 234 | format.enable_color() |
| 235 | console.setFormatter(format) | 235 | console.setFormatter(format) |
| 236 | if preserve_handlers: | 236 | if preserve_handlers: |
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index 5a97d040b0..f86999bb09 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py | |||
| @@ -179,7 +179,7 @@ class TerminalFilter(object): | |||
| 179 | new[3] = new[3] & ~termios.ECHO | 179 | new[3] = new[3] & ~termios.ECHO |
| 180 | termios.tcsetattr(fd, termios.TCSADRAIN, new) | 180 | termios.tcsetattr(fd, termios.TCSADRAIN, new) |
| 181 | curses.setupterm() | 181 | curses.setupterm() |
| 182 | if curses.tigetnum("colors") > 2: | 182 | if curses.tigetnum("colors") > 2 and os.environ.get('NO_COLOR', '') == '': |
| 183 | for h in handlers: | 183 | for h in handlers: |
| 184 | try: | 184 | try: |
| 185 | h.formatter.enable_color() | 185 | h.formatter.enable_color() |
