Update of /cvsroot/mailman/mailman/bin
In directory sc8-pr-cvs1:/tmp/cvs-serv5101/bin

Modified Files:
      Tag: Release_2_1-maint
        Makefile.in dumpdb list_members mailmanctl msgfmt.py 
        pygettext.py 
Added Files:
      Tag: Release_2_1-maint
        discard show_qfiles 
Log Message:
Backporting from the HEAD -- bin and cron scripts




--- NEW FILE: discard ---
#! @PYTHON@
#
# Copyright (C) 2003 by the Free Software Foundation, Inc.
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

"""Discard held messages.

Usage:
    discard [options] file ...

Options:
    --help / -h
        Print this help message and exit.

    --quiet / -q
        Don't print status messages.
"""

# TODO: add command line arguments for specifying other actions than DISCARD,
# and also for specifying other __handlepost() arguments, i.e. comment,
# preserve, forward, addr

import os
import re
import sys
import getopt

import paths
from Mailman import mm_cfg
from Mailman.MailList import MailList
from Mailman.i18n import _

try:
    True, False
except NameError:
    True = 1
    False = 0

cre = re.compile(r'heldmsg-(?P<listname>.*)-(?P<id>[0-9]+)\.(pck|txt)$')



def usage(code, msg=''):
    if code:
        fd = sys.stderr
    else:
        fd = sys.stdout
    print >> fd, _(__doc__)
    if msg:
        print >> fd, msg
    sys.exit(code)



def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'hq', ['help', 'quiet'])
    except getopt.error, msg:
        usage(1, msg)

    quiet = False
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            usage(0)
        elif opt in ('-q', '--quiet'):
            quiet = True

    files = args
    if not files:
        print _('Nothing to do.')

    # Mapping from listnames to sequence of request ids
    discards = {}

    # Cruise through all the named files, collating by mailing list.  We'll
    # lock the list once, process all holds for that list and move on.
    for f in files:
        basename = os.path.basename(f)
        mo = cre.match(basename)
        if not mo:
            print >> sys.stderr, _('Ignoring non-held message: %(f)s')
            continue
        listname, id = mo.group('listname', 'id')
        try:
            id = int(id)
        except (ValueError, TypeError):
            print >> sys.stderr, _('Ignoring held msg w/bad id: %(f)s')
            continue
        discards.setdefault(listname, []).append(id)

    # Now do the discards
    for listname, ids in discards.items():
        mlist = MailList(listname)
        try:
            for id in ids:
                # No comment, no preserve, no forward, no forwarding address
                mlist.HandleRequest(id, mm_cfg.DISCARD, '', False, False, '')
                if not quiet:
                    print _('Discarded held msg #%(id)s for list %(listname)s')
            mlist.Save()
        finally:
            mlist.Unlock()



if __name__ == '__main__':
    main()

--- NEW FILE: show_qfiles ---
#! @PYTHON@

"""Show the contents of one or more Mailman queue files.

Usage: show_qfiles [options] qfile ...

Options:

    -q / --quiet
        Don't print `helpful' message delimiters.

    -h / --help
        Print this text and exit.

Example: show_qfiles qfiles/shunt/*.pck
"""

import sys
import getopt
from cPickle import load

import paths
from Mailman.i18n import _

try:
    True, False
except NameError:
    True = 1
    False = 0



def usage(code, msg=''):
    if code:
        fd = sys.stderr
    else:
        fd = sys.stdout
    print >> fd, _(__doc__)
    if msg:
        print >> fd, msg
    sys.exit(code)



def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'hq', ['help', 'quiet'])
    except getopt.error, msg:
        usage(1, msg)

    quiet = False
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            usage(0)
        elif opt in ('-q', '--quiet'):
            quiet = True

    if not args:
        usage(1, "Not enough arguments")

    for filename in args:
        if not quiet:
            print '====================>', filename
        fp = open(filename)
        if filename.endswith(".pck"):
            msg = load(fp)
            sys.stdout.write(msg.as_string())
        else:
            sys.stdout.write(fp.read())



if __name__ == '__main__':
    main()

Index: Makefile.in
===================================================================
RCS file: /cvsroot/mailman/mailman/bin/Makefile.in,v
retrieving revision 2.19.2.2
retrieving revision 2.19.2.3
diff -u -d -r2.19.2.2 -r2.19.2.3
--- Makefile.in 22 Apr 2003 03:34:52 -0000      2.19.2.2
+++ Makefile.in 22 Sep 2003 02:29:50 -0000      2.19.2.3
@@ -48,7 +48,7 @@
                version config_list list_lists dumpdb cleanarch \
                list_admins genaliases change_pw mailmanctl qrunner inject \
                unshunt fix_url.py convert.py transcheck b4b5-archfix \
-               list_owners msgfmt.py
+               list_owners msgfmt.py show_qfiles discard
 
 BUILDDIR=      ../build/bin
 

Index: dumpdb
===================================================================
RCS file: /cvsroot/mailman/mailman/bin/dumpdb,v
retrieving revision 2.12
retrieving revision 2.12.2.1
diff -u -d -r2.12 -r2.12.2.1
--- dumpdb      21 Oct 2002 22:36:56 -0000      2.12
+++ dumpdb      22 Sep 2003 02:29:50 -0000      2.12.2.1
@@ -1,19 +1,19 @@
 #! @PYTHON@
 #
-# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
 #
 # This program 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 2
 # of the License, or (at your option) any later version.
-# 
+#
 # This program 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 this program; if not, write to the Free Software 
+# along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 """Dump the contents of any Mailman `database' file.
@@ -49,7 +49,7 @@
 import os
 import getopt
 import pprint
-import cPickle
+import cPickle as pickle
 
 import paths
 # Import this /after/ paths so that the sys.path is properly hacked
@@ -123,7 +123,7 @@
             pp.pprint(d)
         return d
     else:
-        m = cPickle.load(open(filename))
+        m = pickle.load(open(filename))
         if doprint:
             pp.pprint(m)
         return m

Index: list_members
===================================================================
RCS file: /cvsroot/mailman/mailman/bin/list_members,v
retrieving revision 2.12.2.1
retrieving revision 2.12.2.2
diff -u -d -r2.12.2.1 -r2.12.2.2
--- list_members        31 Mar 2003 20:07:56 -0000      2.12.2.1
+++ list_members        22 Sep 2003 02:29:50 -0000      2.12.2.2
@@ -44,11 +44,18 @@
     --fullnames / -f
         Include the full names in the output.
 
-    --preserve
-    -p
+    --preserve / -p
         Output member addresses case preserved the way they were added to the
         list.  Otherwise, addresses are printed in all lowercase.
 
+    --invalid / -i
+        Print only the addresses in the membership list that are invalid.
+        Ignores -r, -d, -n.
+
+    --unicode / -u
+        Print addresses which are stored as Unicode objects instead of normal
+        string objects.  Ignores -r, -d, -n.
+
     --help
     -h
         Print this help message and exit.
@@ -65,6 +72,7 @@
 
 import paths
 from Mailman import mm_cfg
+from Mailman import Utils
 from Mailman import MailList
 from Mailman import Errors
 from Mailman import MemberAdaptor
@@ -74,6 +82,14 @@
 
 PROGRAM = sys.argv[0]
 ENC = sys.getdefaultencoding()
+COMMASPACE = ', '
+
+try:
+    True, False
+except NameError:
+    True = 1
+    False = 0
+
 
 WHYCHOICES = {'enabled' : MemberAdaptor.ENABLED,
               'unknown' : MemberAdaptor.UNKNOWN,
@@ -103,6 +119,17 @@
     return unicode(s, ENC, 'replace').encode(ENC, 'replace')
 
 
+def isinvalid(addr):
+    try:
+        Utils.ValidateEmail(addr)
+        return False
+    except Errors.EmailAddressError:
+        return True
+
+def isunicode(addr):
+    return isinstance(addr, UnicodeType)
+
+
 
 def whymatches(mlist, addr, why):
     # Return true if the `why' matches the reason the address is enabled, or
@@ -124,14 +151,16 @@
     nomail = None
     why = None
     kind = None
-    fullnames = 0
+    fullnames = False
+    invalidonly = False
+    unicodeonly = False
 
     # Throw away the first (program) argument
     args = sys.argv[1:]
     if not args:
         usage(0)
 
-    while 1:
+    while True:
         try:
             opt = args.pop(0)
         except IndexError:
@@ -139,38 +168,42 @@
         if opt in ('-h', '--help'):
             usage(0)
         elif opt in ('-f', '--fullnames'):
-            fullnames = 1
+            fullnames = True
         elif opt in ('-p', '--preserve'):
-            preserve = 1
+            preserve = True
         elif opt in ('-r', '--regular'):
-            regular = 1
+            regular = True
         elif opt in ('-o', '--output'):
             try:
                 outfile = args.pop(0)
             except IndexError:
                 usage(1)
         elif opt == '-n':
-            nomail = 1
+            nomail = True
             if args and args[0] in WHYCHOICES.keys():
                 why = args.pop(0)
         elif opt.startswith('--nomail'):
-            nomail = 1
+            nomail = True
             i = opt.find('=')
             if i >= 0:
                 why = opt[i+1:]
                 if why not in WHYCHOICES.keys():
                     usage(1, _('Bad --nomail option: %(why)s'))
         elif opt == '-d':
-            digest = 1
+            digest = True
             if args and args[0] in ('mime', 'plain'):
                 kind = args.pop(0)
         elif opt.startswith('--digest'):
-            digest = 1
+            digest = True
             i = opt.find('=')
             if i >= 0:
                 kind = opt[i+1:]
                 if kind not in ('mime', 'plain'):
                     usage(1, _('Bad --digest option: %(kind)s'))
+        elif opt in ('-i', '--invalid'):
+            invalidonly = True
+        elif opt in ('-u', '--unicode'):
+            unicodeonly = True
         else:
             # No more options left, push the last one back on the list
             args.insert(0, opt)
@@ -182,7 +215,7 @@
     listname = args[0].lower().strip()
 
     if regular is None and digest is None:
-        regular = digest = 1
+        regular = digest = True
 
     if outfile:
         try:
@@ -194,7 +227,7 @@
         fp = sys.stdout
 
     try:
-        mlist = MailList.MailList(listname, lock=0)
+        mlist = MailList.MailList(listname, lock=False)
     except Errors.MMListError, e:
         print >> sys.stderr, _('No such list: %(listname)s')
         sys.exit(1)
@@ -208,6 +241,19 @@
         rmembers = mlist.getMemberCPAddresses(rmembers)
         dmembers = mlist.getMemberCPAddresses(dmembers)
 
+    if invalidonly or unicodeonly:
+        all = rmembers + dmembers
+        all.sort()
+        for addr in all:
+            name = fullnames and mlist.getMemberName(addr) or ''
+            showit = False
+            if invalidonly and isinvalid(addr):
+                showit = True
+            if unicodeonly and isunicode(addr):
+                showit = True
+            if showit:
+                print >> fp, formataddr((safe(name), addr))
+        return
     if regular:
         rmembers.sort()
         for addr in rmembers:

Index: mailmanctl
===================================================================
RCS file: /cvsroot/mailman/mailman/bin/mailmanctl,v
retrieving revision 2.24.2.1
retrieving revision 2.24.2.2
diff -u -d -r2.24.2.1 -r2.24.2.2
--- mailmanctl  8 Feb 2003 07:13:51 -0000       2.24.2.1
+++ mailmanctl  22 Sep 2003 02:29:50 -0000      2.24.2.2
@@ -250,9 +250,10 @@
     #
     # Craft the command line arguments for the exec() call.
     rswitch = '--runner=%s:%d:%d' % (qrname, slice, count)
-    # BAW: should argv[0] be `python'?
     exe = os.path.join(mm_cfg.BIN_DIR, 'qrunner')
-    os.execl(mm_cfg.PYTHON, 'qrunner', exe, rswitch, '-s')
+    # mm_cfg.PYTHON, which is the absolute path to the Python interpreter,
+    # must be given as argv[0] due to Python's library search algorithm.
+    os.execl(mm_cfg.PYTHON, mm_cfg.PYTHON, exe, rswitch, '-s')
     # Should never get here
     raise RuntimeError, 'os.execl() failed'
 

Index: msgfmt.py
===================================================================
RCS file: /cvsroot/mailman/mailman/bin/msgfmt.py,v
retrieving revision 2.1.2.1
retrieving revision 2.1.2.2
diff -u -d -r2.1.2.1 -r2.1.2.2
--- msgfmt.py   22 Apr 2003 03:34:52 -0000      2.1.2.1
+++ msgfmt.py   22 Sep 2003 02:29:50 -0000      2.1.2.2
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-
+# -*- coding: iso-8859-1 -*-
 # Written by Martin v. L�wis <[EMAIL PROTECTED]>
 
 """Generate binary message catalog from textual translation description.
@@ -82,8 +82,8 @@
         koffsets += [l1, o1+keystart]
         voffsets += [l2, o2+valuestart]
     offsets = koffsets + voffsets
-    output = struct.pack("iiiiiii",
-                         0x950412de,        # Magic
+    output = struct.pack("Iiiiiii",
+                         0x950412deL,       # Magic
                          0,                 # Version
                          len(keys),         # # of entries
                          7*4,               # start of key index

Index: pygettext.py
===================================================================
RCS file: /cvsroot/mailman/mailman/bin/pygettext.py,v
retrieving revision 2.6
retrieving revision 2.6.2.1
diff -u -d -r2.6 -r2.6.2.1
--- pygettext.py        21 Oct 2002 22:36:56 -0000      2.6
+++ pygettext.py        22 Sep 2003 02:29:50 -0000      2.6.2.1
@@ -200,8 +200,8 @@
     global escapes
     if pass_iso8859:
         # Allow iso-8859 characters to pass through so that e.g. 'msgid
-        # "H�he"' would result not result in 'msgid "H\366he"'.  Otherwise we
-        # escape any character outside the 32..126 range.
+        # "H[o-umlaut]he"' would result not result in 'msgid "H\366he"'.
+        # Otherwise we escape any character outside the 32..126 range.
         mod = 128
     else:
         mod = 256



_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-checkins

Reply via email to