From patchwork Sat Jan 25 12:27:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Livius X-Patchwork-Id: 56093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC9EDC0218C for ; Sat, 25 Jan 2025 12:29:35 +0000 (UTC) Received: from smtp-out.freemail.hu (smtp-out.freemail.hu [46.107.16.242]) by mx.groups.io with SMTP id smtpd.web10.8926.1737808166434792688 for ; Sat, 25 Jan 2025 04:29:26 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@freemail.hu header.s=20181004 header.b=KRKFY94l; spf=pass (domain: freemail.hu, ip: 46.107.16.242, mailfrom: egyszeregy@freemail.hu) Received: from localhost.localdomain (catv-178-48-208-49.catv.fixed.vodafone.hu [178.48.208.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.freemail.hu (Postfix) with ESMTPSA id 4YgDWm264Kz8q; Sat, 25 Jan 2025 13:29:24 +0100 (CET) From: egyszeregy@freemail.hu To: bitbake-devel@lists.openembedded.org Cc: =?utf-8?q?Benjamin_Sz=C5=91ke?= Subject: [PATCH v3 1/4] bitbake: progressbar: Add self._fd_console to use for self._handle_resize() Date: Sat, 25 Jan 2025 13:27:49 +0100 Message-ID: <20250125122752.649-2-egyszeregy@freemail.hu> X-Mailer: git-send-email 2.47.1.windows.2 In-Reply-To: <20250125122752.649-1-egyszeregy@freemail.hu> References: <20250125122752.649-1-egyszeregy@freemail.hu> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/relaxed; t=1737808164; List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 25 Jan 2025 12:29:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17084 s=20181004; d=freemail.hu; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1756; bh=OMbJ1pXWmsldkpXzCJhrbnm3JgAdcrjxZC3B6XkI6RA=; b=KRKFY94lFtcTjT2XO1BedIo1zEF+uEgBwjYKuNfoW5MvqazsEtw5ot1mAtH+jzud I9x3Qsgk9Eiggot56XetRnkqXfnphfPrroW1nAPGOTikeSLSWQ4tNJkBXji2FY17rEP QiPrPUWIOaR01DmF0KBAB8RJjob4H27E/NcxJWvBZfElQBc5etSWIgpSyG2MN5/HHQj SyU8GDX22/NxvjqEB3DZY5HkRepfWaQZ/NlvwpSVaE/GQIwmBi3tszk2PUJ42fF7HSq GbZq77j/gnj1bhPfVMoKbil22OybGgPPkeZtKZPdL3xLmSSMgzlWLWf6I0ZTJFR+8A+ vGPKoRzSwA== Content-Transfer-Encoding: quoted-printable From: Benjamin Sz=C5=91ke Introduce self._fd_console as a dedicated attribute of self._handle_resiz= e(). Signed-off-by: Benjamin Sz=C5=91ke --- lib/progressbar/progressbar.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) except Exception as e: - print("DEBUG 5 %s" % e) self.term_width =3D self._env_size() =20 self.__iterable =3D None @@ -182,7 +189,7 @@ class ProgressBar(object): def _handle_resize(self, signum=3DNone, frame=3DNone): """Tries to catch resize signals sent from the terminal.""" =20 - h, w =3D array('h', ioctl(self.fd, termios.TIOCGWINSZ, '\0' * 8)= )[:2] + h, w =3D array('h', ioctl(self._fd_console, termios.TIOCGWINSZ, = '\0' * 8))[:2] self.term_width =3D w =20 =20 --=20 2.47.1.windows.2 diff --git a/lib/progressbar/progressbar.py b/lib/progressbar/progressbar= .py index d4da10ab7..eccc45849 100644 --- a/lib/progressbar/progressbar.py +++ b/lib/progressbar/progressbar.py @@ -110,18 +110,25 @@ class ProgressBar(object): self.widgets =3D widgets self.fd =3D fd self.left_justify =3D left_justify + self._fd_console =3D None =20 self.signal_set =3D False if term_width is not None: self.term_width =3D term_width else: try: + # Check if given file descriptor is resizable for exampl= e belong + # to a terminal/console as STDOUT or STDERR. If file des= criptor + # is resizable, let's allow to use for self._handle_resi= ze() + # in a dedicated self._fd_console in order to be able to= set + # temporarily/permanently self.fd to any StringIO or oth= er + # file descriptor later. + self._fd_console =3D fd self._handle_resize(None, None) signal.signal(signal.SIGWINCH, self._handle_resize) self.signal_set =3D True except (SystemExit, KeyboardInterrupt): raise From patchwork Sat Jan 25 12:27:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Livius X-Patchwork-Id: 56096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9D65C0218D for ; Sat, 25 Jan 2025 12:29:35 +0000 (UTC) Received: from smtp-out.freemail.hu (smtp-out.freemail.hu [46.107.16.242]) by mx.groups.io with SMTP id smtpd.web10.8928.1737808169590906672 for ; Sat, 25 Jan 2025 04:29:29 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@freemail.hu header.s=20181004 header.b=lYHV/Kc8; spf=pass (domain: freemail.hu, ip: 46.107.16.242, mailfrom: egyszeregy@freemail.hu) Received: from localhost.localdomain (catv-178-48-208-49.catv.fixed.vodafone.hu [178.48.208.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.freemail.hu (Postfix) with ESMTPSA id 4YgDWq4zRtz1QP; Sat, 25 Jan 2025 13:29:27 +0100 (CET) From: egyszeregy@freemail.hu To: bitbake-devel@lists.openembedded.org Cc: =?utf-8?q?Benjamin_Sz=C5=91ke?= Subject: [PATCH v3 2/4] bitbake: knotty: Use a StringIO buffer for update footer. Date: Sat, 25 Jan 2025 13:27:50 +0100 Message-ID: <20250125122752.649-3-egyszeregy@freemail.hu> X-Mailer: git-send-email 2.47.1.windows.2 In-Reply-To: <20250125122752.649-1-egyszeregy@freemail.hu> References: <20250125122752.649-1-egyszeregy@freemail.hu> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/relaxed; t=1737808168; List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 25 Jan 2025 12:29:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17085 s=20181004; d=freemail.hu; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; l=4500; bh=7Hdy5SuwLqPXCfbDpMxD+jOsdh1E8uImXi9ca3InbzY=; b=lYHV/Kc830QMrJv5Vg8tbxDSdXjk3l4LbqKsAdUYZJdHLPIuacHtgB/tvD+oHrdu LoxOvHu9cch6PW7RJrx3fY8sHEMM9KX6cM7iABISAke2of8zSB4m1LviG4oiW2lwRqQ ZHsjtOT9ldQCA3ehBYZRNEPkUxJ5N1+VnztccG1KG2EgNgIfDHt/+o7UamOJqfPeWYV nAPQhGluYeKhQjHuEiS/2iEp6Gj+tdqGSA76+vG4h5jMQQd/YDTje0Sd7cSvHpR1zux IF9GSkp34evvQqgIsYyaKlDqL1dC6p0R9Ikz05NAytqr5H6opDkG6fXEaPWb5aDdpdx nkbJY/E2Jg== Content-Transfer-Encoding: quoted-printable From: Benjamin Sz=C5=91ke Optimize printing in footer update with use a StringIO buffer and it prints content to terminal in a single call in every cycle. Signed-off-by: Benjamin Sz=C5=91ke --- lib/bb/ui/knotty.py | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) hrs =3D int(sec / 3600.0) @@ -253,10 +257,14 @@ class TerminalFilter(object): if self.footer_present and not self.helper.needUpdate: return self.helper.needUpdate =3D False - if self.footer_present: - self.clearFooter() if (not self.helper.tasknumber_total or self.helper.tasknumber_c= urrent =3D=3D self.helper.tasknumber_total) and not len(activetasks): + self.clearFooter() return + + # Clear footer buffer. + self._footer_buf.truncate(0) + self._footer_buf.seek(0) + tasks =3D [] for t in runningpids: start_time =3D activetasks[t].get("starttime", None) @@ -275,6 +283,7 @@ class TerminalFilter(object): else: pbar =3D BBProgress("0: %s" % msg, 100, widgets=3D= [' ', progressbar.Percentage(), ' ', progressbar.Bar(), ''], extrapos=3D5= , resize_handler=3Dself.sigwinch_handle) pbar.bouncing =3D False + pbar.fd =3D self._footer_buf activetasks[t]["progressbar"] =3D pbar tasks.append((pbar, msg, progress, rate, start_time)) else: @@ -285,7 +294,7 @@ class TerminalFilter(object): "Waiting for %s running tasks to finish"= , len(activetasks)) if not self.quiet: content +=3D ':' - print(content) + print(content, file=3Dself._footer_buf) else: scene_tasks =3D "%s of %s" % (self.helper.setscene_current, = self.helper.setscene_total) cur_tasks =3D "%s of %s" % (self.helper.tasknumber_current, = self.helper.tasknumber_total) @@ -294,7 +303,7 @@ class TerminalFilter(object): if not self.quiet: msg =3D "Setscene tasks: %s" % scene_tasks content +=3D msg + "\n" - print(msg) + print(msg, file=3Dself._footer_buf) =20 if self.quiet: msg =3D "Running tasks (%s, %s)" % (scene_tasks, cur_tas= ks) @@ -306,11 +315,12 @@ class TerminalFilter(object): if not self.main_progress or self.main_progress.maxval !=3D = maxtask: widgets =3D [' ', progressbar.Percentage(), ' ', progres= sbar.Bar()] self.main_progress =3D BBProgress("Running tasks", maxta= sk, widgets=3Dwidgets, resize_handler=3Dself.sigwinch_handle) + self.main_progress.fd =3D self._footer_buf self.main_progress.start(False) self.main_progress.setmessage(msg) progress =3D max(0, self.helper.tasknumber_current - 1) content +=3D self.main_progress.update(progress) - print('') + print('', file=3Dself._footer_buf) lines =3D self.getlines(content) if not self.quiet: for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines= )]): @@ -326,15 +336,20 @@ class TerminalFilter(object): content =3D pbar.update(progress) else: content =3D pbar.update(1) - print('') + print('', file=3Dself._footer_buf) else: content =3D "%s: %s" % (tasknum, task) - print(content) + print(content, file=3Dself._footer_buf) lines =3D lines + self.getlines(content) - self.footer_present =3D lines self.lastpids =3D runningpids[:] self.lastcount =3D self.helper.tasknumber_current =20 + # Clear footer and Print buffer. + self.clearFooter() + print(self._footer_buf.getvalue(), end=3D'') + self._footer_lines =3D lines + self.footer_present =3D True + def getlines(self, content): lines =3D 0 for line in content.split("\n"): @@ -342,6 +357,7 @@ class TerminalFilter(object): return lines =20 def finish(self): + self._footer_buf.close() if self.stdinbackup: fd =3D sys.stdin.fileno() self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdi= nbackup) --=20 2.47.1.windows.2 diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py index 2fff1b366..416ea166f 100644 --- a/lib/bb/ui/knotty.py +++ b/lib/bb/ui/knotty.py @@ -10,6 +10,7 @@ =20 from __future__ import division =20 +import io import os import sys import logging @@ -168,6 +169,9 @@ class TerminalFilter(object): self.lasttime =3D None self.quiet =3D quiet =20 + self._footer_buf =3D io.StringIO() + self._footer_lines =3D None + if not self.interactive: return =20 @@ -215,11 +219,11 @@ class TerminalFilter(object): =20 def clearFooter(self): if self.footer_present: - lines =3D self.footer_present - sys.stdout.buffer.write(self.curses.tparm(self.cuu, lines)) + sys.stdout.buffer.write(self.curses.tparm(self.cuu, self._fo= oter_lines)) sys.stdout.buffer.write(self.curses.tparm(self.ed)) sys.stdout.flush() self.footer_present =3D False + self._footer_lines =3D None =20 def elapsed(self, sec): From patchwork Sat Jan 25 12:27:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Livius X-Patchwork-Id: 56094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB991C0218E for ; Sat, 25 Jan 2025 12:29:35 +0000 (UTC) Received: from smtp-out.freemail.hu (smtp-out.freemail.hu [46.107.16.242]) by mx.groups.io with SMTP id smtpd.web11.8668.1737808171574059887 for ; Sat, 25 Jan 2025 04:29:31 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@freemail.hu header.s=20181004 header.b=U9ntFV/s; spf=pass (domain: freemail.hu, ip: 46.107.16.242, mailfrom: egyszeregy@freemail.hu) Received: from localhost.localdomain (catv-178-48-208-49.catv.fixed.vodafone.hu [178.48.208.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.freemail.hu (Postfix) with ESMTPSA id 4YgDWs4mhjzHm; Sat, 25 Jan 2025 13:29:29 +0100 (CET) From: egyszeregy@freemail.hu To: bitbake-devel@lists.openembedded.org Cc: =?utf-8?q?Benjamin_Sz=C5=91ke?= Subject: [PATCH v3 3/4] bitbake: knotty: Use 40 Hz refresh rate (FPS) for footer update. Date: Sat, 25 Jan 2025 13:27:51 +0100 Message-ID: <20250125122752.649-4-egyszeregy@freemail.hu> X-Mailer: git-send-email 2.47.1.windows.2 In-Reply-To: <20250125122752.649-1-egyszeregy@freemail.hu> References: <20250125122752.649-1-egyszeregy@freemail.hu> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/relaxed; t=1737808169; List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 25 Jan 2025 12:29:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17086 s=20181004; d=freemail.hu; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1985; bh=UgjLq2rOYnxJyFRcHguc0UUKUy6d0z7WKZnhmYaqtLE=; b=U9ntFV/sVOK8VnmARtCtpAXstiDNu3C3qjSZt5I4gWR4X1S4MD5VvXJNKIYO1uLt zEQ8rZ72Fj2AIqlWYW4U6YuGU2Wac/nKOFnYdx5NkzX1wJFLtETOBJiWwf3wz3tVKUD nRy/nznbimWPPVuAVzOdk2I3w1qMgjfPlcfXknpyYNxRgOs8HcWKZjQY5YO2lD5W57h R1ZWAt8fMEQ50lf5I23LE/2XT0crWjhpoMDzSO8HuU77SnyNAsbQysfNdmlA5OwVTGP xhuvCJF3Iogt8S/O9fmG8LOxmQY/M3p/2mbkgKDVUUvYhI9heVZWM5HJqPG8C5Uii11 ed4i0QD/pg== Content-Transfer-Encoding: quoted-printable From: Benjamin Sz=C5=91ke Refresh footer in 40 Hz to avoid heavy print() flooding but keep it fluen= t for human eyes. Signed-off-by: Benjamin Sz=C5=91ke --- lib/bb/ui/knotty.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) urrent =3D=3D self.helper.tasknumber_total) and not len(activetasks): self.clearFooter() --=20 2.47.1.windows.2 diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py index 416ea166f..bef45cad6 100644 --- a/lib/bb/ui/knotty.py +++ b/lib/bb/ui/knotty.py @@ -128,6 +128,10 @@ class InteractConsoleLogFilter(logging.Filter): return True =20 class TerminalFilter(object): + + # 40 Hz (FPS) -> 0.025 secs + _DEFAULT_PRINT_INTERVAL =3D 0.025 + rows =3D 25 columns =3D 80 =20 @@ -166,7 +170,7 @@ class TerminalFilter(object): self.interactive =3D sys.stdout.isatty() self.footer_present =3D False self.lastpids =3D [] - self.lasttime =3D None + self.lasttime =3D time.time() self.quiet =3D quiet =20 self._footer_buf =3D io.StringIO() @@ -251,11 +255,23 @@ class TerminalFilter(object): failedtasks =3D self.helper.failed_tasks runningpids =3D self.helper.running_pids currenttime =3D time.time() - if not self.lasttime or (currenttime - self.lasttime > 5): + deltatime =3D currenttime - self.lasttime + + if (deltatime > 5.0): self.helper.needUpdate =3D True - self.lasttime =3D currenttime - if self.footer_present and not self.helper.needUpdate: + need_update =3D self.helper.needUpdate + else: + # Do not let to update faster then _DEFAULT_PRINT_INTERVAL + # to avoid heavy print() flooding. + need_update =3D self.helper.needUpdate and (deltatime > self= ._DEFAULT_PRINT_INTERVAL) + + if self.footer_present and (not need_update): + # Footer update is not need. return + else: + # Footer update is need and store its "lasttime" value. + self.lasttime =3D currenttime + self.helper.needUpdate =3D False if (not self.helper.tasknumber_total or self.helper.tasknumber_c= From patchwork Sat Jan 25 12:27:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Livius X-Patchwork-Id: 56095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAD64C0218F for ; Sat, 25 Jan 2025 12:29:35 +0000 (UTC) Received: from smtp-out.freemail.hu (smtp-out.freemail.hu [46.107.16.242]) by mx.groups.io with SMTP id smtpd.web10.8929.1737808173573283869 for ; Sat, 25 Jan 2025 04:29:33 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@freemail.hu header.s=20181004 header.b=OPO6nQCA; spf=pass (domain: freemail.hu, ip: 46.107.16.242, mailfrom: egyszeregy@freemail.hu) Received: from localhost.localdomain (catv-178-48-208-49.catv.fixed.vodafone.hu [178.48.208.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.freemail.hu (Postfix) with ESMTPSA id 4YgDWv55kFz14t; Sat, 25 Jan 2025 13:29:31 +0100 (CET) From: egyszeregy@freemail.hu To: bitbake-devel@lists.openembedded.org Cc: =?utf-8?q?Benjamin_Sz=C5=91ke?= Subject: [PATCH v3 4/4] bitbake: knotty: print() was eliminated from all loops for better performance. Date: Sat, 25 Jan 2025 13:27:52 +0100 Message-ID: <20250125122752.649-5-egyszeregy@freemail.hu> X-Mailer: git-send-email 2.47.1.windows.2 In-Reply-To: <20250125122752.649-1-egyszeregy@freemail.hu> References: <20250125122752.649-1-egyszeregy@freemail.hu> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/relaxed; t=1737808171; List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 25 Jan 2025 12:29:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17087 s=20181004; d=freemail.hu; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1871; bh=EeDpWoJlUfOYj/cha3GH0X2emMJbKr/wz+vZNdj7owE=; b=OPO6nQCAyPkZUyRK1m6d71y54qVAwi2ooND0ti/xpzckENh6iattrWvntnPmYfAz J/9lZevOWbGB+QXm0+SeoUpEPS/yKvbU8Bhd/cxzlfTw3MLZrjGGB/oPtMY0A6goevt 08wfvI/vTnmD/p71OZpd+NXEh0RoF+UsDgn6cS0T0jm59vfSU4mwvdUuyUM4a5lY4tl 7QpjUUomiAfSf0nRQobgBJg3nWKyE4x/NfUnRV3LseVzrclwWLs7NCUhK0HNT0mEpam EJaenUJCZSHJF+CLsTjIIgdoHmmjdJO5u0Vm6rmcgf4NloSGHFdArwenuOKPxf4qfDg hIJUM/xJOQ== Content-Transfer-Encoding: quoted-printable From: Benjamin Sz=C5=91ke Refactoring prints, print() functions were eliminated from all loops and = it uses "\n".join(...) in a single print() call for better performance. Signed-off-by: Benjamin Sz=C5=91ke --- lib/bb/ui/knotty.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) =20 def updateFooter(self): @@ -379,13 +380,12 @@ class TerminalFilter(object): self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdi= nbackup) =20 def print_event_log(event, includelogs, loglines, termfilter): - # FIXME refactor this out further logfile =3D 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: - print("Log data follows:") + msgbuf =3D ["Log data follows:"] f =3D open(logfile, "r") lines =3D [] while True: @@ -398,11 +398,11 @@ def print_event_log(event, includelogs, loglines, t= ermfilter): if len(lines) > int(loglines): lines.pop(0) else: - print('| %s' % l) + msgbuf.append('| %s' % l) f.close() if lines: - for line in lines: - print(line) + msgbuf.extend(lines) + print("\n".join(msgbuf)) =20 def _log_settings_from_server(server, observe_only): # Get values of variables which control our output --=20 2.47.1.windows.2 diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py index bef45cad6..492ea2076 100644 --- a/lib/bb/ui/knotty.py +++ b/lib/bb/ui/knotty.py @@ -243,9 +243,10 @@ class TerminalFilter(object): =20 def keepAlive(self, t): if not self.cuu: - print("Bitbake still alive (no events for %ds). Active tasks= :" % t) + msgbuf =3D ["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()