diff options
| author | Barry Warsaw | 2009-01-03 05:13:41 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-01-03 05:13:41 -0500 |
| commit | e5a96f14fb0fe8196e7b3ea0306c9f57f45c3110 (patch) | |
| tree | e456327300678100b6cc6dfa625c7bc31a9f34a4 /mailman/bin | |
| parent | c0522afd1754c7a18c40c9ebaa6c2ef406929170 (diff) | |
| download | mailman-e5a96f14fb0fe8196e7b3ea0306c9f57f45c3110.tar.gz mailman-e5a96f14fb0fe8196e7b3ea0306c9f57f45c3110.tar.zst mailman-e5a96f14fb0fe8196e7b3ea0306c9f57f45c3110.zip | |
- For command line scripts, -C names the configuration file to use. For
convenient testing, if -C is not given, then the environment variable
MAILMAN_CONFIG_FILE is consulted.
- Mailing lists no longer have a .web_page_url attribute; this is taken
from the mailing list's domain's base_url attribute.
- Incoming MTA selection is now taken from the config file instead of
plugins. An MTA for Postfix+LMTP is added. bin/genaliases works again.
- The LMTP server now properly calculates the message's original size.
- If a message has no Message-ID, the stock archivers will return None for
the permalink now instead of raising an assertion.
- IArchiver no longer has an is_enabled property; this is taken from the
configuration file now.
- In bin/create_list, fixed a unicode problem when the language is defined in
the configuration file.
- Fixed bin/dumbdb, bin/list_lists, bin/remove_list, bin/unshunt, and
bin/mailmanctl
- config.archivers is a property now, not a dictionary that needs
initialization from plugins.
- IMailTransportAgent interface has been added.
Diffstat (limited to 'mailman/bin')
| -rw-r--r-- | mailman/bin/create_list.py | 13 | ||||
| -rw-r--r-- | mailman/bin/dumpdb.py | 2 | ||||
| -rw-r--r-- | mailman/bin/genaliases.py | 72 | ||||
| -rw-r--r-- | mailman/bin/list_lists.py | 2 | ||||
| -rw-r--r-- | mailman/bin/mailmanctl.py | 4 | ||||
| -rw-r--r-- | mailman/bin/qrunner.py | 4 | ||||
| -rw-r--r-- | mailman/bin/remove_list.py | 2 | ||||
| -rw-r--r-- | mailman/bin/unshunt.py | 59 | ||||
| -rw-r--r-- | mailman/bin/withlist.py | 5 |
9 files changed, 60 insertions, 103 deletions
diff --git a/mailman/bin/create_list.py b/mailman/bin/create_list.py index 36aa5c1d1..0c6039e45 100644 --- a/mailman/bin/create_list.py +++ b/mailman/bin/create_list.py @@ -17,12 +17,12 @@ import sys -from mailman import errors from mailman import Message from mailman import Utils from mailman import i18n from mailman.app.lifecycle import create_list -from mailman.configuration import config +from mailman.config import config +from mailman.core import errors from mailman.interfaces import ListAlreadyExistsError from mailman.options import SingleMailingListOptions @@ -79,7 +79,7 @@ owner is specified with the -o option..""")) def sanity_check(self): """Set up some defaults we couldn't set up earlier.""" if self.options.language is None: - self.options.language = config.DEFAULT_SERVER_LANGUAGE + self.options.language = unicode(config.mailman.default_language) # Is the language known? if self.options.language not in config.languages.enabled_codes: self.parser.error(_('Unknown language: $opts.language')) @@ -95,6 +95,8 @@ def main(): # Create the mailing list, applying styles as appropriate. fqdn_listname = options.options.listname + if fqdn_listname is None: + options.parser.error(_('--listname is required')) try: mlist = create_list(fqdn_listname, options.options.owners) mlist.preferred_language = options.options.language @@ -107,11 +109,6 @@ def main(): config.db.commit() - # Send notices to the list owners. XXX This should also be moved to the - # Mailman.app.create module. - if not options.options.quiet and not options.options.automate: - print _('Hit enter to notify $fqdn_listname owners...'), - sys.stdin.readline() if not options.options.quiet: d = dict( listname = mlist.fqdn_listname, diff --git a/mailman/bin/dumpdb.py b/mailman/bin/dumpdb.py index 4642ac361..6657602e4 100644 --- a/mailman/bin/dumpdb.py +++ b/mailman/bin/dumpdb.py @@ -18,7 +18,7 @@ import pprint import cPickle -from mailman.configuration import config +from mailman.config import config from mailman.i18n import _ from mailman.interact import interact from mailman.options import Options diff --git a/mailman/bin/genaliases.py b/mailman/bin/genaliases.py index a09bc6318..3fbef0f88 100644 --- a/mailman/bin/genaliases.py +++ b/mailman/bin/genaliases.py @@ -1,5 +1,3 @@ -#! @PYTHON@ -# # Copyright (C) 2001-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. @@ -17,67 +15,49 @@ # 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__ = [ + 'main', + ] + + import sys -import optparse -from mailman import MailList -from mailman.configuration import config +from mailman.config import config +from mailman.core.plugins import get_plugin from mailman.i18n import _ -from mailman.initialize import initialize +from mailman.options import Options from mailman.version import MAILMAN_VERSION -def parseargs(): - parser = optparse.OptionParser(version=MAILMAN_VERSION, - usage=_("""\ +class ScriptOptions(Options): + """Options for the genaliases script.""" + + usage = _("""\ %prog [options] Regenerate the Mailman specific MTA aliases from scratch. The actual output -depends on the value of the 'MTA' variable in your etc/mailman.cfg file.""")) - parser.add_option('-q', '--quiet', - default=False, action='store_true', help=_("""\ +depends on the value of the 'MTA' variable in your etc/mailman.cfg file.""") + + def add_options(self): + super(ScriptOptions, self).add_options() + self.parser.add_option( + '-q', '--quiet', + default=False, action='store_true', help=_("""\ Some MTA output can include more verbose help text. Use this to tone down the verbosity.""")) - parser.add_option('-C', '--config', - help=_('Alternative configuration file to use')) - opts, args = parser.parse_args() - if args: - parser.print_error(_('Unexpected arguments')) - return parser, opts, args + def main(): - parser, opts, args = parseargs() - initialize(opts.config) - - # Import the MTA specific module - modulename = 'mailman.MTA.' + config.MTA - __import__(modulename) - MTA = sys.modules[modulename] + options = ScriptOptions() + options.initialize() - # We need to acquire a lock so nobody tries to update the files while - # we're doing it. - lock = MTA.makelock() - lock.lock() - # Group lists by virtual hostname - mlists = {} - for listname in config.list_manager.names: - mlist = MailList.MailList(listname, lock=False) - mlists.setdefault(mlist.host_name, []).append(mlist) - try: - MTA.clear() - if not mlists: - MTA.create(None, nolock=True, quiet=opts.quiet) - else: - for hostname, vlists in mlists.items(): - for mlist in vlists: - MTA.create(mlist, nolock=True, quiet=opts.quiet) - # Be verbose for only the first printed list - quiet = True - finally: - lock.unlock(unconditionally=True) + # Get the MTA-specific module. + mta = get_plugin('mailman.mta') + mta().regenerate() diff --git a/mailman/bin/list_lists.py b/mailman/bin/list_lists.py index d19044f35..d2aed3c01 100644 --- a/mailman/bin/list_lists.py +++ b/mailman/bin/list_lists.py @@ -16,7 +16,7 @@ # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. from mailman import Defaults -from mailman.configuration import config +from mailman.config import config from mailman.i18n import _ from mailman.options import Options diff --git a/mailman/bin/mailmanctl.py b/mailman/bin/mailmanctl.py index 6d424442a..667a46a70 100644 --- a/mailman/bin/mailmanctl.py +++ b/mailman/bin/mailmanctl.py @@ -27,9 +27,9 @@ import logging from optparse import OptionParser -from mailman.configuration import config +from mailman.config import config +from mailman.core.initialize import initialize from mailman.i18n import _ -from mailman.initialize import initialize from mailman.version import MAILMAN_VERSION diff --git a/mailman/bin/qrunner.py b/mailman/bin/qrunner.py index a71bb2ef5..eeb5c286b 100644 --- a/mailman/bin/qrunner.py +++ b/mailman/bin/qrunner.py @@ -151,9 +151,9 @@ def make_qrunner(name, slice, range, once=False): class Once(qrclass): def _do_periodic(self): self.stop() - qrunner = Once(slice, range) + qrunner = Once(name, slice) else: - qrunner = qrclass(slice, range) + qrunner = qrclass(name, slice) return qrunner diff --git a/mailman/bin/remove_list.py b/mailman/bin/remove_list.py index fb5d4cdbf..57e41c3b3 100644 --- a/mailman/bin/remove_list.py +++ b/mailman/bin/remove_list.py @@ -21,7 +21,7 @@ import shutil from mailman import Utils from mailman.app.lifecycle import remove_list -from mailman.configuration import config +from mailman.config import config from mailman.i18n import _ from mailman.options import MultipleMailingListOptions diff --git a/mailman/bin/unshunt.py b/mailman/bin/unshunt.py index 8a1dba081..97369ab17 100644 --- a/mailman/bin/unshunt.py +++ b/mailman/bin/unshunt.py @@ -15,51 +15,33 @@ # 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__ = [ + 'main', + ] + + import sys -import optparse -from mailman.configuration import config +from mailman.config import config from mailman.i18n import _ -from mailman.queue import Switchboard from mailman.version import MAILMAN_VERSION - - - -def parseargs(): - parser = optparse.OptionParser(version=MAILMAN_VERSION, - usage=_("""\ -%%prog [options] [directory] - -Move a message from the shunt queue to the original queue. Optional -`directory' specifies a directory to dequeue from other than qfiles/shunt. -""")) - parser.add_option('-C', '--config', - help=_('Alternative configuration file to use')) - opts, args = parser.parse_args() - if len(args) > 1: - parser.print_help() - print >> sys.stderr, _('Unexpected arguments') - sys.exit(1) - return parser, opts, args +from mailman.options import Options def main(): - parser, opts, args = parseargs() - config.load(opts.config) - if args: - qdir = args[0] - else: - qdir = config.SHUNTQUEUE_DIR + options = Options() + options.initialize() + + switchboard = config.switchboards['shunt'] + switchboard.recover_backup_files() - sb = Switchboard(qdir) - sb.recover_backup_files() - for filebase in sb.files(): + for filebase in switchboard.files: try: - msg, msgdata = sb.dequeue(filebase) - whichq = msgdata.get('whichq', config.INQUEUE_DIR) - tosb = Switchboard(whichq) - tosb.enqueue(msg, msgdata) + msg, msgdata = switchboard.dequeue(filebase) + whichq = msgdata.get('whichq', 'in') + config.switchboards[whichq].enqueue(msg, msgdata) except Exception, e: # If there are any unshunting errors, log them and continue trying # other shunted messages. @@ -67,9 +49,4 @@ def main(): 'Cannot unshunt message $filebase, skipping:\n$e') else: # Unlink the .bak file left by dequeue() - sb.finish(filebase) - - - -if __name__ == '__main__': - main() + switchboard.finish(filebase) diff --git a/mailman/bin/withlist.py b/mailman/bin/withlist.py index 8862501d5..f180f5525 100644 --- a/mailman/bin/withlist.py +++ b/mailman/bin/withlist.py @@ -154,7 +154,10 @@ def main(): global LAST_MLIST, VERBOSE parser, opts, args = parseargs() - initialize(opts.config, not opts.quiet) + config_file = (os.getenv('MAILMAN_CONFIG_FILE') + if opts.config is None + else opts.config) + initialize(config_file, not opts.quiet) VERBOSE = not opts.quiet # The default for interact is true unless -r was given |
