From 35dd23615502ef89263bee456cb3814f930164d7 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sun, 5 Dec 2010 15:35:02 +0100 Subject: [PATCH] Improve TTY ui to not always prepend 'sync account foo' 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 Signed-off-by: Nicolas Sebrecht --- offlineimap/ui/TTY.py | 13 ++++++++++--- 1 file 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()