[PATCH] Declutter TTY output

Sebastian Spaeth Sebastian at SSpaeth.de
Wed Mar 9 07:44:41 GMT 2011


Previously we would output:

Folder sync sspaeth.de[INBOX.INBOX201004]:
 Syncing INBOX.INBOX201004: IMAP -> Maildir
Folder sync sspaeth.de[INBOX.INBOX201006]:
 Syncing INBOX.INBOX201006: IMAP -> Maildir
Folder sync sspaeth.de[INBOX.INBOX201009]:
 Syncing INBOX.INBOX201009: IMAP -> Maildir

which is very repetitive and cluttered. By naming the folder sync
threads just according to the account and not the folder, the output
looks much nicer:

Folder sync [sspaeth.de]:
 Syncing INBOX.INBOX201004: IMAP -> Maildir
 Syncing INBOX.INBOX201006: IMAP -> Maildir
 Syncing INBOX.INBOX201009: IMAP -> Maildir

If syncing multiple accounts in parallel, we will still get headers
indicating the account:

Folder sync [sspaeth.de]:
 Syncing INBOX: IMAP -> Maildir
 Syncing INBOX.INBOX201006: IMAP -> Maildir
Folder sync [gmail]:
 Syncing INBOX: IMAP -> Maildir

This is a small fix that makes the output much nicer in my opinion.

Also don't output the thread name if we are in the MainThread, e.g. when
we output the initial offlineimap banner.

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

diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py
index 0f8c7be..35550c1 100644
--- a/offlineimap/accounts.py
+++ b/offlineimap/accounts.py
@@ -253,8 +253,7 @@ class SyncableAccount(Account):
                     thread = InstanceLimitedThread(\
                         instancename = 'FOLDER_' + self.remoterepos.getname(),
                         target = syncfolder,
-                        name = "Folder sync %s[%s]" % \
-                        (self.name, remotefolder.getvisiblename()),
+                        name = "Folder sync [%s]" % self.name,
                         args = (self.name, remoterepos, remotefolder, localrepos,
                                 statusrepos, quick))
                     thread.setDaemon(1)
diff --git a/offlineimap/ui/TTY.py b/offlineimap/ui/TTY.py
index ee18dfa..d88de1b 100644
--- a/offlineimap/ui/TTY.py
+++ b/offlineimap/ui/TTY.py
@@ -41,7 +41,8 @@ class TTYUI(UIBase):
                 threadname = currentThread().name
             except AttributeError:
                 threadname = currentThread().getName()
-            if (threadname == s._lastThreaddisplay):
+            if (threadname == s._lastThreaddisplay \
+                    or threadname == 'MainThread'):
                 print " %s" % msg
             else:
                 print "%s:\n %s" % (threadname, msg)
-- 
1.7.1





More information about the OfflineIMAP-project mailing list