diff options
| author | Barry Warsaw | 2007-07-21 14:52:50 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2007-07-21 14:52:50 -0400 |
| commit | a55d4aa436f34e5d3f1e0e06b372b57de323aa61 (patch) | |
| tree | abd69b303ca57af0b7cc245745dbda2d2dc6c10a | |
| parent | 9e6e3641a7d8738a4adb09c05c4c55882af77e26 (diff) | |
| download | mailman-a55d4aa436f34e5d3f1e0e06b372b57de323aa61.tar.gz mailman-a55d4aa436f34e5d3f1e0e06b372b57de323aa61.tar.zst mailman-a55d4aa436f34e5d3f1e0e06b372b57de323aa61.zip | |
| -rw-r--r-- | Mailman/bin/__init__.py | 1 | ||||
| -rw-r--r-- | Mailman/bin/cleanarch.py (renamed from bin/cleanarch) | 114 | ||||
| -rw-r--r-- | Mailman/bin/genaliases.py | 4 | ||||
| -rwxr-xr-x | bin/check_db | 153 | ||||
| -rw-r--r-- | bin/convert.py | 44 | ||||
| -rw-r--r-- | bin/mailmanctl | 0 | ||||
| -rw-r--r-- | bin/mmshell | 48 | ||||
| -rw-r--r-- | bin/qrunner | 0 |
8 files changed, 40 insertions, 324 deletions
diff --git a/Mailman/bin/__init__.py b/Mailman/bin/__init__.py index 1b1ec6c71..2bb75a4c8 100644 --- a/Mailman/bin/__init__.py +++ b/Mailman/bin/__init__.py @@ -23,6 +23,7 @@ __all__ = [ 'change_pw', 'check_perms', 'checkdbs', + 'cleanarch', 'config_list', 'confirm', 'disabled', diff --git a/bin/cleanarch b/Mailman/bin/cleanarch.py index a8485333d..cda9ad112 100644 --- a/bin/cleanarch +++ b/Mailman/bin/cleanarch.py @@ -1,6 +1,4 @@ -#! @PYTHON@ - -# Copyright (C) 2001-2006 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2007 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 @@ -17,46 +15,19 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. -"""Clean up an .mbox archive file. - -The archiver looks for Unix-From lines separating messages in an mbox archive -file. For compatibility, it specifically looks for lines that start with -"From " -- i.e. the letters capital-F, lowercase-r, o, m, space, ignoring -everything else on the line. - -Normally, any lines that start "From " in the body of a message should be -escaped such that a > character is actually the first on a line. It is -possible though that body lines are not actually escaped. This script -attempts to fix these by doing a stricter test of the Unix-From lines. Any -lines that start "From " but do not pass this stricter test are escaped with a -> character. - -Usage: cleanarch [options] < inputfile > outputfile -Options: - -s n - --status=n - Print a # character every n lines processed - - -q / --quiet - Don't print changed line information to standard error. - - -n / --dry-run - Don't actually output anything. - - -h / --help - Print this message and exit -""" +"""Clean up an .mbox archive file.""" import re import sys -import getopt import mailbox +import optparse -import paths +from Mailman import Version from Mailman.i18n import _ -cre = re.compile(mailbox.UnixMailbox._fromlinepattern) +__i18n_templates = True +cre = re.compile(mailbox.UnixMailbox._fromlinepattern) # From RFC 2822, a header field name must contain only characters from 33-126 # inclusive, excluding colon. I.e. from oct 41 to oct 176 less oct 072. Must # use re.match() so that it's anchored at the beginning of the line. @@ -64,15 +35,36 @@ fre = re.compile(r'[\041-\071\073-\176]+') -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 parseargs(): + parser = optparse.OptionParser(version=Version.MAILMAN_VERSION, + usage=_("""\ +%prog [options] < inputfile > outputfile + +The archiver looks for Unix-From lines separating messages in an mbox archive +file. For compatibility, it specifically looks for lines that start with +'From ' -- i.e. the letters capital-F, lowercase-r, o, m, space, ignoring +everything else on the line. + +Normally, any lines that start 'From ' in the body of a message should be +escaped such that a > character is actually the first on a line. It is +possible though that body lines are not actually escaped. This script +attempts to fix these by doing a stricter test of the Unix-From lines. Any +lines that start From ' but do not pass this stricter test are escaped with a +'>' character.""")) + parser.add_option('-q', '--quiet', + default=False, action='store_true', help=_("""\ +Don't print changed line information to standard error.""")) + parser.add_option('-s', '--status', + default=-1, type='int', help=_("""\ +Print a '#' character for every n lines processed. With a number less than or +equal to zero, suppress the '#' characters.""")) + parser.add_option('-n', '--dry-run', + default=False, action='store_true', help=_("""\ +Don't actually output anything.""")) + opts, args = parser.parser_args() + if args: + parser.print_error(_('Unexpected arguments')) + return parser, opts, args @@ -80,38 +72,13 @@ def escape_line(line, lineno, quiet, output): if output: sys.stdout.write('>' + line) if not quiet: - print >> sys.stderr, _('Unix-From line changed: %(lineno)d') + print >> sys.stderr, _('Unix-From line changed: $lineno') print >> sys.stderr, line[:-1] def main(): - try: - opts, args = getopt.getopt( - sys.argv[1:], 'hqns:', - ['help', 'quiet', 'dry-run', 'status=']) - except getopt.error, msg: - usage(1, msg) - - quiet = False - output = True - status = -1 - - for opt, arg in opts: - if opt in ('-h', '--help'): - usage(0) - elif opt in ('-q', '--quiet'): - quiet = True - elif opt in ('-n', '--dry-run'): - output = False - elif opt in ('-s', '--status'): - try: - status = int(arg) - except ValueError: - usage(1, _('Bad status number: %(arg)s')) - - if args: - usage(1) + parser, opts, args = parseargs() lineno = 0 statuscnt = 0 @@ -165,8 +132,3 @@ def main(): statuscnt = 0 prevline = line print >> sys.stderr, _('%(messages)d messages found') - - - -if __name__ == '__main__': - main() diff --git a/Mailman/bin/genaliases.py b/Mailman/bin/genaliases.py index 239f88c91..99a4234d4 100644 --- a/Mailman/bin/genaliases.py +++ b/Mailman/bin/genaliases.py @@ -45,9 +45,7 @@ verbosity.""")) help=_('Alternative configuration file to use')) opts, args = parser.parse_args() if args: - parser.print_help() - print >> sys.stderr, _('Unexpected arguments') - sys.exit(1) + parser.print_error(_('Unexpected arguments')) return parser, opts, args diff --git a/bin/check_db b/bin/check_db deleted file mode 100755 index b1157bc7d..000000000 --- a/bin/check_db +++ /dev/null @@ -1,153 +0,0 @@ -#! @PYTHON@ -# -# Copyright (C) 1998,1999,2000,2001,2002 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -"""Check a list's config database file for integrity. - -All of the following files are checked: - - config.pck - config.pck.last - config.db - config.db.last - config.safety - -It's okay if any of these are missing. config.pck and config.pck.last are -pickled versions of the config database file for 2.1a3 and beyond. config.db -and config.db.last are used in all earlier versions, and these are Python -marshals. config.safety is a pickle written by 2.1a3 and beyond when the -primary config.pck file could not be read. - -Usage: %(PROGRAM)s [options] [listname [listname ...]] - -Options: - - --all / -a - Check the databases for all lists. Otherwise only the lists named on - the command line are checked. - - --verbose / -v - Verbose output. The state of every tested file is printed. - Otherwise only corrupt files are displayed. - - --help / -h - Print this text and exit. -""" - -import sys -import os -import errno -import getopt -import marshal -import cPickle - -import paths -from Mailman import mm_cfg -from Mailman import Utils -from Mailman.MailList import MailList -from Mailman.i18n import _ - -PROGRAM = sys.argv[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 testfile(dbfile): - if dbfile.endswith('.db') or dbfile.endswith('.db.last'): - loadfunc = marshal.load - elif dbfile.endswith('.pck') or dbfile.endswith('.pck.last'): - loadfunc = cPickle.load - else: - assert 0 - fp = open(dbfile) - try: - loadfunc(fp) - finally: - fp.close() - - -def main(): - try: - opts, args = getopt.getopt(sys.argv[1:], 'ahv', - ['all', 'verbose', 'help']) - except getopt.error, msg: - usage(1, msg) - - verbose = 0 - listnames = args - - for opt, arg in opts: - if opt in ('-h', '--help'): - usage(0) - elif opt in ('-v', '--verbose'): - verbose = 1 - elif opt in ('-a', '--all'): - listnames = Utils.list_names() - - listnames = [n.lower().strip() for n in listnames] - if not listnames: - print _('Nothing to do.') - sys.exit(0) - - for listname in listnames: - if not Utils.list_exists(listname): - print _('No list named:'), listname - continue - mlist = MailList(listname, lock=0) - pfile = os.path.join(mlist.fullpath(), 'config.pck') - plast = pfile + '.last' - dfile = os.path.join(mlist.fullpath(), 'config.db') - dlast = dfile + '.last' - - if verbose: - print _('List:'), listname - - for file in (pfile, plast, dfile, dlast): - status = 0 - try: - testfile(file) - except IOError, e: - # Don't report ENOENT unless we're in verbose mode - if verbose or e.errno <> errno.ENOENT: - status = e - except Exception, e: - status = e - # Report errors - if status: - if isinstance(status, EnvironmentError): - # This already includes the file name - print ' ', status - else: - print ' %s: %s' % (file, status) - elif verbose: - print _(' %(file)s: okay') - - - -if __name__ == '__main__': - main() diff --git a/bin/convert.py b/bin/convert.py deleted file mode 100644 index aefc5d532..000000000 --- a/bin/convert.py +++ /dev/null @@ -1,44 +0,0 @@ -#! @PYTHON@ -# -# Copyright (C) 2002-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -"""Convert a list's interpolation strings from %-strings to $-strings. - -This script is intended to be run as a bin/withlist script, i.e. - -% bin/withlist -l -r convert <mylist> -""" - -import paths -from Mailman import Utils -from Mailman.i18n import _ - -def convert(mlist): - for attr in ('msg_header', 'msg_footer', 'digest_header', 'digest_footer', - 'autoresponse_postings_text', 'autoresponse_admin_text', - 'autoresponse_request_text'): - s = getattr(mlist, attr) - t = Utils.to_dollar(s) - setattr(mlist, attr, t) - mlist.use_dollar_strings = 1 - print _('Saving list') - mlist.Save() - - - -if __name__ == '__main__': - print _(__doc__.replace('%', '%%')) diff --git a/bin/mailmanctl b/bin/mailmanctl deleted file mode 100644 index e69de29bb..000000000 --- a/bin/mailmanctl +++ /dev/null diff --git a/bin/mmshell b/bin/mmshell deleted file mode 100644 index 042f659f2..000000000 --- a/bin/mmshell +++ /dev/null @@ -1,48 +0,0 @@ -#! @PYTHON@ -# -# Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. - -"""Driver for all command line scripts in Mailman. - -This works by interrogating sys.argv[0] to determine which module actually -implements the script's functionality. -""" - -import os -import sys - -import paths -from Mailman.i18n import _ - - - -def main(): - script_name = os.path.basename(sys.argv[0]) - module_name = 'Mailman.bin.' + script_name - __import__(module_name) - try: - status = sys.modules[module_name].main() - except KeyboardInterrupt: - print >> sys.stderr, _('Interrupted') - status = 0 - sys.exit(status) - - - -if __name__ == '__main__': - main() diff --git a/bin/qrunner b/bin/qrunner deleted file mode 100644 index e69de29bb..000000000 --- a/bin/qrunner +++ /dev/null |
