diff options
| -rw-r--r-- | src/mailman/Archiver/Archiver.py | 6 | ||||
| -rw-r--r-- | src/mailman/Archiver/HyperArch.py | 1 | ||||
| -rw-r--r-- | src/mailman/Archiver/pipermail.py | 18 | ||||
| -rw-r--r-- | src/mailman/archiving/pipermail.py | 19 | ||||
| -rw-r--r-- | src/mailman/attic/Mailbox.py (renamed from src/mailman/Mailbox.py) | 0 |
5 files changed, 25 insertions, 19 deletions
diff --git a/src/mailman/Archiver/Archiver.py b/src/mailman/Archiver/Archiver.py index d0b9fbd1b..1a4e32623 100644 --- a/src/mailman/Archiver/Archiver.py +++ b/src/mailman/Archiver/Archiver.py @@ -26,11 +26,11 @@ archival. import os import errno import logging +import mailbox from cStringIO import StringIO from string import Template -from mailman import Mailbox from mailman import Utils from mailman.config import config @@ -140,7 +140,7 @@ class Archiver: """Open (creating, if necessary) the named archive file.""" omask = os.umask(002) try: - return Mailbox.Mailbox(open(afn, 'a+')) + return mailbox.mbox(afn, 'a+') finally: os.umask(omask) @@ -153,7 +153,7 @@ class Archiver: try: afn = self.ArchiveFileName() mbox = self.__archive_file(afn) - mbox.AppendMessage(post) + mbox.add(post) mbox.fp.close() except IOError, msg: log.error('Archive file access failure:\n\t%s %s', afn, msg) diff --git a/src/mailman/Archiver/HyperArch.py b/src/mailman/Archiver/HyperArch.py index d9477cc3f..26f32bdd0 100644 --- a/src/mailman/Archiver/HyperArch.py +++ b/src/mailman/Archiver/HyperArch.py @@ -48,7 +48,6 @@ from mailman import Utils from mailman import i18n from mailman.Archiver import HyperDatabase from mailman.Archiver import pipermail -from mailman.Mailbox import ArchiverMailbox from mailman.config import config diff --git a/src/mailman/Archiver/pipermail.py b/src/mailman/Archiver/pipermail.py index 19bc05c3f..e6c87baa0 100644 --- a/src/mailman/Archiver/pipermail.py +++ b/src/mailman/Archiver/pipermail.py @@ -17,7 +17,6 @@ __version__ = '0.11 (Mailman edition)' VERSION = __version__ CACHESIZE = 100 # Number of slots in the cache -from mailman.Mailbox import ArchiverMailbox from mailman.core import errors from mailman.i18n import _ @@ -540,30 +539,29 @@ class T: def _makeArticle(self, msg, sequence): return Article(msg, sequence) - def processUnixMailbox(self, input, start=None, end=None): - mbox = ArchiverMailbox(input, self.maillist) + def processUnixMailbox(self, path, start=None, end=None): + mbox = iter(mailbox.mbox(path)) if start is None: start = 0 counter = 0 while counter < start: try: - m = mbox.next() + m = next(mbox) except errors.DiscardMessage: continue if m is None: return counter += 1 - while 1: + while True: try: - pos = input.tell() - m = mbox.next() + m = next(mbox) + except StopIteration: + break except errors.DiscardMessage: continue except Exception: - log.error('uncaught archiver exception at filepos: %s', pos) + log.error('uncaught archiver exception') raise - if m is None: - break if m == '': # It was an unparseable message continue diff --git a/src/mailman/archiving/pipermail.py b/src/mailman/archiving/pipermail.py index 377f4ab53..42a89ea55 100644 --- a/src/mailman/archiving/pipermail.py +++ b/src/mailman/archiving/pipermail.py @@ -26,6 +26,8 @@ __all__ = [ import os +import mailbox +import tempfile from cStringIO import StringIO from zope.interface import implements @@ -111,11 +113,18 @@ class Pipermail: @staticmethod def archive_message(mlist, message): """See `IArchiver`.""" - text = str(message) - fileobj = StringIO(text) + fd, path = tempfile.mkstemp('.mbox') + os.close(fd) + try: + mbox = mailbox.mbox(path, create=True) + mbox.add(message) + finally: + mbox.close() h = HyperArchive(IPipermailMailingList(mlist)) - h.processUnixMailbox(fileobj) - h.close() - fileobj.close() + try: + h.processUnixMailbox(path) + finally: + h.close() + os.remove(path) # There's no good way to know the url for the archived message. return None diff --git a/src/mailman/Mailbox.py b/src/mailman/attic/Mailbox.py index 3a2f079c4..3a2f079c4 100644 --- a/src/mailman/Mailbox.py +++ b/src/mailman/attic/Mailbox.py |
