[Mailman-Developers] Contrib: bin/show_qfiles

Greg Ward gward@mems-exchange.org
Mon Oct 28 16:54:08 2002


---------------------- multipart/mixed attachment
The attached script is handy for reading Mailman 2.1 queue files, eg.

  bin/show_qfiles qfiles/shunt/*.pck

Help yourselves.

        Greg
-- 
Greg Ward - software developer                gward@mems-exchange.org
MEMS Exchange                            http://www.mems-exchange.org

---------------------- multipart/mixed attachment
#! /www/python/bin/python

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

Usage: show_qfiles qfile ...

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

import sys
from cPickle import load
import paths

from Mailman.i18n import _


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():
    if len(sys.argv) < 2:
	usage(1, "Not enough arguments")

    for filename in sys.argv[1:]:
	print "** %s **" % filename
        file = open(filename)
	if filename.endswith(".pck"):
	    msg = load(file)
	    sys.stdout.write(str(msg))
	else:
	    sys.stdout.write(file.read())


if __name__ == '__main__':
    main()

---------------------- multipart/mixed attachment--