summaryrefslogtreecommitdiff
path: root/tools/u_boot_pylib/tout.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-04-29 07:22:05 -0600
committerSimon Glass <sjg@chromium.org>2025-05-27 10:07:41 +0100
commit9dee86cf533271deddd7f8ab077d98e4a1d3cb78 (patch)
tree73d0ff42e1a3e5d2ecd4f15f6cb25be0c9996f02 /tools/u_boot_pylib/tout.py
parent55342144af598453c2de0271b8df50821f39ba13 (diff)
u_boot_pylib: Allow disabling colour output
When running tests there is no situation in which we want ANSI output as it makes it much harder to see what is going on in logs, tests, etc. Provide a way to disable this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/u_boot_pylib/tout.py')
-rw-r--r--tools/u_boot_pylib/tout.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/u_boot_pylib/tout.py b/tools/u_boot_pylib/tout.py
index 6bd2806f88f..37849d1450e 100644
--- a/tools/u_boot_pylib/tout.py
+++ b/tools/u_boot_pylib/tout.py
@@ -155,7 +155,7 @@ def user_output(msg):
"""
_output(0, msg)
-def init(_verbose=WARNING, stdout=sys.stdout):
+def init(_verbose=WARNING, stdout=sys.stdout, allow_colour=True):
"""Initialize a new output object.
Args:
@@ -166,7 +166,8 @@ def init(_verbose=WARNING, stdout=sys.stdout):
verbose = _verbose
_progress = '' # Our last progress message
- _color = terminal.Color()
+ _color = terminal.Color(terminal.COLOR_IF_TERMINAL if allow_colour
+ else terminal.COLOR_NEVER)
_stdout = stdout
# TODO(sjg): Move this into Chromite libraries when we have them