diff options
62 files changed, 116 insertions, 218 deletions
diff --git a/buildout.cfg b/buildout.cfg index f502d24e9..d345bf142 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -5,7 +5,7 @@ parts = test unzip = true # bzr branch lp:~barry/lazr.config/megamerge -develop = . /Users/barry/projects/lazr/megamerge +develop = . /home/barry/projects/lazr/megamerge [interpreter] recipe = zc.recipe.egg diff --git a/mailman/Archiver/Archiver.py b/mailman/Archiver/Archiver.py index 74e80a742..d0b9fbd1b 100644 --- a/mailman/Archiver/Archiver.py +++ b/mailman/Archiver/Archiver.py @@ -24,10 +24,8 @@ archival. """ import os -import re import errno import logging -import traceback from cStringIO import StringIO from string import Template @@ -35,7 +33,6 @@ from string import Template from mailman import Mailbox from mailman import Utils from mailman.config import config -from mailman.i18n import _ log = logging.getLogger('mailman.error') @@ -81,13 +78,14 @@ class Archiver: # the private directory, pointing directly to the private/listname # which has o+rx permissions. Private archives do not have the # symbolic links. - archdir = archive_dir(self.fqdn_listname) + archdir = self.archive_dir(self.fqdn_listname) omask = os.umask(0) try: try: os.mkdir(archdir+'.mbox', 02775) except OSError, e: - if e.errno <> errno.EEXIST: raise + if e.errno <> errno.EEXIST: + raise # We also create an empty pipermail archive directory into # which we'll drop an empty index.html file into. This is so # that lists that have not yet received a posting have @@ -95,7 +93,8 @@ class Archiver: try: os.mkdir(archdir, 02775) except OSError, e: - if e.errno <> errno.EEXIST: raise + if e.errno <> errno.EEXIST: + raise # See if there's an index.html file there already and if not, # write in the empty archive notice. indexfile = os.path.join(archdir, 'index.html') @@ -103,7 +102,8 @@ class Archiver: try: fp = open(indexfile) except IOError, e: - if e.errno <> errno.ENOENT: raise + if e.errno <> errno.ENOENT: + raise omask = os.umask(002) try: fp = open(indexfile, 'w') @@ -163,7 +163,6 @@ class Archiver: cmd = Template(ar).safe_substitute( listname=self.fqdn_listname, hostname=self.host_name) - cmd = ar % d extarch = os.popen(cmd, 'w') extarch.write(txt) status = extarch.close() diff --git a/mailman/Bouncers/Caiwireless.py b/mailman/Bouncers/Caiwireless.py index 8c26c7b97..3bf03cc62 100644 --- a/mailman/Bouncers/Caiwireless.py +++ b/mailman/Bouncers/Caiwireless.py @@ -19,7 +19,6 @@ import re import email -from cStringIO import StringIO tcre = re.compile(r'the following recipients did not receive this message:', re.IGNORECASE) diff --git a/mailman/Bouncers/DSN.py b/mailman/Bouncers/DSN.py index 425eee6fb..37e5bcb83 100644 --- a/mailman/Bouncers/DSN.py +++ b/mailman/Bouncers/DSN.py @@ -21,7 +21,6 @@ RFC 3464 obsoletes 1894 which was the old DSN standard. This module has not been audited for differences between the two. """ -from cStringIO import StringIO from email.Iterators import typed_subpart_iterator from email.Utils import parseaddr diff --git a/mailman/Mailbox.py b/mailman/Mailbox.py index 14fed7402..a56aeab05 100644 --- a/mailman/Mailbox.py +++ b/mailman/Mailbox.py @@ -24,7 +24,6 @@ import mailbox from email.Errors import MessageParseError from email.Generator import Generator -from email.Parser import Parser from mailman import Defaults from mailman.Message import Message diff --git a/mailman/Utils.py b/mailman/Utils.py index 5ad940d58..56f186a17 100644 --- a/mailman/Utils.py +++ b/mailman/Utils.py @@ -30,7 +30,6 @@ import errno import base64 import random import logging -import urlparse import htmlentitydefs import email.Header import email.Iterators @@ -497,7 +496,8 @@ def findtext(templatefile, dict=None, raw=False, lang=None, mlist=None): fp = open(filename) raise OuterExit except IOError, e: - if e.errno <> errno.ENOENT: raise + if e.errno <> errno.ENOENT: + raise # Okay, it doesn't exist, keep looping fp = None except OuterExit: diff --git a/mailman/app/bounces.py b/mailman/app/bounces.py index 24daf9a88..704921f38 100644 --- a/mailman/app/bounces.py +++ b/mailman/app/bounces.py @@ -21,12 +21,10 @@ __all__ = [ 'bounce_message', ] -import re import logging from email.mime.message import MIMEMessage from email.mime.text import MIMEText -from email.utils import getaddresses from mailman import Message from mailman import Utils diff --git a/mailman/app/membership.py b/mailman/app/membership.py index aaab9555b..4d20be91e 100644 --- a/mailman/app/membership.py +++ b/mailman/app/membership.py @@ -32,8 +32,7 @@ from mailman import i18n from mailman.app.notifications import send_goodbye_message from mailman.config import config from mailman.core import errors -from mailman.interfaces.member import ( - AlreadySubscribedError, DeliveryMode, MemberRole) +from mailman.interfaces.member import AlreadySubscribedError, MemberRole _ = i18n._ diff --git a/mailman/archiving/pipermail.py b/mailman/archiving/pipermail.py index d51b80738..d4969b9f6 100644 --- a/mailman/archiving/pipermail.py +++ b/mailman/archiving/pipermail.py @@ -30,7 +30,6 @@ from string import Template from zope.interface import implements from zope.interface.interface import adapter_hooks -from mailman import Defaults from mailman.Utils import makedirs from mailman.config import config from mailman.interfaces.archiver import IArchiver, IPipermailMailingList diff --git a/mailman/bin/export.py b/mailman/bin/export.py index f0bd28da0..d1992b4b4 100644 --- a/mailman/bin/export.py +++ b/mailman/bin/export.py @@ -17,11 +17,7 @@ """Export an XML representation of a mailing list.""" -import os -import re -import sha import sys -import base64 import codecs import datetime import optparse @@ -260,7 +256,7 @@ class XMLDumper(object): def parseargs(): - parser = optparse.OptionParser(version=Version.MAILMAN_VERSION, + parser = optparse.OptionParser(version=MAILMAN_VERSION, usage=_("""\ %prog [options] diff --git a/mailman/bin/genaliases.py b/mailman/bin/genaliases.py index 3fbef0f88..786069417 100644 --- a/mailman/bin/genaliases.py +++ b/mailman/bin/genaliases.py @@ -21,13 +21,9 @@ __all__ = [ ] -import sys - -from mailman.config import config from mailman.core.plugins import get_plugin from mailman.i18n import _ from mailman.options import Options -from mailman.version import MAILMAN_VERSION diff --git a/mailman/bin/list_lists.py b/mailman/bin/list_lists.py index d2aed3c01..ea1640910 100644 --- a/mailman/bin/list_lists.py +++ b/mailman/bin/list_lists.py @@ -15,7 +15,6 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. -from mailman import Defaults from mailman.config import config from mailman.i18n import _ from mailman.options import Options @@ -23,7 +22,7 @@ from mailman.options import Options class ScriptOptions(Options): - usage=_("""\ + usage = _("""\ %prog [options] List all mailing lists.""") diff --git a/mailman/bin/list_members.py b/mailman/bin/list_members.py index b969eecf7..443f764d6 100644 --- a/mailman/bin/list_members.py +++ b/mailman/bin/list_members.py @@ -41,7 +41,7 @@ KINDCHOICES = set(('mime', 'plain', 'any')) class ScriptOptions(SingleMailingListOptions): - usage=_("""\ + usage = _("""\ %prog [options] List all the members of a mailing list. Note that with the options below, if @@ -143,7 +143,7 @@ def main(): fqdn_listname = options.options.listname if options.options.output: try: - fp = open(opts.output, 'w') + fp = open(options.output, 'w') except IOError: options.parser.error( _('Could not open file for writing: $options.options.output')) diff --git a/mailman/bin/qrunner.py b/mailman/bin/qrunner.py index eeb5c286b..62e943aad 100644 --- a/mailman/bin/qrunner.py +++ b/mailman/bin/qrunner.py @@ -55,7 +55,7 @@ def r_callback(option, opt, value, parser): class ScriptOptions(Options): - usage=_("""\ + usage = _("""\ Run one or more qrunners, once or repeatedly. Each named runner class is run in round-robin fashion. In other words, the diff --git a/mailman/bin/remove_list.py b/mailman/bin/remove_list.py index 57e41c3b3..05211b200 100644 --- a/mailman/bin/remove_list.py +++ b/mailman/bin/remove_list.py @@ -15,11 +15,8 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. -import os import sys -import shutil -from mailman import Utils from mailman.app.lifecycle import remove_list from mailman.config import config from mailman.i18n import _ @@ -28,7 +25,7 @@ from mailman.options import MultipleMailingListOptions class ScriptOptions(MultipleMailingListOptions): - usage=_("""\ + usage = _("""\ %prog [options] Remove the components of a mailing list with impunity - beware! diff --git a/mailman/bin/show_qfiles.py b/mailman/bin/show_qfiles.py index 08697a54e..3f27ae271 100644 --- a/mailman/bin/show_qfiles.py +++ b/mailman/bin/show_qfiles.py @@ -26,7 +26,7 @@ from mailman.version import MAILMAN_VERSION def parseargs(): - parser = optparse.OptionParser(version=Version.MAILMAN_VERSION, + parser = optparse.OptionParser(version=MAILMAN_VERSION, usage=_("""\ %%prog [options] qfiles ... diff --git a/mailman/bin/unshunt.py b/mailman/bin/unshunt.py index 97369ab17..fc889377c 100644 --- a/mailman/bin/unshunt.py +++ b/mailman/bin/unshunt.py @@ -25,7 +25,6 @@ import sys from mailman.config import config from mailman.i18n import _ -from mailman.version import MAILMAN_VERSION from mailman.options import Options diff --git a/mailman/bin/withlist.py b/mailman/bin/withlist.py index f180f5525..8f2d8a2b5 100644 --- a/mailman/bin/withlist.py +++ b/mailman/bin/withlist.py @@ -151,7 +151,7 @@ the results.""")) def main(): - global LAST_MLIST, VERBOSE + global VERBOSE parser, opts, args = parseargs() config_file = (os.getenv('MAILMAN_CONFIG_FILE') diff --git a/mailman/commands/cmd_stop.py b/mailman/commands/cmd_stop.py deleted file mode 100644 index fc3df69fd..000000000 --- a/mailman/commands/cmd_stop.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2002-2009 by the Free Software Foundation, Inc. -# -# This file is part of GNU Mailman. -# -# GNU Mailman 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 3 of the License, or (at your option) -# any later version. -# -# GNU Mailman 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 -# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. - -"""stop is synonymous with the end command. -""" - -from mailman.Commands.cmd_end import process diff --git a/mailman/commands/join.py b/mailman/commands/join.py index 532b89a08..c14f3142b 100644 --- a/mailman/commands/join.py +++ b/mailman/commands/join.py @@ -24,11 +24,9 @@ __all__ = [ ] -from email.header import decode_header, make_header from email.utils import formataddr, parseaddr from zope.interface import implements -from mailman.Utils import MakeRandomPassword from mailman.config import config from mailman.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand diff --git a/mailman/core/errors.py b/mailman/core/errors.py index e83f32932..51803ae79 100644 --- a/mailman/core/errors.py +++ b/mailman/core/errors.py @@ -102,6 +102,7 @@ class SomeRecipientsFailed(HandlerError): class RejectMessage(HandlerError): """The message will be bounced back to the sender""" def __init__(self, notice=None): + super(RejectMessage, self).__init__() if notice is None: notice = _('Your message was rejected') if notice.endswith('\n\n'): @@ -136,6 +137,7 @@ class BadPasswordSchemeError(PasswordError): """A bad password scheme was given.""" def __init__(self, scheme_name='unknown'): + super(BadPasswordSchemeError, self).__init__() self.scheme_name = scheme_name def __str__(self): diff --git a/mailman/core/logging.py b/mailman/core/logging.py index d1f46f951..ce79761ca 100644 --- a/mailman/core/logging.py +++ b/mailman/core/logging.py @@ -30,7 +30,6 @@ import os import sys import codecs import logging -import ConfigParser from lazr.config import as_boolean, as_log_level diff --git a/mailman/core/rules.py b/mailman/core/rules.py index dec7eb792..e272846d3 100644 --- a/mailman/core/rules.py +++ b/mailman/core/rules.py @@ -23,7 +23,6 @@ __all__ = [ ] -from zope.interface import implements from zope.interface.verify import verifyObject from mailman.config import config diff --git a/mailman/core/styles.py b/mailman/core/styles.py index 11177e725..b375a743c 100644 --- a/mailman/core/styles.py +++ b/mailman/core/styles.py @@ -33,7 +33,6 @@ from zope.interface.verify import verifyObject from mailman import Defaults from mailman import Utils -from mailman.config import config from mailman.core.plugins import get_plugins from mailman.i18n import _ from mailman.interfaces import Action, NewsModeration diff --git a/mailman/database/member.py b/mailman/database/member.py index a8deb3171..66d215e4d 100644 --- a/mailman/database/member.py +++ b/mailman/database/member.py @@ -15,16 +15,19 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. +__metaclass__ = type +__all__ = [ + 'Member', + ] + from storm.locals import * from zope.interface import implements -from mailman.Utils import split_listname from mailman.config import config from mailman.constants import SystemDefaultPreferences from mailman.database.model import Model from mailman.database.types import Enum from mailman.interfaces.member import IMember -from mailman.interfaces.preferences import IPreferences diff --git a/mailman/database/message.py b/mailman/database/message.py index f74de3c55..c7ec6bcf6 100644 --- a/mailman/database/message.py +++ b/mailman/database/message.py @@ -15,6 +15,11 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. +__metaclass__ = type +__all__ = [ + 'Message', + ] + from storm.locals import * from zope.interface import implements @@ -36,6 +41,7 @@ class Message(Model): # This is a Messge-ID field representation, not a database row id. def __init__(self, message_id, message_id_hash, path): + super(Message, self).__init__() self.message_id = message_id self.message_id_hash = message_id_hash self.path = path diff --git a/mailman/database/model.py b/mailman/database/model.py index 598f537e8..9a83002bd 100644 --- a/mailman/database/model.py +++ b/mailman/database/model.py @@ -49,6 +49,6 @@ class ModelMeta(PropertyPublisherMeta): -class Model(object): +class Model: """Like Storm's `Storm` subclass, but with a bit extra.""" __metaclass__ = ModelMeta diff --git a/mailman/database/pending.py b/mailman/database/pending.py index 9b7094b8b..07e594253 100644 --- a/mailman/database/pending.py +++ b/mailman/database/pending.py @@ -17,6 +17,12 @@ """Implementations of the IPendable and IPending interfaces.""" +__metaclass__ = type +__all__ = [ + 'Pended', + 'Pendings', + ] + import sys import time import random @@ -56,6 +62,7 @@ class Pended(Model): implements(IPended) def __init__(self, token, expiration_date): + super(Pended, self).__init__() self.token = token self.expiration_date = expiration_date @@ -71,7 +78,7 @@ class UnpendedPendable(dict): -class Pendings(object): +class Pendings: """Implementation of the IPending interface.""" implements(IPendings) diff --git a/mailman/database/requests.py b/mailman/database/requests.py index 6e9828cf9..812c5a0ab 100644 --- a/mailman/database/requests.py +++ b/mailman/database/requests.py @@ -129,6 +129,7 @@ class _Request(Model): mailing_list = Reference(mailing_list_id, 'MailingList.id') def __init__(self, key, request_type, mailing_list, data_hash): + super(_Request, self).__init__() self.key = key self.request_type = request_type self.mailing_list = mailing_list diff --git a/mailman/database/roster.py b/mailman/database/roster.py index d0759e176..fcebfb7f0 100644 --- a/mailman/database/roster.py +++ b/mailman/database/roster.py @@ -39,7 +39,6 @@ from storm.locals import * from zope.interface import implements from mailman.config import config -from mailman.constants import SystemDefaultPreferences from mailman.database.address import Address from mailman.database.member import Member from mailman.interfaces.member import DeliveryMode, MemberRole diff --git a/mailman/database/types.py b/mailman/database/types.py index 26bdb0aff..17719c941 100644 --- a/mailman/database/types.py +++ b/mailman/database/types.py @@ -23,7 +23,7 @@ __all__ = [ import sys from storm.properties import SimpleProperty -from storm.variables import UnicodeVariable, Variable +from storm.variables import Variable diff --git a/mailman/database/user.py b/mailman/database/user.py index 1e2a7085d..ec428f0a2 100644 --- a/mailman/database/user.py +++ b/mailman/database/user.py @@ -15,7 +15,11 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. -from email.utils import formataddr +__metaclass__ = type +__all__ = [ + 'User', + ] + from storm.locals import * from zope.interface import implements diff --git a/mailman/database/usermanager.py b/mailman/database/usermanager.py index ea628c835..c30c40d12 100644 --- a/mailman/database/usermanager.py +++ b/mailman/database/usermanager.py @@ -17,7 +17,10 @@ """A user manager.""" -import os +__metaclass__ = type +__all__ = [ + 'UserManager', + ] from zope.interface import implements diff --git a/mailman/database/version.py b/mailman/database/version.py index 83e50b821..519c5438c 100644 --- a/mailman/database/version.py +++ b/mailman/database/version.py @@ -15,6 +15,11 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. +__metaclass__ = type +__all__ = [ + 'Version', + ] + from storm.locals import * from mailman.database.model import Model @@ -26,5 +31,6 @@ class Version(Model): version = Int() def __init__(self, component, version): + super(Version, self).__init__() self.component = component self.version = version diff --git a/mailman/i18n.py b/mailman/i18n.py index 374fee399..278199535 100644 --- a/mailman/i18n.py +++ b/mailman/i18n.py @@ -34,7 +34,6 @@ import string import gettext import mailman.messages -from mailman.config import config _translation = None _missing = object() @@ -157,7 +156,7 @@ def ctime(date): if isinstance(date, str): try: year, mon, day, hh, mm, ss, wday, ydat, dst = time.strptime(date) - if dst in (0,1): + if dst in (0, 1): tzname = time.tzname[dst] else: # MAS: No exception but dst = -1 so try diff --git a/mailman/interfaces/database.py b/mailman/interfaces/database.py index bf4aaa87c..27ab4bf83 100644 --- a/mailman/interfaces/database.py +++ b/mailman/interfaces/database.py @@ -23,6 +23,13 @@ setup.py file as an entry point in the 'mailman.database' group with the name Mailman's back end. """ +__metaclass__ = type +__all__ = [ + 'DatabaseError', + 'IDatabase', + 'SchemaVersionMismatchError', + ] + from zope.interface import Interface, Attribute from mailman.interfaces.errors import MailmanError @@ -38,6 +45,7 @@ class SchemaVersionMismatchError(DatabaseError): """The database schema version number did not match what was expected.""" def __init__(self, got): + super(SchemaVersionMismatchError, self).__init__() self._got = got def __str__(self): diff --git a/mailman/interfaces/member.py b/mailman/interfaces/member.py index 590ad1b9b..697117219 100644 --- a/mailman/interfaces/member.py +++ b/mailman/interfaces/member.py @@ -72,6 +72,7 @@ class AlreadySubscribedError(SubscriptionError): """The member is already subscribed to the mailing list with this role.""" def __init__(self, fqdn_listname, address, role): + super(AlreadySubscribedError, self).__init__() self._fqdn_listname = fqdn_listname self._address = address self._role = role diff --git a/mailman/interfaces/mta.py b/mailman/interfaces/mta.py index a8f55f961..5e647cfb2 100644 --- a/mailman/interfaces/mta.py +++ b/mailman/interfaces/mta.py @@ -17,7 +17,13 @@ """Interface for mail transport agent integration.""" -from zope.interface import Interface, Attribute +__metaclass__ = type +__all__ = [ + 'IMailTransportAgent', + ] + + +from zope.interface import Interface diff --git a/mailman/interfaces/registrar.py b/mailman/interfaces/registrar.py index 823298d5e..d6c174d85 100644 --- a/mailman/interfaces/registrar.py +++ b/mailman/interfaces/registrar.py @@ -22,7 +22,13 @@ etc. than the IUserManager. The latter does no validation, syntax checking, or confirmation, while this interface does. """ -from zope.interface import Interface, Attribute +__metaclass__ = type +__all__ = [ + 'IRegistrar', + ] + + +from zope.interface import Interface diff --git a/mailman/languages.py b/mailman/languages.py index 2fd93aaf6..27e2353de 100644 --- a/mailman/languages.py +++ b/mailman/languages.py @@ -35,8 +35,8 @@ class LanguageManager: self._enabled.add(code) def enable_language(self, code): - # As per the interface, let KeyError percolate up. - self._language_data[code] + if code not in self._language_data: + raise KeyError(code) self._enabled.add(code) def get_description(self, code): diff --git a/mailman/mta/Utils.py b/mailman/mta/Utils.py deleted file mode 100644 index bebbc69b7..000000000 --- a/mailman/mta/Utils.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright (C) 2001-2009 by the Free Software Foundation, Inc. -# -# This file is part of GNU Mailman. -# -# GNU Mailman 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 3 of the License, or (at your option) -# any later version. -# -# GNU Mailman 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 -# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. - -"""Utilities for list creation/deletion hooks.""" - -import os -import pwd - -from mailman.configuration import config - - - -def getusername(): - username = os.environ.get('USER') or os.environ.get('LOGNAME') - if not username: - import pwd - username = pwd.getpwuid(os.getuid())[0] - if not username: - username = '<unknown>' - return username - - - -def _makealiases_mailprog(mlist): - wrapper = os.path.join(config.WRAPPER_DIR, 'mailman') - # Most of the list alias extensions are quite regular. I.e. if the - # message is delivered to listname-foobar, it will be filtered to a - # program called foobar. There are two exceptions: - # - # 1) Messages to listname (no extension) go to the post script. - # 2) Messages to listname-admin go to the bounces script. This is for - # backwards compatibility and may eventually go away (we really have no - # need for the -admin address anymore). - # - # Seed this with the special cases. - listname = mlist.internal_name() - fqdn_listname = mlist.fqdn_listname - aliases = [ - (listname, '"|%s post %s"' % (wrapper, fqdn_listname)), - ] - for ext in ('admin', 'bounces', 'confirm', 'join', 'leave', 'owner', - 'request', 'subscribe', 'unsubscribe'): - aliases.append(('%s-%s' % (listname, ext), - '"|%s %s %s"' % (wrapper, ext, fqdn_listname))) - return aliases - - - -def _makealiases_maildir(mlist): - maildir = config.MAILDIR_DIR - listname = mlist.internal_name() - fqdn_listname = mlist.fqdn_listname - if not maildir.endswith('/'): - maildir += '/' - # Deliver everything using maildir style. This way there's no mail - # program, no forking and no wrapper necessary! - # - # Note, don't use this unless your MTA leaves the envelope recipient in - # Delivered-To:, Envelope-To:, or Apparently-To: - aliases = [(listname, maildir)] - for ext in ('admin', 'bounces', 'confirm', 'join', 'leave', 'owner', - 'request', 'subscribe', 'unsubscribe'): - aliases.append(('%s-%s' % (listname, ext), maildir)) - return aliases - - - -# XXX This won't work if Mailman.MTA.Utils is imported before the -# configuration is loaded. -if config.USE_MAILDIR: - makealiases = _makealiases_maildir -else: - makealiases = _makealiases_mailprog diff --git a/mailman/pipeline/acknowledge.py b/mailman/pipeline/acknowledge.py index 1e42f5049..f1bd585f6 100644 --- a/mailman/pipeline/acknowledge.py +++ b/mailman/pipeline/acknowledge.py @@ -28,7 +28,6 @@ from zope.interface import implements from mailman import Message from mailman import Utils -from mailman.config import config from mailman.i18n import _ from mailman.interfaces.handler import IHandler diff --git a/mailman/pipeline/avoid_duplicates.py b/mailman/pipeline/avoid_duplicates.py index d7e920e81..10c047004 100644 --- a/mailman/pipeline/avoid_duplicates.py +++ b/mailman/pipeline/avoid_duplicates.py @@ -30,7 +30,6 @@ __all__ = ['AvoidDuplicates'] from email.Utils import getaddresses, formataddr from zope.interface import implements -from mailman.config import config from mailman.i18n import _ from mailman.interfaces.handler import IHandler diff --git a/mailman/pipeline/calculate_recipients.py b/mailman/pipeline/calculate_recipients.py index 8f1310ab8..9385c64e8 100644 --- a/mailman/pipeline/calculate_recipients.py +++ b/mailman/pipeline/calculate_recipients.py @@ -28,7 +28,6 @@ __all__ = ['CalculateRecipients'] from zope.interface import implements -from mailman import Message from mailman import Utils from mailman.config import config from mailman.core import errors diff --git a/mailman/pipeline/cook_headers.py b/mailman/pipeline/cook_headers.py index d8d5e3651..88051970e 100644 --- a/mailman/pipeline/cook_headers.py +++ b/mailman/pipeline/cook_headers.py @@ -25,7 +25,6 @@ __all__ = [ import re -from email.charset import Charset from email.errors import HeaderParseError from email.header import Header, decode_header, make_header from email.utils import parseaddr, formataddr, getaddresses @@ -33,7 +32,6 @@ from zope.interface import implements from mailman import Utils from mailman.config import config -from mailman.core.plugins import get_plugins from mailman.i18n import _ from mailman.interfaces.handler import IHandler from mailman.interfaces.mailinglist import Personalization, ReplyToMunging @@ -319,12 +317,12 @@ def ch_oneline(headerstr): # At this point, we should rstrip() every string because some # MUA deliberately add trailing spaces when composing return # message. - d = [(s.rstrip(),c) for (s,c) in d] + d = [(s.rstrip(), c) for (s, c) in d] # Find all charsets in the original header. We use 'utf-8' rather # than using the first charset (in mailman 2.1.x) if multiple # charsets are used. csets = [] - for (s,c) in d: + for (s, c) in d: if c and c not in csets: csets.append(c) if len(csets) == 0: diff --git a/mailman/pipeline/decorate.py b/mailman/pipeline/decorate.py index 2a7e7b065..bf9fbea80 100644 --- a/mailman/pipeline/decorate.py +++ b/mailman/pipeline/decorate.py @@ -28,7 +28,6 @@ from email.MIMEText import MIMEText from string import Template from zope.interface import implements -from mailman import Defaults from mailman import Utils from mailman.Message import Message from mailman.config import config diff --git a/mailman/pipeline/mime_delete.py b/mailman/pipeline/mime_delete.py index 0245e347a..c7e27bd5f 100644 --- a/mailman/pipeline/mime_delete.py +++ b/mailman/pipeline/mime_delete.py @@ -37,7 +37,6 @@ from email.Iterators import typed_subpart_iterator from os.path import splitext from zope.interface import implements -from mailman.Message import UserNotification from mailman.Utils import oneline from mailman.config import config from mailman.core import errors @@ -217,7 +216,8 @@ def to_plaintext(msg): try: os.unlink(filename) except OSError, e: - if e.errno <> errno.ENOENT: raise + if e.errno <> errno.ENOENT: + raise # Now replace the payload of the subpart and twiddle the Content-Type: del subpart['content-transfer-encoding'] subpart.set_payload(plaintext) diff --git a/mailman/pipeline/smtp_direct.py b/mailman/pipeline/smtp_direct.py index 9d2019ec4..09b2223d6 100644 --- a/mailman/pipeline/smtp_direct.py +++ b/mailman/pipeline/smtp_direct.py @@ -34,7 +34,6 @@ __all__ = [ import copy import time -import email import socket import logging import smtplib diff --git a/mailman/queue/bounce.py b/mailman/queue/bounce.py index e098ba866..ce5040982 100644 --- a/mailman/queue/bounce.py +++ b/mailman/queue/bounce.py @@ -23,17 +23,14 @@ import cPickle import logging import datetime -from email.MIMEMessage import MIMEMessage -from email.MIMEText import MIMEText from email.Utils import parseaddr from mailman import Defaults from mailman import Utils from mailman.Bouncers import BouncerAPI -from mailman.Message import UserNotification from mailman.config import config from mailman.i18n import _ -from mailman.queue import Runner, Switchboard +from mailman.queue import Runner COMMASPACE = ', ' diff --git a/mailman/queue/command.py b/mailman/queue/command.py index 983f6e77a..45c9693b5 100644 --- a/mailman/queue/command.py +++ b/mailman/queue/command.py @@ -29,21 +29,16 @@ __all__ = [ # -owner. import re -import sys import logging from StringIO import StringIO from email.Errors import HeaderParseError -from email.Header import decode_header, make_header, Header +from email.Header import decode_header, make_header from email.Iterators import typed_subpart_iterator -from email.MIMEMessage import MIMEMessage -from email.MIMEText import MIMEText from zope.interface import implements from mailman import Defaults from mailman import Message -from mailman import Utils -from mailman.app.replybot import autorespond_to_sender from mailman.config import config from mailman.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailResults diff --git a/mailman/queue/incoming.py b/mailman/queue/incoming.py index ae78e1a81..1adda6629 100644 --- a/mailman/queue/incoming.py +++ b/mailman/queue/incoming.py @@ -26,7 +26,6 @@ prepared for delivery. Rejections, discards, and holds are processed immediately. """ -from mailman.config import config from mailman.core.chains import process from mailman.queue import Runner diff --git a/mailman/queue/lmtp.py b/mailman/queue/lmtp.py index 1f45732a3..f52c99fae 100644 --- a/mailman/queue/lmtp.py +++ b/mailman/queue/lmtp.py @@ -34,7 +34,6 @@ See the variable USE_LMTP in Defaults.py.in for enabling this delivery mechanism. """ -import os import email import smtpd import logging @@ -194,8 +193,8 @@ class LMTPRunner(Runner, smtpd.SMTPServer): msgdata['tolist'] = True queue = 'in' elif subaddress == 'request': - msgdata['torequest'] = True - queue = 'command' + msgdata['torequest'] = True + queue = 'command' else: elog.error('Unknown sub-address: %s', subaddress) status.append(ERR_550) diff --git a/mailman/queue/maildir.py b/mailman/queue/maildir.py index e12550cb5..e8d454d39 100644 --- a/mailman/queue/maildir.py +++ b/mailman/queue/maildir.py @@ -64,14 +64,14 @@ log = logging.getLogger('mailman.error') # We only care about the listname and the subq as in listname@ or # listname-request@ -subqnames = ('admin','bounces','confirm','join','leave', - 'owner','request','subscribe','unsubscribe') +subqnames = ('admin', 'bounces', 'confirm', 'join', 'leave', + 'owner', 'request', 'subscribe', 'unsubscribe') def getlistq(address): localpart, domain = address.split('@', 1) # TK: FIXME I only know configs of Postfix. if config.POSTFIX_STYLE_VIRTUAL_DOMAINS: - p = localpart.split(config.POSTFIX_VIRTUAL_SEPARATOR,1) + p = localpart.split(config.POSTFIX_VIRTUAL_SEPARATOR, 1) if len(p) == 2: localpart, domain = p l = localpart.split('-') @@ -105,7 +105,8 @@ class MaildirRunner(Runner): try: files = os.listdir(self._dir) except OSError, e: - if e.errno <> errno.ENOENT: raise + if e.errno <> errno.ENOENT: + raise # Nothing's been delivered yet return 0 for file in files: diff --git a/mailman/queue/news.py b/mailman/queue/news.py index 98735d498..ec744208d 100644 --- a/mailman/queue/news.py +++ b/mailman/queue/news.py @@ -24,7 +24,6 @@ import logging import nntplib from cStringIO import StringIO -from email.utils import getaddresses, make_msgid COMMASPACE = ', ' diff --git a/mailman/queue/outgoing.py b/mailman/queue/outgoing.py index 14ba869dc..ed648cca0 100644 --- a/mailman/queue/outgoing.py +++ b/mailman/queue/outgoing.py @@ -18,19 +18,15 @@ """Outgoing queue runner.""" import os -import sys -import copy -import email import socket import logging from datetime import datetime from mailman import Defaults -from mailman import Message from mailman.config import config from mailman.core import errors -from mailman.queue import Runner, Switchboard +from mailman.queue import Runner from mailman.queue.bounce import BounceMixin # This controls how often _do_periodic() will try to deal with deferred @@ -67,7 +63,7 @@ class OutgoingRunner(Runner, BounceMixin): self._func(mlist, msg, msgdata) # Failsafe -- a child may have leaked through. if pid <> os.getpid(): - log.error('child process leaked thru: %s', modname) + log.error('child process leaked thru: %s', pid) os._exit(1) self._logged = False except socket.error: diff --git a/mailman/queue/pipeline.py b/mailman/queue/pipeline.py index f0a42f729..6566b75df 100644 --- a/mailman/queue/pipeline.py +++ b/mailman/queue/pipeline.py @@ -23,7 +23,6 @@ headers, calculates message recipients, and more. """ from mailman.core.pipelines import process -from mailman.config import config from mailman.queue import Runner diff --git a/mailman/queue/virgin.py b/mailman/queue/virgin.py index ca61074bf..b163d3ea2 100644 --- a/mailman/queue/virgin.py +++ b/mailman/queue/virgin.py @@ -24,7 +24,6 @@ recipient. """ from mailman.core.pipelines import process -from mailman.config import config from mailman.queue import Runner diff --git a/mailman/rules/suspicious.py b/mailman/rules/suspicious.py index 13052298b..019e6c09b 100644 --- a/mailman/rules/suspicious.py +++ b/mailman/rules/suspicious.py @@ -18,17 +18,21 @@ """The historical 'suspicious header' rule.""" __metaclass__ = type -__all__ = ['SuspiciousHeader'] +__all__ = [ + 'SuspiciousHeader', + ] import re +import logging -from email.utils import getaddresses from zope.interface import implements from mailman.i18n import _ from mailman.interfaces.rules import IRule +log = logging.getLogger('mailman.error') + class SuspiciousHeader: diff --git a/mailman/testing/helpers.py b/mailman/testing/helpers.py index 05ca9253f..9b5252b71 100644 --- a/mailman/testing/helpers.py +++ b/mailman/testing/helpers.py @@ -35,15 +35,12 @@ import socket import logging import mailbox import smtplib -import tempfile import threading from Queue import Empty, Queue -from datetime import datetime, timedelta from mailman.bin.master import Loop as Master from mailman.config import config -from mailman.queue import Switchboard from mailman.testing.smtplistener import Server diff --git a/mailman/testing/smtplistener.py b/mailman/testing/smtplistener.py index cb9d9b323..f7f584f92 100644 --- a/mailman/testing/smtplistener.py +++ b/mailman/testing/smtplistener.py @@ -18,6 +18,7 @@ """A test SMTP listener.""" import smtpd +import socket import logging import asyncore diff --git a/mailman/tests/test_membership.py b/mailman/tests/test_membership.py index b50b2390e..fdb00eec9 100644 --- a/mailman/tests/test_membership.py +++ b/mailman/tests/test_membership.py @@ -17,11 +17,9 @@ """Unit tests for OldStyleMemberships.""" -import os import time import unittest -from mailman import Utils from mailman import passwords from mailman.config import config from mailman.core.errors import NotAMemberError @@ -136,7 +134,8 @@ class TestMembers(unittest.TestCase): eq = self.assertEqual raises = self.assertRaises # We don't really care what the bounce info is - class Info: pass + class Info: + pass info = Info() mlist = self._mlist mlist.setBounceInfo('person@dom.ain', info) diff --git a/mailman/tests/test_security_mgr.py b/mailman/tests/test_security_mgr.py index 76f242104..a70129210 100644 --- a/mailman/tests/test_security_mgr.py +++ b/mailman/tests/test_security_mgr.py @@ -19,7 +19,6 @@ import os import errno -import Cookie import unittest # Don't use cStringIO because we're going to inherit @@ -88,11 +87,13 @@ class TestAuthenticate(unittest.TestCase): try: os.unlink(config.SITE_PW_FILE) except OSError, e: - if e.errno <> errno.ENOENT: raise + if e.errno <> errno.ENOENT: + raise try: os.unlink(config.LISTCREATOR_PW_FILE) except OSError, e: - if e.errno <> errno.ENOENT: raise + if e.errno <> errno.ENOENT: + raise def test_auth_creator(self): self.assertEqual(self._mlist.Authenticate( @@ -187,11 +188,13 @@ class TestWebAuthenticate(unittest.TestCase): try: os.unlink(config.SITE_PW_FILE) except OSError, e: - if e.errno <> errno.ENOENT: raise + if e.errno <> errno.ENOENT: + raise try: os.unlink(config.LISTCREATOR_PW_FILE) except OSError, e: - if e.errno <> errno.ENOENT: raise + if e.errno <> errno.ENOENT: + raise del os.environ['HTTP_COOKIE'] def test_auth_site_admin(self): |
