Patchwork [bitbake-devel,v3,08/15] knotty.py, knotty2, py: Flush and update footer on dynamic log level change

login
register
mail settings
Submitter Jason Wessel
Date June 6, 2012, 8:28 p.m.
Message ID <1339014519-9972-9-git-send-email-jason.wessel@windriver.com>
Download mbox | patch
Permalink /patch/29343/
State New
Headers show

Comments

Jason Wessel - June 6, 2012, 8:28 p.m.
This patch adds a call to update the task list after changing log
modes dynamically such that you can immediately see the remaining
tasks.  After adding this functionality, it became obvious there was a
problem flushing data loaded into stdout because the task list would
not appear immediately.  Doing something like "bitbake IMAGE | tee
/tmp/log" is where the flush problem manifests itself the most.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
 lib/bb/ui/knotty.py  |   14 ++++++++++++--
 lib/bb/ui/knotty2.py |    4 ++++
 2 files changed, 16 insertions(+), 2 deletions(-)

Patch

diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index b4125f6..d7b1e19 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -82,9 +82,16 @@  class TerminalFilter(object):
     def clearFooter(self):
         return
 
+    def updateFooterForce(self):
+        self.printFooter(True)
+
     def updateFooter(self):
-        if not main.shutdown or not self.helper.needUpdate:
-            return
+        self.printFooter(False)
+
+    def printFooter(self, force_update):
+        if not force_update:
+            if not main.shutdown or not self.helper.needUpdate:
+                return
 
         activetasks = self.helper.running_tasks
         runningpids = self.helper.running_pids
@@ -238,6 +245,9 @@  def main(server, eventHandler, tf = TerminalFilter):
             if stdin_mgr.poll():
                 keyinput = sys.stdin.read(1)
                 rtloglevel.setLevel(keyinput, True)
+                termfilter.updateFooterForce()
+                sys.stdout.flush()
+
             # Always try printing any accumulated log files first
             rtloglevel.displayLogs()
             if event is None:
diff --git a/lib/bb/ui/knotty2.py b/lib/bb/ui/knotty2.py
index aa6a408..01693e9 100644
--- a/lib/bb/ui/knotty2.py
+++ b/lib/bb/ui/knotty2.py
@@ -73,6 +73,10 @@  class TerminalFilter2(object):
             sys.stdout.write(self.curses.tparm(self.ed))
         self.footer_present = False
 
+    def updateFooterForce(self):
+        self.footer_present = False
+        self.updateFooter()
+
     def updateFooter(self):
         if not self.cuu:
             return