------------------------------------------------------------
revno: 6615
committer: Barry Warsaw <[EMAIL PROTECTED]>
branch nick: 3.0
timestamp: Tue 2008-03-25 22:28:57 -0400
message:
  Lots of little patches trying to get a simple end-to-end test working.  There
  should be tests for these. :/
  
  - Disable MTA hack in remove_list()
  - Convert bin/inject to SingleMailingListOptions
  - Remove an unnecessary import
  - Fix qrunner restarts in bin/master
  - Add IMailinglist.pipeline so that this value persists
  - Move Runner.SLEEPTIME into the __init__() so that it isn't hurt by order of
    configuration initialization.
modified:
  mailman/app/lifecycle.py
  mailman/bin/inject.py
  mailman/bin/list_lists.py
  mailman/bin/master.py
  mailman/bin/withlist.py
  mailman/database/mailinglist.py
  mailman/database/mailman.sql
  mailman/interfaces/mailinglist.py
  mailman/queue/__init__.py

=== modified file 'mailman/app/lifecycle.py'
--- a/mailman/app/lifecycle.py  2008-03-23 02:01:31 +0000
+++ b/mailman/app/lifecycle.py  2008-03-26 02:28:57 +0000
@@ -85,10 +85,10 @@
         # 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.

=== modified file 'mailman/bin/inject.py'
--- a/mailman/bin/inject.py     2008-02-27 06:26:18 +0000
+++ b/mailman/bin/inject.py     2008-03-26 02:28:57 +0000
@@ -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 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):
-            parser.print_help()
-            print >> sys.stderr, _('Bad queue directory: $qdir')
-            sys.exit(1)
-    else:
-        qdir = config.INQUEUE_DIR
-
-    if not Utils.list_exists(opts.listname):
-        parser.print_help()
-        print >> sys.stderr, _('No such list: $opts.listname')
-        sys.exit(1)
-
-    if args:
-        fp = open(args[0])
-        try:
-            msgtext = fp.read()
-        finally:
-            fp.close()
-    else:
-        msgtext = sys.stdin.read()
-
-    inject(opts.listname, msgtext, qdir=qdir)
+            options.parser.error(_('Bad queue directory: $qdir'))
+
+    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 options.filename == '-':
+        message_text = sys.stdin.read()
+    else:
+        with open(options.filename) as fp:
+            message_text = fp.read()
+
+    inject(fqdn_listname, message_text, qdir=qdir)
 
 
 

=== modified file 'mailman/bin/list_lists.py'
--- a/mailman/bin/list_lists.py 2008-03-23 01:43:38 +0000
+++ b/mailman/bin/list_lists.py 2008-03-26 02:28:57 +0000
@@ -19,7 +19,6 @@
 from mailman import Version
 from mailman.configuration import config
 from mailman.i18n import _
-from mailman.initialize import initialize
 from mailman.options import Options
 
 

=== modified file 'mailman/bin/master.py'
--- a/mailman/bin/master.py     2008-03-23 01:43:38 +0000
+++ b/mailman/bin/master.py     2008-03-26 02:28:57 +0000
@@ -350,7 +350,7 @@
             # 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 @@
             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 @@
             # 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."""

=== modified file 'mailman/bin/withlist.py'
--- a/mailman/bin/withlist.py   2008-02-27 06:26:18 +0000
+++ b/mailman/bin/withlist.py   2008-03-26 02:28:57 +0000
@@ -37,6 +37,9 @@
     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')

=== modified file 'mailman/database/mailinglist.py'
--- a/mailman/database/mailinglist.py   2008-02-27 06:26:18 +0000
+++ b/mailman/database/mailinglist.py   2008-03-26 02:28:57 +0000
@@ -138,6 +138,7 @@
     pass_filename_extensions = Pickle()
     pass_mime_types = Pickle()
     personalize = Enum()
+    pipeline = Unicode()
     post_id = Int()
     preferred_language = Unicode()
     private_roster = Bool()

=== modified file 'mailman/database/mailman.sql'
--- a/mailman/database/mailman.sql      2008-02-02 16:18:22 +0000
+++ b/mailman/database/mailman.sql      2008-03-26 02:28:57 +0000
@@ -118,6 +118,7 @@
         pass_filename_extensions BLOB,
         pass_mime_types BLOB,
         personalize TEXT,
+        pipeline TEXT,
         post_id INTEGER,
         preferred_language TEXT,
         private_roster BOOLEAN,

=== modified file 'mailman/interfaces/mailinglist.py'
--- a/mailman/interfaces/mailinglist.py 2008-02-18 04:34:09 +0000
+++ b/mailman/interfaces/mailinglist.py 2008-03-26 02:28:57 +0000
@@ -253,3 +253,10 @@
         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.
+        """)

=== modified file 'mailman/queue/__init__.py'
--- a/mailman/queue/__init__.py 2008-03-13 01:22:48 +0000
+++ b/mailman/queue/__init__.py 2008-03-26 02:28:57 +0000
@@ -210,7 +210,7 @@
     implements(IRunner)
 
     QDIR = None
-    SLEEPTIME = config.QRUNNER_SLEEP_TIME
+    SLEEPTIME = None
 
     def __init__(self, slice=None, numslices=1):
         self._kids = {}
@@ -220,6 +220,8 @@
         # 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))



--
Primary development focus
https://code.launchpad.net/~mailman-coders/mailman/3.0

You are receiving this branch notification because you are subscribed to it.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to