/offlineimap/head: changeset 312
Updated the mbnames recorder to bring it back up-to-date with the new account-centric system. It will now gather reports from account sync threads, and when it has all that it's supposed to, it'll write out the file.
This commit is contained in:
parent
930f94fbb1
commit
f652bc5bac
@ -15,7 +15,7 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
from offlineimap import imapserver, repository, threadutil
|
from offlineimap import imapserver, repository, threadutil, mbnames
|
||||||
from offlineimap.ui import UIBase
|
from offlineimap.ui import UIBase
|
||||||
from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
|
from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
|
||||||
from threading import Event
|
from threading import Event
|
||||||
@ -128,6 +128,7 @@ class AccountSynchronizationMixin:
|
|||||||
thread.start()
|
thread.start()
|
||||||
folderthreads.append(thread)
|
folderthreads.append(thread)
|
||||||
threadutil.threadsreset(folderthreads)
|
threadutil.threadsreset(folderthreads)
|
||||||
|
mbnames.write()
|
||||||
if not self.hold:
|
if not self.hold:
|
||||||
server.close()
|
server.close()
|
||||||
finally:
|
finally:
|
||||||
@ -146,8 +147,7 @@ def syncfolder(accountname, remoterepos, remotefolder, localrepos,
|
|||||||
getfolder(remotefolder.getvisiblename().\
|
getfolder(remotefolder.getvisiblename().\
|
||||||
replace(remoterepos.getsep(), localrepos.getsep()))
|
replace(remoterepos.getsep(), localrepos.getsep()))
|
||||||
# Write the mailboxes
|
# Write the mailboxes
|
||||||
mailboxes.append({'accountname': accountname,
|
mbnames.add(accountname, localfolder.getvisiblename())
|
||||||
'foldername': localfolder.getvisiblename()})
|
|
||||||
# Load local folder
|
# Load local folder
|
||||||
ui.syncingfolder(remoterepos, remotefolder, localrepos, localfolder)
|
ui.syncingfolder(remoterepos, remotefolder, localrepos, localfolder)
|
||||||
ui.loadmessagelist(localrepos, localfolder)
|
ui.loadmessagelist(localrepos, localfolder)
|
||||||
|
@ -19,7 +19,30 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import re # for folderfilter
|
import re # for folderfilter
|
||||||
|
|
||||||
def genmbnames(config, boxlist):
|
boxes = {}
|
||||||
|
config = None
|
||||||
|
accounts = None
|
||||||
|
|
||||||
|
def init(conf, accts):
|
||||||
|
global config, accounts
|
||||||
|
config = conf
|
||||||
|
accounts = accts
|
||||||
|
|
||||||
|
def add(accountname, foldername):
|
||||||
|
if not accountname in boxes:
|
||||||
|
boxes[accountname] = []
|
||||||
|
if not foldername in boxes[accountname]:
|
||||||
|
boxes[accountname].append(foldername)
|
||||||
|
|
||||||
|
def write():
|
||||||
|
# See if we're ready to write it out.
|
||||||
|
for account in accounts:
|
||||||
|
if account not in boxes:
|
||||||
|
return
|
||||||
|
|
||||||
|
genmbnames()
|
||||||
|
|
||||||
|
def genmbnames():
|
||||||
"""Takes a configparser object and a boxlist, which is a list of hashes
|
"""Takes a configparser object and a boxlist, which is a list of hashes
|
||||||
containing 'accountname' and 'foldername' keys."""
|
containing 'accountname' and 'foldername' keys."""
|
||||||
localeval = config.getlocaleval()
|
localeval = config.getlocaleval()
|
||||||
@ -31,9 +54,13 @@ def genmbnames(config, boxlist):
|
|||||||
if config.has_option("mbnames", "folderfilter"):
|
if config.has_option("mbnames", "folderfilter"):
|
||||||
folderfilter = localeval.eval(config.get("mbnames", "folderfilter"),
|
folderfilter = localeval.eval(config.get("mbnames", "folderfilter"),
|
||||||
{'re': re})
|
{'re': re})
|
||||||
itemlist = [localeval.eval(config.get("mbnames", "peritem", raw=1)) % item\
|
itemlist = []
|
||||||
for item in boxlist \
|
for accountname in boxes.keys():
|
||||||
if folderfilter(item['accountname'], item['foldername'])]
|
for foldername in boxes[accountname]:
|
||||||
|
if folderfilter(accountname, foldername):
|
||||||
|
itemlist.append(config.get("mbnames", "peritem", raw=1) % \
|
||||||
|
{'accountname': accountname,
|
||||||
|
'foldername': foldername})
|
||||||
file.write(localeval.eval(config.get("mbnames", "sep")).join(itemlist))
|
file.write(localeval.eval(config.get("mbnames", "sep")).join(itemlist))
|
||||||
file.write(localeval.eval(config.get("mbnames", "footer")))
|
file.write(localeval.eval(config.get("mbnames", "footer")))
|
||||||
file.close()
|
file.close()
|
||||||
|
@ -38,9 +38,8 @@ def syncitall(accounts, config):
|
|||||||
currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
|
currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
|
||||||
ui = UIBase.getglobalui()
|
ui = UIBase.getglobalui()
|
||||||
threads = threadutil.threadlist()
|
threads = threadutil.threadlist()
|
||||||
offlineimap.accounts.mailboxes = [] # Reset.
|
mbnames.init(config, accounts)
|
||||||
for accountname in accounts:
|
for accountname in accounts:
|
||||||
syncaccount(threads, config, accountname)
|
syncaccount(threads, config, accountname)
|
||||||
# Wait for the threads to finish.
|
# Wait for the threads to finish.
|
||||||
threads.reset()
|
threads.reset()
|
||||||
mbnames.genmbnames(config, offlineimap.accounts.mailboxes)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user