]> code.delx.au - offlineimap/blob - offlineimap/syncmaster.py
Update FSF address
[offlineimap] / offlineimap / syncmaster.py
1 # OfflineIMAP synchronization master code
2 # Copyright (C) 2002 John Goerzen
3 # <jgoerzen@complete.org>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 from offlineimap import imaplib, imapserver, repository, folder, mbnames, threadutil, version
20 from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
21 import offlineimap.accounts
22 from offlineimap.accounts import SyncableAccount
23 from offlineimap.ui import UIBase
24 import re, os, os.path, offlineimap, sys
25 from ConfigParser import ConfigParser
26 from threading import *
27
28 def syncaccount(threads, config, accountname):
29 account = SyncableAccount(config, accountname)
30 thread = InstanceLimitedThread(instancename = 'ACCOUNTLIMIT',
31 target = account.syncrunner,
32 name = "Account sync %s" % accountname)
33 thread.setDaemon(1)
34 thread.start()
35 threads.add(thread)
36
37 def syncitall(accounts, config):
38 currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
39 ui = UIBase.getglobalui()
40 threads = threadutil.threadlist()
41 mbnames.init(config, accounts)
42 for accountname in accounts:
43 syncaccount(threads, config, accountname)
44 # Wait for the threads to finish.
45 threads.reset()