# Copyright (C) 2015 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. """Set the Acknowledge posts option for all regular member addresses ending with the supplied argument on a list or lists. Save as bin/set_ack.py Run via bin/withlist -r set_ack to do this for the list, or bin/withlist -a -r set_ack -- to do all lists. For example: bin/withlist -r set_ack mylist user@example.com will set Ack for all regular members of mylist whose address ends with user@example.com (probably only the one user). bin/withlist -r set_ack mylist @gmail.com will set Ack for all regular members of mylist whose addresses end with @gmail.com and bin/withlist -a -r set_ack -- @gmail.com will set Ack for all regular members of all lists whose addresses end with @gmail.com. """ import sys from Mailman import mm_cfg 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 set_ack(mlist, *args): if len(args) != 1: usage(1, 'One and only one argument required.') addr = args[0].lower() if not mlist.Locked(): mlist.Lock() changed = False for member in mlist.getRegularMemberKeys(): if member.endswith(addr): mlist.setMemberOption(member, mm_cfg.AcknowledgePosts, 1) changed = True print 'Set Ack for %s' % member if changed: mlist.Save() mlist.Unlock()