offlineimap rev 529
"Automatic Subversion Change Mailer" <[email protected]> Sun, 27 Jul 2003 17:03:36 -0500 (CDT)
| Newsgroups | gmane.mail.imap.offlineimap.subversion |
|---|---|
| Message-ID | <[email protected]> |
You are receiving this message because
all commits get sent to this address.
Author: jgoerzen
Date: 2003-07-27 17:03:25 -0500 (Sun, 27 Jul 2003)
New Revision: 529
Modified:
offlineimap/branches/twisted/offlineimap/accounts.py
offlineimap/branches/twisted/offlineimap/folder/Base.py
offlineimap/branches/twisted/offlineimap/folder/IMAP.py
offlineimap/branches/twisted/offlineimap/folder/UIDMaps.py
offlineimap/branches/twisted/offlineimap/imapserver.py
offlineimap/branches/twisted/offlineimap/imaputil.py
offlineimap/branches/twisted/offlineimap/init.py
offlineimap/branches/twisted/offlineimap/repository/IMAP.py
offlineimap/branches/twisted/offlineimap/repository/Maildir.py
offlineimap/branches/twisted/offlineimap/ui/Blinkenlights.py
offlineimap/branches/twisted/offlineimap/ui/Curses.py
offlineimap/branches/twisted/offlineimap/ui/Tk.py
offlineimap/branches/twisted/offlineimap/ui/UIBase.py
Log:
Many fixes towards running Twistedly:
* Removed imports of threadutil and imaplib
* Started to remove calls to imaputil functions
* Removed some of those functions from imaputil
* Make Maildir stuff return Deferreds to.
* General testing to see how far we can get.
Diff:
Modified: offlineimap/branches/twisted/offlineimap/accounts.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/accounts.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/accounts.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from offlineimap import threadutil, mbnames, CustomConfig
+from offlineimap import mbnames, CustomConfig
import offlineimap.repository.Base, offlineimap.repository.LocalStatus
from offlineimap.ui import UIBase
import os
@@ -144,13 +144,13 @@
d.addCallback(self.sync_runfolders)
def sync_getfolders(self, d):
- return remoterepos.getfolders()
+ return self.remoterepos.getfolders()
def sync_runfolders(self, remotefolders):
- dl = defer.DeferredList()
+ dl = defer.DeferredList([])
for remotefolder in remotefolders:
- sf = SyncFolder(self.name, remoterepos, remotefolder, localrepos,
- statusrepos)
+ sf = SyncFolder(self.name, self.remoterepos, remotefolder,
+ self.localrepos, self.statusrepos)
d = sf.start()
dl.addDeferred(d)
dl.addCallback(self.sync_finish)
@@ -175,9 +175,10 @@
def start(self):
self.ui.registerthread(self.accountname)
- d = localrepos.\
- getfolder(remotefolder.getvisiblename().\
- replace(remoterepos.getsep(), localrepos.getsep()))
+ d = self.localrepos.\
+ getfolder(self.remotefolder.getvisiblename().\
+ replace(self.remoterepos.getsep(),
+ self.localrepos.getsep()))
d.addCallback(self.local_cache)
d.addCallback(self.status_load)
d.addCallback(self.status_cache)
Modified: offlineimap/branches/twisted/offlineimap/folder/Base.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/folder/Base.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/folder/Base.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -17,8 +17,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from threading import *
-from offlineimap import threadutil
-from offlineimap.threadutil import InstanceLimitedThread
from offlineimap.ui import UIBase
import os.path, re
Modified: offlineimap/branches/twisted/offlineimap/folder/IMAP.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/folder/IMAP.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/folder/IMAP.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -17,7 +17,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from Base import BaseFolder
-from offlineimap import imaputil, imaplib
+from offlineimap import imaputil
from offlineimap.ui import UIBase
import rfc822, time, string, random, binascii, re
from StringIO import StringIO
@@ -28,7 +28,7 @@
def __init__(self, imapserver, name, visiblename, accountname, repository):
self.config = imapserver.config
self.expunge = repository.getexpunge()
- self.name = imaputil.dequote(name)
+ self.name = name
self.root = None # imapserver.root
self.sep = imapserver.delim
self.imapserver = imapserver
Modified: offlineimap/branches/twisted/offlineimap/folder/UIDMaps.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/folder/UIDMaps.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/folder/UIDMaps.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -17,8 +17,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from threading import *
-from offlineimap import threadutil
-from offlineimap.threadutil import InstanceLimitedThread
from offlineimap.ui import UIBase
from IMAP import IMAPFolder
import os.path, re
Modified: offlineimap/branches/twisted/offlineimap/imapserver.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/imapserver.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/imapserver.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -52,7 +52,7 @@
def __init__(self, config, reposname,
username = None, password = None, hostname = None,
port = None, ssl = 1, maxconnections = 1, tunnel = None,
- reference = '""'):
+ reference = ''):
self.reposname = reposname
self.config = config
self.username = username
@@ -122,9 +122,31 @@
'Attempting plain authentication')
print "imapobj is", imapobj
d = imapobj.login(self.username, self.getpassword())
+ d.addErrback(self.plainautherror, imapobj)
+ print "reference is", self.reference
+ d.addCallback(self.listcallback, self.reference, '')
+ d.addCallback(self.setdelim)
d.addCallback(self.handOverConnection)
- d.addErrback(self.plainautherror, (imapobj,))
+
+ def listcallback(self, discarded, reference, path):
+ return self.imapobj.list(reference, path)
+
+ def setdelim(self, listres, triedasterisk = 0):
+ if self.delim == None:
+ if not len(listres):
+ # Some buggy IMAP servers do not respond well to LIST "" ""
+ # Work around them.
+ #
+ # We return a deferred that has this own function as the
+ # callback. That way, when it gets added to the chain up
+ # above, it'll all work out properly.
+ d = imapobj.list(self.reference, '*')
+ d.addCallback(self.setdelim, (1,))
+ return d
+ print "listres is", listres
+ self.delim, self.root = listres[0][1:]
+
def plainautherror(self, error, imapobj):
UIBase.getglobalui().warn(str(error))
self.plainauth(imapobj)
@@ -162,6 +184,7 @@
def connectionMade(self, protocol):
print "This is IMAPServer.connectionMade; handing over to plainauth"
self.imapobj = protocol
+ print "Connectionmade: imapobj is", self.imapobj
self.plainauth(protocol)
def handOverConnection(self, d = None):
@@ -227,16 +250,6 @@
self.passworderror = str(val)
self.password = None
- if self.delim == None:
- listres = imapobj.list(self.reference, '""')[1]
- if listres == [None] or listres == None:
- # Some buggy IMAP servers do not respond well to LIST "" ""
- # Work around them.
- listres = imapobj.list(self.reference, '"*"')[1]
- self.delim, self.root = \
- imaputil.imapsplit(listres[0])[1:]
- self.delim = imaputil.dequote(self.delim)
- self.root = imaputil.dequote(self.root)
self.connectionlock.acquire()
self.assignedconnections.append(imapobj)
Modified: offlineimap/branches/twisted/offlineimap/imaputil.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/imaputil.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/imaputil.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -34,25 +34,6 @@
d.callback(val)
return d
-def dequote(string):
- """Takes a string which may or may not be quoted and returns it, unquoted.
- This function does NOT consider parenthised lists to be quoted.
- """
-
- debug("dequote() called with input:", string)
- if not (string[0] == '"' and string[-1] == '"'):
- return string
- string = string[1:-1] # Strip off quotes.
- string = string.replace('\\"', '"')
- string = string.replace('\\\\', '\\')
- debug("dequote() returning:", string)
- return string
-
-def flagsplit(string):
- if string[0] != '(' or string[-1] != ')':
- raise ValueError, "Passed string '%s' is not a flag list" % string
- return imapsplit(string[1:-1])
-
def options2hash(list):
debug("options2hash called with input:", list)
retval = {}
Modified: offlineimap/branches/twisted/offlineimap/init.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/init.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/init.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -16,9 +16,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from offlineimap import imaplib, imapserver, repository, folder, mbnames, threadutil, version, syncmaster, accounts
+from offlineimap import imapserver, repository, folder, mbnames, version, syncmaster, accounts
from offlineimap.localeval import LocalEval
-from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
from offlineimap.ui import UIBase
import re, os, os.path, offlineimap, sys
from offlineimap.CustomConfig import CustomConfigParser
@@ -90,7 +89,8 @@
for debugtype in options['-d'].split(','):
ui.add_debug(debugtype.strip())
if debugtype == 'imap':
- imaplib.Debug = 5
+ pass
+ #imaplib.Debug = 5
if debugtype == 'thread':
threading._VERBOSE = 1
Modified: offlineimap/branches/twisted/offlineimap/repository/IMAP.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/repository/IMAP.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/repository/IMAP.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -19,7 +19,6 @@
from Base import BaseRepository
from offlineimap import folder, imaputil, imapserver
from offlineimap.folder.UIDMaps import MappedIMAPFolder
-from offlineimap.threadutil import ExitNotifyThread
import re, types, os
from threading import *
@@ -100,7 +99,7 @@
return self.getconf('preauthtunnel', None)
def getreference(self):
- return self.getconf('reference', '""')
+ return self.getconf('reference', '')
def getmaxconnections(self):
return self.getconfint('maxconnections', 1)
Modified: offlineimap/branches/twisted/offlineimap/repository/Maildir.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/repository/Maildir.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/repository/Maildir.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -18,6 +18,7 @@
from Base import BaseRepository
from offlineimap import folder, imaputil
+from offlineimap.imaputil import rd
from offlineimap.ui import UIBase
from mailbox import Maildir
import os
@@ -142,5 +143,5 @@
def getfolders(self):
if self.folders == None:
self.folders = self._getfolders_scandir(self.root)
- return self.folders
+ return rd(self.folders)
Modified: offlineimap/branches/twisted/offlineimap/ui/Blinkenlights.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/ui/Blinkenlights.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/ui/Blinkenlights.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -19,7 +19,7 @@
from threading import *
from offlineimap.ui.UIBase import UIBase
import thread
-from offlineimap.threadutil import MultiLock
+#from offlineimap.threadutil import MultiLock
class BlinkenBase:
"""This is a mix-in class that should be mixed in with either UIBase
Modified: offlineimap/branches/twisted/offlineimap/ui/Curses.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/ui/Curses.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/ui/Curses.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -20,9 +20,9 @@
from UIBase import UIBase
from threading import *
import thread, time, sys, os, signal, time
-from offlineimap import version, threadutil
-from offlineimap.threadutil import MultiLock
+from offlineimap import version
+
import curses, curses.panel, curses.textpad, curses.wrapper
acctkeys = '1234567890abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-=;/.,'
Modified: offlineimap/branches/twisted/offlineimap/ui/Tk.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/ui/Tk.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/ui/Tk.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -24,7 +24,7 @@
import thread, traceback, time, threading
from StringIO import StringIO
from ScrolledText import ScrolledText
-from offlineimap import threadutil, version
+from offlineimap import version
from Queue import Queue
from UIBase import UIBase
from offlineimap.ui.Blinkenlights import BlinkenBase
Modified: offlineimap/branches/twisted/offlineimap/ui/UIBase.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/ui/UIBase.py 2003-07-27 20:57:59 UTC (rev 528)
+++ offlineimap/branches/twisted/offlineimap/ui/UIBase.py 2003-07-27 22:03:25 UTC (rev 529)
@@ -81,9 +81,10 @@
"""Provides a hint to UIs about which account this particular
thread is processing."""
if s.threadaccounts.has_key(threading.currentThread()):
- raise ValueError, "Thread %s already registered (old %s, new %s)" %\
- (threading.currentThread().getName(),
- s.getthreadaccount(s), account)
+ pass
+ #raise ValueError, "Thread %s already registered (old %s, new %s)" %\
+ # (threading.currentThread().getName(),
+ # s.getthreadaccount(s), account)
s.threadaccounts[threading.currentThread()] = account
def unregisterthread(s, thr):