Skip to content

Instantly share code, notes, and snippets.

@orrisroot
Last active April 2, 2018 11:53
Show Gist options
  • Save orrisroot/a95aefc02162dc8cc85e486196cc2930 to your computer and use it in GitHub Desktop.
Save orrisroot/a95aefc02162dc8cc85e486196cc2930 to your computer and use it in GitHub Desktop.
mailman withlist script to replace list owner address
#!/usr/bin/python
"""Replace list's owner address.
This script is intended to be run as a bin/withlist script, i.e.
% bin/withlist -l -r replace_owner listname from_address to_address
If run standalone, it prints this help text and exits.
"""
import sys
import getopt
from Mailman import mm_cfg
from Mailman.i18n import C_
def usage(code, msg=''):
print C_(__doc__.replace('%', '%%'))
if msg:
print msg
sys.exit(code)
def replace_owner(mlist, from_address, to_address):
verbose = 1
# make sure list is locked.
if not mlist.Locked():
if verbose:
print C_('Locking list')
mlist.Lock()
owner = [w.replace(from_address, to_address) for w in mlist.owner]
if verbose:
print C_(owner)
mlist.owner = owner
mlist.Save()
mlist.Unlock()
if __name__ == '__main__':
useage(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment