From 576d8e4b40ae35bb016035c8ded8351e6d319855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Sz=C5=91ke?= Date: Sat, 25 Jan 2025 13:27:52 +0100 Subject: [PATCH] bitbake: knotty: print() was eliminated from all loops for better performance. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactoring prints, print() functions were eliminated from all loops and it uses "\n".join(...) in a single print() call for better performance. (Bitbake rev: c32c3d9b83818661e12f3e437563ab4e1fa05e15) Signed-off-by: Benjamin Szőke Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/knotty.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index 732540b462..492ea20763 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py @@ -243,9 +243,10 @@ class TerminalFilter(object): def keepAlive(self, t): if not self.cuu: - print("Bitbake still alive (no events for %ds). Active tasks:" % t) + msgbuf = ["Bitbake still alive (no events for %ds). Active tasks:" % t] for t in self.helper.running_tasks: - print(t) + msgbuf.append(str(t)) + print("\n".join(msgbuf)) sys.stdout.flush() def updateFooter(self): @@ -379,13 +380,12 @@ class TerminalFilter(object): self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup) def print_event_log(event, includelogs, loglines, termfilter): - # FIXME refactor this out further logfile = event.logfile if logfile and os.path.exists(logfile): termfilter.clearFooter() bb.error("Logfile of failure stored in: %s" % logfile) if includelogs and not event.errprinted: - bb.plain("Log data follows:") + msgbuf = ["Log data follows:"] f = open(logfile, "r") lines = [] while True: @@ -398,11 +398,11 @@ def print_event_log(event, includelogs, loglines, termfilter): if len(lines) > int(loglines): lines.pop(0) else: - bb.plain('| %s' % l) + msgbuf.append('| %s' % l) f.close() if lines: - for line in lines: - bb.plain(line) + msgbuf.extend(lines) + print("\n".join(msgbuf)) def _log_settings_from_server(server, observe_only): # Get values of variables which control our output