summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mailman/app/lifecycle.py8
-rw-r--r--mailman/bin/inject.py85
-rw-r--r--mailman/bin/list_lists.py1
-rw-r--r--mailman/bin/master.py9
-rw-r--r--mailman/bin/withlist.py3
-rw-r--r--mailman/database/mailinglist.py1
-rw-r--r--mailman/database/mailman.sql1
-rw-r--r--mailman/interfaces/mailinglist.py7
-rw-r--r--mailman/queue/__init__.py4
9 files changed, 64 insertions, 55 deletions
diff --git a/mailman/app/lifecycle.py b/mailman/app/lifecycle.py
index 396e8da39..0f3374276 100644
--- a/mailman/app/lifecycle.py
+++ b/mailman/app/lifecycle.py
@@ -85,10 +85,10 @@ def remove_list(fqdn_listname, mailing_list=None, archives=True):
# Delete the mailing list from the database.
config.db.list_manager.delete(mailing_list)
# Do the MTA-specific list deletion tasks
- if config.MTA:
- modname = 'mailman.MTA.' + config.MTA
- __import__(modname)
- sys.modules[modname].remove(mailing_list)
+## if config.MTA:
+## modname = 'mailman.MTA.' + config.MTA
+## __import__(modname)
+## sys.modules[modname].remove(mailing_list)
# Remove the list directory.
removeables.append(os.path.join(config.LIST_DATA_DIR, fqdn_listname))
# Remove any stale locks associated with the list.
diff --git a/mailman/bin/inject.py b/mailman/bin/inject.py
index 6605cefb5..3e4012baf 100644
--- a/mailman/bin/inject.py
+++ b/mailman/bin/inject.py
@@ -15,78 +15,73 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
+from __future__ import with_statement
+
import os
import sys
-import optparse
from mailman import Utils
from mailman import Version
from mailman.configuration import config
from mailman.i18n import _
from mailman.inject import inject
+from mailman.options import SingleMailingListOptions
-def parseargs():
- parser = optparse.OptionParser(version=Version.MAILMAN_VERSION,
- usage=_("""\
+class ScriptOptions(SingleMailingListOptions):
+ usage=_("""\
%prog [options] [filename]
Inject a message from a file into Mailman's incoming queue. 'filename' is the
-name of the plaintext message file to inject. If omitted, standard input is
-used.
-"""))
- parser.add_option('-l', '--listname',
- type='string', help=_("""\
-The name of the list to inject this message to. Required."""))
- parser.add_option('-q', '--queue',
- type='string', help=_("""\
+name of the plaintext message file to inject. If omitted, or the string '-',
+standard input is used.
+""")
+
+ def add_options(self):
+ super(ScriptOptions, self).add_options()
+ self.parser.add_option(
+ '-q', '--queue',
+ type='string', help=_("""\
The name of the queue to inject the message to. The queuename must be one of
the directories inside the qfiles directory. If omitted, the incoming queue
is used."""))
- 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)
- if opts.listname is None:
- parser.print_help()
- print >> sys.stderr, _('-l is required')
- sys.exit(1)
- return parser, opts, args
+
+ def sanity_check(self):
+ if not self.options.listname:
+ self.parser.error(_('Missing listname'))
+ if len(self.arguments) == 0:
+ self.filename = '-'
+ elif len(self.arguments) > 1:
+ self.parser.print_error(_('Unexpected arguments'))
+ else:
+ self.filename = self.arguments[0]
def main():
- parser, opts, args = parseargs()
- config.load(opts.config)
+ options = ScriptOptions()
+ options.initialize()
- if opts.queue:
- qdir = os.path.join(config.QUEUE_DIR, opts.queue)
- if not os.path.isdir(qdir):
- parser.print_help()
- print >> sys.stderr, _('Bad queue directory: $qdir')
- sys.exit(1)
- else:
+ if options.options.queue is None:
qdir = config.INQUEUE_DIR
+ else:
+ qdir = os.path.join(config.QUEUE_DIR, options.options.queue)
+ if not os.path.isdir(qdir):
+ options.parser.error(_('Bad queue directory: $qdir'))
- if not Utils.list_exists(opts.listname):
- parser.print_help()
- print >> sys.stderr, _('No such list: $opts.listname')
- sys.exit(1)
+ fqdn_listname = options.options.listname
+ mlist = config.db.list_manager.get(fqdn_listname)
+ if mlist is None:
+ options.parser.error(_('No such list: $fqdn_listname'))
- if args:
- fp = open(args[0])
- try:
- msgtext = fp.read()
- finally:
- fp.close()
+ if options.filename == '-':
+ message_text = sys.stdin.read()
else:
- msgtext = sys.stdin.read()
+ with open(options.filename) as fp:
+ message_text = fp.read()
- inject(opts.listname, msgtext, qdir=qdir)
+ inject(fqdn_listname, message_text, qdir=qdir)
diff --git a/mailman/bin/list_lists.py b/mailman/bin/list_lists.py
index 7742f1dbb..805ef725c 100644
--- a/mailman/bin/list_lists.py
+++ b/mailman/bin/list_lists.py
@@ -19,7 +19,6 @@ from mailman import Defaults
from mailman import Version
from mailman.configuration import config
from mailman.i18n import _
-from mailman.initialize import initialize
from mailman.options import Options
diff --git a/mailman/bin/master.py b/mailman/bin/master.py
index 7369dd2ca..e033d4d77 100644
--- a/mailman/bin/master.py
+++ b/mailman/bin/master.py
@@ -350,7 +350,7 @@ class Loop:
# because of a failure (i.e. no exit signal), and the no-restart
# command line switch was not given. This lets us better handle
# runaway restarts (e.g. if the subprocess had a syntax error!)
- qrname, slice, count, restarts = self._kids.pop(pid)
+ qrname, slice_number, count, restarts = self._kids.pop(pid)
restart = False
if why == signal.SIGUSR1 and self._restartable:
restart = True
@@ -362,7 +362,7 @@ class Loop:
log.debug("""\
Master detected subprocess exit
(pid: %d, why: %s, class: %s, slice: %d/%d) %s""",
- pid, why, qrname, slice+1, count,
+ pid, why, qrname, slice_number + 1, count,
('[restarting]' if restart else ''))
# See if we've reached the maximum number of allowable restarts
if restarts > config.MAX_RESTARTS:
@@ -372,8 +372,9 @@ qrunner %s reached maximum restart limit of %d, not restarting.""",
# Now perhaps restart the process unless it exited with a
# SIGTERM or we aren't restarting.
if restart:
- newpid = start_runner(qrname, slice, count)
- self._kids[newpid] = (qrname, slice, count, restarts)
+ spec = '%s:%d:%d' % (qrname, slice_number, count)
+ newpid = self._start_runner(spec)
+ self._kids[newpid] = (qrname, slice_number, count, restarts)
def cleanup(self):
"""Ensure that all children have exited."""
diff --git a/mailman/bin/withlist.py b/mailman/bin/withlist.py
index f19723fbc..c6a352319 100644
--- a/mailman/bin/withlist.py
+++ b/mailman/bin/withlist.py
@@ -37,6 +37,9 @@ def do_list(listname, args, func):
if '@' not in listname:
listname += '@' + config.DEFAULT_EMAIL_HOST
+ # XXX FIXME Remove this when this script is converted to
+ # MultipleMailingListOptions.
+ listname = listname.decode(sys.getdefaultencoding())
mlist = config.db.list_manager.get(listname)
if mlist is None:
print >> sys.stderr, _('Unknown list: $listname')
diff --git a/mailman/database/mailinglist.py b/mailman/database/mailinglist.py
index b03d20b1a..9895f9c2d 100644
--- a/mailman/database/mailinglist.py
+++ b/mailman/database/mailinglist.py
@@ -138,6 +138,7 @@ class MailingList(Model):
pass_filename_extensions = Pickle()
pass_mime_types = Pickle()
personalize = Enum()
+ pipeline = Unicode()
post_id = Int()
preferred_language = Unicode()
private_roster = Bool()
diff --git a/mailman/database/mailman.sql b/mailman/database/mailman.sql
index 7c53f25be..3cef32e24 100644
--- a/mailman/database/mailman.sql
+++ b/mailman/database/mailman.sql
@@ -118,6 +118,7 @@ CREATE TABLE mailinglist (
pass_filename_extensions BLOB,
pass_mime_types BLOB,
personalize TEXT,
+ pipeline TEXT,
post_id INTEGER,
preferred_language TEXT,
private_roster BOOLEAN,
diff --git a/mailman/interfaces/mailinglist.py b/mailman/interfaces/mailinglist.py
index d94ed6f71..de63e84e5 100644
--- a/mailman/interfaces/mailinglist.py
+++ b/mailman/interfaces/mailinglist.py
@@ -253,3 +253,10 @@ class IMailingList(Interface):
object, and the returned url will be relative to that object's
'location' attribute.
"""
+
+ pipeline = Attribute(
+ """The name of this mailing list's processing pipeline.
+
+ Every mailing list has a processing pipeline that messages flow
+ through once they've been accepted.
+ """)
diff --git a/mailman/queue/__init__.py b/mailman/queue/__init__.py
index e30608138..4175babaa 100644
--- a/mailman/queue/__init__.py
+++ b/mailman/queue/__init__.py
@@ -210,7 +210,7 @@ class Runner:
implements(IRunner)
QDIR = None
- SLEEPTIME = config.QRUNNER_SLEEP_TIME
+ SLEEPTIME = None
def __init__(self, slice=None, numslices=1):
self._kids = {}
@@ -220,6 +220,8 @@ class Runner:
# Create the shunt switchboard
self._shunt = Switchboard(config.SHUNTQUEUE_DIR)
self._stop = False
+ if self.SLEEPTIME is None:
+ self.SLEEPTIME = config.QRUNNER_SLEEP_TIME
def __repr__(self):
return '<%s at %s>' % (self.__class__.__name__, id(self))