From 18b37cc518b6fbb1a157b1afe84607313467aea2 Mon Sep 17 00:00:00 2001 From: Chris Laplante Date: Mon, 19 Aug 2024 10:36:13 -0400 Subject: bitbake: ui/knotty: respect NO_COLOR & check for tty; rename print_hyperlink => format_hyperlink (Bitbake rev: 3f6de25a8a4d73dfba864aa6a543c5eafa9b7c7c) Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/knotty.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index 5956ab177c..3784c93ad8 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py @@ -577,6 +577,8 @@ def main(server, eventHandler, params, tf = TerminalFilter): else: log_exec_tty = False + should_print_hyperlinks = sys.stdout.isatty() and os.environ.get('NO_COLOR', '') == '' + helper = uihelper.BBUIHelper() # Look for the specially designated handlers which need to be passed to the @@ -944,10 +946,12 @@ def main(server, eventHandler, params, tf = TerminalFilter): try: termfilter.clearFooter() summary = "" - def print_hyperlink(url, link_text): - start = f'\033]8;;{url}\033\\' - end = '\033]8;;\033\\' - return f'{start}{link_text}{end}' + def format_hyperlink(url, link_text): + if should_print_hyperlinks: + start = f'\033]8;;{url}\033\\' + end = '\033]8;;\033\\' + return f'{start}{link_text}{end}' + return link_text if taskfailures: summary += pluralise("\nSummary: %s task failed:", @@ -955,7 +959,7 @@ def main(server, eventHandler, params, tf = TerminalFilter): for (failure, log_file) in taskfailures.items(): summary += "\n %s" % failure if log_file: - hyperlink = print_hyperlink(f"file://{log_file}", log_file) + hyperlink = format_hyperlink(f"file://{log_file}", log_file) summary += "\n log: {}".format(hyperlink) if warnings: summary += pluralise("\nSummary: There was %s WARNING message.", -- cgit v1.2.3-54-g00ecf