From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: bitbake-devel <bitbake-devel@lists.openembedded.org>
Subject: [PATCH] knotty: Limit printed lines to terminal size
Date: Sun, 12 May 2013 08:25:00 +0100 [thread overview]
Message-ID: <1368343500.21569.0.camel@ted> (raw)
If you have a small terminal window with a large number of bitbake threads,
the scrollback output becomes corrupted since the footer is larger than
the height of the screen.
This patch ensures we limit the number of printed lines to match the
terminal height.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 6ea7d86..c9323d9 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -102,13 +102,14 @@ class InteractConsoleLogFilter(logging.Filter):
class TerminalFilter(object):
columns = 80
+ lines = 25
def sigwinch_handle(self, signum, frame):
- self.columns = self.getTerminalColumns()
+ (self.lines, self.columns) = self.getTerminalSize()
if self._sigwinch_default:
self._sigwinch_default(signum, frame)
- def getTerminalColumns(self):
+ def getTerminalSize(self):
def ioctl_GWINSZ(fd):
try:
cr = struct.unpack('hh', fcntl.ioctl(fd, self.termios.TIOCGWINSZ, '1234'))
@@ -128,7 +129,7 @@ class TerminalFilter(object):
cr = (env['LINES'], env['COLUMNS'])
except:
cr = (25, 80)
- return cr[1]
+ return cr
def __init__(self, main, helper, console, format):
self.main = main
@@ -167,7 +168,7 @@ class TerminalFilter(object):
signal.signal(signal.SIGWINCH, self.sigwinch_handle)
except:
pass
- self.columns = self.getTerminalColumns()
+ (self.lines, self.columns) = self.getTerminalSize()
except:
self.cuu = None
console.addFilter(InteractConsoleLogFilter(self, format))
@@ -195,18 +196,30 @@ class TerminalFilter(object):
for t in runningpids:
tasks.append("%s (pid %s)" % (activetasks[t]["title"], t))
+ display = []
+ def addline(content, display):
+ display.append(content)
+ extra = int(len(content) / (self.columns + 1))
+ for n in range(extra):
+ display.append(None)
+ return 1 + extra
+
if self.main.shutdown:
content = "Waiting for %s running tasks to finish:" % len(activetasks)
elif not len(activetasks):
content = "No currently running tasks (%s of %s)" % (self.helper.tasknumber_current, self.helper.tasknumber_total)
else:
content = "Currently %s running tasks (%s of %s):" % (len(activetasks), self.helper.tasknumber_current, self.helper.tasknumber_total)
- print(content)
- lines = 1 + int(len(content) / (self.columns + 1))
+ lines = addline(content, display)
for tasknum, task in enumerate(tasks):
content = "%s: %s" % (tasknum, task)
- print(content)
- lines = lines + 1 + int(len(content) / (self.columns + 1))
+ lines = lines + addline(content, display)
+ if lines > (self.lines -1):
+ display = display[-(self.lines - 1):]
+ lines = self.lines - 1
+ for l in display:
+ if l:
+ print(l)
self.footer_present = lines
self.lastpids = runningpids[:]
self.lastcount = self.helper.tasknumber_current
reply other threads:[~2013-05-12 7:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1368343500.21569.0.camel@ted \
--to=richard.purdie@linuxfoundation.org \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.