2002-10-07 23:17:13 +02:00
|
|
|
# OfflineIMAP synchronization master code
|
2003-04-29 02:04:22 +02:00
|
|
|
# Copyright (C) 2002 John Goerzen
|
2002-10-07 23:17:13 +02:00
|
|
|
# <jgoerzen@complete.org>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2003-04-16 21:23:45 +02:00
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
2002-10-07 23:17:13 +02:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2006-08-12 06:15:55 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-10-07 23:17:13 +02:00
|
|
|
|
|
|
|
from offlineimap import imaplib, imapserver, repository, folder, mbnames, threadutil, version
|
|
|
|
from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
|
2003-01-04 05:57:46 +01:00
|
|
|
import offlineimap.accounts
|
|
|
|
from offlineimap.accounts import SyncableAccount
|
2002-10-07 23:17:13 +02:00
|
|
|
from offlineimap.ui import UIBase
|
|
|
|
import re, os, os.path, offlineimap, sys
|
|
|
|
from ConfigParser import ConfigParser
|
|
|
|
from threading import *
|
|
|
|
|
2003-04-29 02:04:22 +02:00
|
|
|
def syncaccount(threads, config, accountname):
|
2003-01-04 05:57:46 +01:00
|
|
|
account = SyncableAccount(config, accountname)
|
|
|
|
thread = InstanceLimitedThread(instancename = 'ACCOUNTLIMIT',
|
|
|
|
target = account.syncrunner,
|
|
|
|
name = "Account sync %s" % accountname)
|
|
|
|
thread.setDaemon(1)
|
|
|
|
thread.start()
|
2003-04-29 02:04:22 +02:00
|
|
|
threads.add(thread)
|
2002-10-07 23:17:13 +02:00
|
|
|
|
2003-01-04 05:57:46 +01:00
|
|
|
def syncitall(accounts, config):
|
2003-04-29 02:04:22 +02:00
|
|
|
currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
|
2002-10-07 23:17:13 +02:00
|
|
|
ui = UIBase.getglobalui()
|
2003-04-29 02:04:22 +02:00
|
|
|
threads = threadutil.threadlist()
|
2003-01-06 21:40:23 +01:00
|
|
|
mbnames.init(config, accounts)
|
2002-10-07 23:17:13 +02:00
|
|
|
for accountname in accounts:
|
2003-04-29 02:04:22 +02:00
|
|
|
syncaccount(threads, config, accountname)
|
|
|
|
# Wait for the threads to finish.
|
|
|
|
threads.reset()
|