]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
u_boot_pylib: Allow disabling colour output
authorSimon Glass <sjg@chromium.org>
Tue, 29 Apr 2025 13:22:05 +0000 (07:22 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 27 May 2025 09:07:41 +0000 (10:07 +0100)
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>
tools/u_boot_pylib/tout.py

index 6bd2806f88fb4999d4257590457257cf36a0aa45..37849d1450e123af636c045d84fccc287d8d9b8d 100644 (file)
@@ -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