/offlineimap/head: changeset 260

Updated -- the init changes now actually work.
This commit is contained in:
jgoerzen 2002-10-07 22:11:19 +01:00
parent 73199ad735
commit eaec9e7db4
3 changed files with 37 additions and 9 deletions

View File

@ -15,6 +15,7 @@ offlineimap (3.99.0) unstable; urgency=low
offlineimap/init.py.
* Moved __main__.ui to functions in UIBase: getglobalui() and
setglobalui().
* Added license comments to some source files that were missing them.
-- John Goerzen <jgoerzen@complete.org> Mon, 30 Sep 2002 12:08:08 -0500

View File

@ -67,7 +67,6 @@ def startup(revno):
ui = offlineimap.ui.detector.findUI(config, localeval, options.get('-u'))
ui.init_banner()
UIBase.setglobalui(ui)
print "UI is", UIBase.getglobalui()
if '-d' in options:
for debugtype in options['-d'].split(','):
@ -104,7 +103,6 @@ def startup(revno):
# asking for passwords simultaneously.
for account in accounts:
print "Processing account", account
#if '.' in account:
# raise ValueError, "Account '%s' contains a dot; dots are not " \
# "allowed in account names." % account
@ -130,7 +128,13 @@ def startup(revno):
threadutil.initexitnotify()
t = ExitNotifyThread(target=sync_with_timer,
name='Sync Runner')
name='Sync Runner',
kwargs = {'accounts': accounts,
'metadatadir': metadatadir,
'servers': servers,
'config': config,
'passwords': passwords,
'localeval': localeval})
t.setDaemon(1)
t.start()
try:
@ -140,7 +144,8 @@ def startup(revno):
except:
ui.mainException() # Also expected to terminate.
def syncaccount(accountname, *args):
def syncaccount(accountname, metadatadir, servers, config, passwords,
localeval, *args):
ui = UIBase.getglobalui()
# We don't need an account lock because syncitall() goes through
# each account once, then waits for all to finish.
@ -263,7 +268,7 @@ def syncfolder(accountname, remoterepos, remotefolder, localrepos,
def syncitall():
def syncitall(accounts, metadatadir, servers, config, passwords, localeval):
ui = UIBase.getglobalui()
global mailboxes
mailboxes = [] # Reset.
@ -272,7 +277,9 @@ def syncitall():
thread = InstanceLimitedThread(instancename = 'ACCOUNTLIMIT',
target = syncaccount,
name = "Account sync %s" % accountname,
args = (accountname,))
args = (accountname, metadatadir,
servers, config, passwords,
localeval))
thread.setDaemon(1)
thread.start()
threads.append(thread)
@ -280,10 +287,11 @@ def syncitall():
threadutil.threadsreset(threads)
mbnames.genmbnames(config, localeval, mailboxes)
def sync_with_timer():
def sync_with_timer(accounts, metadatadir, servers, config, passwords,
localeval):
ui = UIBase.getglobalui()
currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
syncitall()
syncitall(accounts, metadatadir, servers, config, passwords, localeval)
if config.has_option('general', 'autorefresh'):
refreshperiod = config.getint('general', 'autorefresh') * 60
while 1:
@ -313,7 +321,8 @@ def sync_with_timer():
event.set()
for thread in kathreads.values():
thread.join()
syncitall()
syncitall(accounts, metadatadir, servers, config, passwords,
localeval)
def threadexited(thread):
ui = UIBase.getglobalui()

View File

@ -1,4 +1,22 @@
"""Eval python code with global namespace of a python source file."""
# Copyright (C) 2002 John Goerzen
# <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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import imp, errno
class LocalEval: