/head: changeset 20
Fixed several bugs in imaplib, particularly with regard to read()
This commit is contained in:
parent
036b3d10b6
commit
9eff85dd0c
@ -54,6 +54,7 @@ class IMAPFolder(BaseFolder):
|
|||||||
return self.messagelist
|
return self.messagelist
|
||||||
|
|
||||||
def getmessage(self, uid):
|
def getmessage(self, uid):
|
||||||
|
print "***************** GETMESSAGE %d" % uid
|
||||||
assert(self.imapobj.select(self.getfullname())[0] == 'OK')
|
assert(self.imapobj.select(self.getfullname())[0] == 'OK')
|
||||||
return self.imapobj.uid('fetch', '%d' % uid, '(RFC822)')[1][0][1]
|
return self.imapobj.uid('fetch', '%d' % uid, '(RFC822)')[1][0][1]
|
||||||
|
|
||||||
|
@ -76,14 +76,14 @@ class MaildirFolder(BaseFolder):
|
|||||||
nouidcounter -= 1
|
nouidcounter -= 1
|
||||||
else:
|
else:
|
||||||
uid = long(uidmatch.group(1))
|
uid = long(uidmatch.group(1))
|
||||||
flagmatch = re.search(':.*2,([A-Z]+)')
|
flagmatch = re.search(':.*2,([A-Z]+)', messagename)
|
||||||
flags = []
|
flags = []
|
||||||
if flagmatch:
|
if flagmatch:
|
||||||
flags = [f for x in flagmatch.group(1)]
|
flags = [x for x in flagmatch.group(1)]
|
||||||
flags.sort()
|
flags.sort()
|
||||||
self.messagelist[uid] = {'uid': uid,
|
self.messagelist[uid] = {'uid': uid,
|
||||||
'flags': flags,
|
'flags': flags,
|
||||||
'filename': messagename}
|
'filename': file}
|
||||||
|
|
||||||
def getmessagelist(self):
|
def getmessagelist(self):
|
||||||
return self.messagelist
|
return self.messagelist
|
||||||
|
@ -222,8 +222,10 @@ class IMAP4:
|
|||||||
|
|
||||||
def read(self, size):
|
def read(self, size):
|
||||||
"""Read 'size' bytes from remote."""
|
"""Read 'size' bytes from remote."""
|
||||||
return self.file.read(size)
|
retval = ''
|
||||||
|
while len(retval) < size:
|
||||||
|
retval += self.file.read(size - len(retval))
|
||||||
|
return retval
|
||||||
|
|
||||||
def readline(self):
|
def readline(self):
|
||||||
"""Read line from remote."""
|
"""Read line from remote."""
|
||||||
@ -858,6 +860,7 @@ class IMAP4:
|
|||||||
if self.debug >= 4:
|
if self.debug >= 4:
|
||||||
self._mesg('read literal size %s' % size)
|
self._mesg('read literal size %s' % size)
|
||||||
data = self.read(size)
|
data = self.read(size)
|
||||||
|
print "Got data size %d" % len(data)
|
||||||
|
|
||||||
# Store response with literal as tuple
|
# Store response with literal as tuple
|
||||||
|
|
||||||
@ -1056,7 +1059,10 @@ class IMAP4_SSL(IMAP4):
|
|||||||
|
|
||||||
def read(self, size):
|
def read(self, size):
|
||||||
"""Read 'size' bytes from remote."""
|
"""Read 'size' bytes from remote."""
|
||||||
return self.sslobj.read(size)
|
retval = ''
|
||||||
|
while len(retval) < size:
|
||||||
|
retval += self.sslobj.read(size - len(retval))
|
||||||
|
return retval
|
||||||
|
|
||||||
|
|
||||||
def readline(self):
|
def readline(self):
|
||||||
|
@ -32,6 +32,7 @@ class IMAPServer:
|
|||||||
self.port = 993
|
self.port = 993
|
||||||
else:
|
else:
|
||||||
self.port = 143
|
self.port = 143
|
||||||
|
self.imapobj = None
|
||||||
|
|
||||||
def getdelim(self):
|
def getdelim(self):
|
||||||
"""Returns this server's folder delimiter. Can only be called
|
"""Returns this server's folder delimiter. Can only be called
|
||||||
@ -47,6 +48,8 @@ class IMAPServer:
|
|||||||
"""Opens a connection to the server and returns an appropriate
|
"""Opens a connection to the server and returns an appropriate
|
||||||
object."""
|
object."""
|
||||||
|
|
||||||
|
if self.imapobj != None:
|
||||||
|
return self.imapobj
|
||||||
imapobj = None
|
imapobj = None
|
||||||
if self.usessl:
|
if self.usessl:
|
||||||
imapobj = imaplib.IMAP4_SSL(self.hostname, self.port)
|
imapobj = imaplib.IMAP4_SSL(self.hostname, self.port)
|
||||||
@ -61,6 +64,7 @@ class IMAPServer:
|
|||||||
self.delim = imaputil.dequote(self.delim)
|
self.delim = imaputil.dequote(self.delim)
|
||||||
self.root = imaputil.dequote(self.root)
|
self.root = imaputil.dequote(self.root)
|
||||||
|
|
||||||
|
self.imapobj = imapobj
|
||||||
return imapobj
|
return imapobj
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user