[PATCH 2/2] Improve TTY ui to not always prepend 'sync account foo'

Sebastian Spaeth Sebastian at SSpaeth.de
Sun Dec 5 14:35:02 GMT 2010


This is very excessive and a bit annoying. Output that information
only if the next line concerns a different account/thread than the
previous one. This quiets down the UI quite a bit without losing
information.

While modifying this line, use the newer Thread.name and not the as
per python doc's old syntax getName()

Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
 offlineimap/ui/TTY.py |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/offlineimap/ui/TTY.py b/offlineimap/ui/TTY.py
index 99c46d4..4c574b2 100644
--- a/offlineimap/ui/TTY.py
+++ b/offlineimap/ui/TTY.py
@@ -26,6 +26,7 @@ class TTYUI(UIBase):
         UIBase.__init__(s, config, verbose)
         s.iswaiting = 0
         s.outputlock = Lock()
+        s._lastThreaddisplay = None
 
     def isusable(s):
         return sys.stdout.isatty() and sys.stdin.isatty()
@@ -33,10 +34,16 @@ class TTYUI(UIBase):
     def _display(s, msg):
         s.outputlock.acquire()
         try:
-            if (currentThread().getName() == 'MainThread'):
-                print msg
+            #if the next output comes from a different thread than our last one
+            #add the info.
+            #Most look like 'account sync foo' or 'Folder sync foo'.
+            threadname = currentThread().name
+            if (threadname == s._lastThreaddisplay):
+                print " %s" % msg
             else:
-                print "%s:\n   %s" % (currentThread().getName(), msg)
+                print "%s:\n %s" % (threadname, msg)
+                s._lastThreaddisplay = threadname
+
             sys.stdout.flush()
         finally:
             s.outputlock.release()
-- 
1.7.1





More information about the OfflineIMAP-project mailing list