# $Id$ # # Mailman withlist script to turn off the wretched "nodupes" flag on # lists and individual subscriptions, and to report on the state of # these flags. # # Run this as "withlist -q -r whack_nodupes listname" to get a report # on list "listname". # # Run this as "withlist -q -r whack_nodupes -a" to get a report on all # lists. # # Run this as "withlist -q -r whack_nodupes listname --fixit" to whack # the settings on list "listname". # # Run this as "withlist -q -r whack_nodupes -a -- --fixit" to whack # the settings on all lists (the extra "--" separates arguments to # withlist from arguments to the script -- don't look at me, I didn't # invent this silliness...). # # Run this as "withlist -q -r whack_nodupes listname --fixit --quiet" or # "withlist -q -r whack_nodupes -a -- --fixit --quiet" to whack # settings without a report. # # You might want to consider backing everything up before running this. # # You might want to consider trying this on a scratch monkey first. # # This script is hereby explictly placed in the public domain as # Beer-Ware. If we meet some day and you think this script is worth # it, you can buy me a beer. Your mileage may vary. Beware of dog. # We decline responsibilities, all shapes, all sizes, all colors. If # this script breaks, you get to keep both pieces. import sys, getopt from Mailman.mm_cfg import (DontReceiveDuplicates, DEFAULT_NEW_MEMBER_OPTIONS) verbose = True fixit = False def parse_options(args): global fixit global verbose opts, argv = getopt.getopt(args, "fq", ["fixit", "quiet"]) for o, a in opts: if o in ("-f", "--fixit"): fixit = True elif o in ("-q", "--quiet"): verbose = False if argv: sys.exit("Unexpected arguments: %r" % argv) def onoff(val): if val: return "ON" else: return "off" # Process one list member def whack_member(mlist, addr): if verbose: print " ", addr, "has nodupes turned", onoff(mlist.getMemberOption(addr, DontReceiveDuplicates)) if fixit and mlist.getMemberOption(addr, DontReceiveDuplicates): mlist.setMemberOption(addr, DontReceiveDuplicates, False) # Process one list def whack_list(mlist): nodupes = mlist.new_member_options & DontReceiveDuplicates != 0 if verbose: print mlist.getListAddress(), "default nodupes setting for new list members is", onoff(nodupes) if fixit and nodupes: mlist.new_member_options &= ~DontReceiveDuplicates # Process site-wide default whacked_site = False def whack_site(): global whacked_site if not whacked_site: whacked_site = True nodupes = DEFAULT_NEW_MEMBER_OPTIONS & DontReceiveDuplicates != 0 if verbose: print "SITE default nodupes setting for new lists is", onoff(nodupes) if fixit and nodupes: print print "I can't fix this for you, you'll have to edit Mailman.mm_cfg" print "to turn off the DontReceiveDuplicates bit in DEFAULT_NEW_MEMBER_OPTIONS." print "If you haven't customized this variable, you can just do" print print " DEFAULT_NEW_MEMBER_OPTIONS = 0" print # Entry point def whack_nodupes(mlist, *args): parse_options(args) whack_site() try: if fixit: if verbose: sys.stderr.write("Locking %s\n" % mlist.internal_name()) mlist.Lock() whack_list(mlist) for addr in mlist.getRegularMemberKeys(): whack_member(mlist, addr) for addr in mlist.getDigestMemberKeys(): whack_member(mlist, addr) if fixit: if verbose: sys.stderr.write("Saving %s\n" % mlist.internal_name()) mlist.Save() finally: if fixit: if verbose: sys.stderr.write("Unlocking %s\n" % mlist.internal_name()) mlist.Unlock()