1#! @PYTHON@ 2# 3# Copyright (C) 2001-2018 by the Free Software Foundation, Inc. 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License 7# as published by the Free Software Foundation; either version 2 8# of the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18# USA. 19 20"""List all the owners of a mailing list. 21 22Usage: %(program)s [options] listname ... 23 24Where: 25 26 --all-vhost=vhost 27 -v=vhost 28 List the owners of all the mailing lists for the given virtual host. 29 30 --all 31 -a 32 List the owners of all the mailing lists on this system. 33 34 --help 35 -h 36 Print this help message and exit. 37 38`listname' is the name of the mailing list to print the owners of. You can 39have more than one named list on the command line. 40""" 41 42import sys 43import getopt 44 45import paths 46from Mailman import MailList, Utils 47from Mailman import Errors 48from Mailman.i18n import C_ 49 50COMMASPACE = ', ' 51 52program = sys.argv[0] 53 54 55 56def usage(code, msg=''): 57 if code: 58 fd = sys.stderr 59 else: 60 fd = sys.stdout 61 print >> fd, C_(__doc__) 62 if msg: 63 print >> fd, msg 64 sys.exit(code) 65 66 67 68def main(): 69 try: 70 opts, args = getopt.getopt(sys.argv[1:], 'hv:a', 71 ['help', 'all-vhost=', 'all']) 72 except getopt.error, msg: 73 usage(1, msg) 74 75 listnames = [x.lower() for x in args] 76 vhost = None 77 for opt, arg in opts: 78 if opt in ('-h', '--help'): 79 usage(0) 80 elif opt in ('-a', '--all'): 81 listnames = Utils.list_names() 82 elif opt in ('-v', '--all-vhost'): 83 listnames = Utils.list_names() 84 vhost = arg 85 86 for listname in listnames: 87 try: 88 mlist = MailList.MailList(listname, lock=0) 89 except Errors.MMListError, e: 90 print C_('No such list: %(listname)s') 91 continue 92 93 if vhost and vhost <> mlist.host_name: 94 continue 95 96 owners = COMMASPACE.join(mlist.owner) 97 print C_('List: %(listname)s, \tOwners: %(owners)s') 98 99 100 101if __name__ == '__main__': 102 main() 103