#! /usr/bin/env python # # 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. import os import sys import optparse import paths from Mailman import Utils from Mailman import mm_cfg from Mailman import MemberAdaptor from Mailman.MailList import MailList def parseargs(): parser = optparse.OptionParser( usage='%prog [options] list_name email', description=Utils.wrap("""List the member options for the list_name member with address email."""), # OptionParser has no epilog attribute in Python 2.3 and 2.4. # For those versions, remove the next two lines. epilog=Utils.wrap("""This script must be put in Mailman's bin/ directory."""), formatter=optparse.IndentedHelpFormatter()) parser.add_option('-p', '--password', dest='password', action='store_true', help="""\ Include the user's password in the output.""") return parser.parse_args() def abort(msg): print >> sys.stderr, '%s: error: %s' % ( os.path.basename(sys.argv[0]), msg) sys.exit(2) def main(): ns, args = parseargs() if len(args) != 2: abort('Exactly 2 args required.') member = args[1].lower() listname = args[0].lower() if not Utils.list_exists(listname): abort("list %s doesn't exist." % listname) mlist = MailList(listname, lock=False) if member in mlist.getRegularMemberKeys(): regular = True elif member in mlist.getDigestMemberKeys(): regular = False else: abort('%s is not a member of %s.' % (member, listname)) if mlist.getMemberName(member): print 'Name = %s' % mlist.getMemberName(member) print 'Moderated Member = %s' % (mlist.getMemberOption( member, mm_cfg.OPTINFO['mod']) and 'Yes' or 'No') print 'Language = %s' % mlist.getMemberLanguage(member) deliv = mlist.getDeliveryStatus(member) if deliv == MemberAdaptor.ENABLED: print 'Delivery is enabled.' elif deliv == MemberAdaptor.UNKNOWN: print 'Delivery is disabled for unknown reason.' elif deliv == MemberAdaptor.BYUSER: print 'Delivery is disabled by user.' elif deliv == MemberAdaptor.BYADMIN: print 'Delivery is disabled by admin.' elif deliv == MemberAdaptor.BYBOUNCE: print 'Delivery is disabled by bounce processing.' print 'Digests = %s' % (regular and 'No' or 'Yes') if not regular: print 'Digest Format = %s' % (mlist.getMemberOption( member, mm_cfg.OPTINFO['plain']) and 'Plain' or 'MIME') print 'Conceal Subscription = %s' % (mlist.getMemberOption( member, mm_cfg.OPTINFO['hide']) and 'Yes' or 'No') print 'Acknowledge Posts = %s' % (mlist.getMemberOption( member, mm_cfg.OPTINFO['ack']) and 'Yes' or 'No') print "Don't Receive Own Posts = %s" % (mlist.getMemberOption( member, mm_cfg.OPTINFO['notmetoo']) and 'Yes' or 'No') print 'Suppress Password Reminder = %s' % (mlist.getMemberOption( member, mm_cfg.OPTINFO['noremind']) and 'Yes' or 'No') print "Don't Receive Duplicates = %s" % (mlist.getMemberOption( member, mm_cfg.OPTINFO['nodupes']) and 'Yes' or 'No') if mlist.topics_enabled and mlist.getMemberTopics(member): print 'Subscribed topics = %r' % mlist.getMemberTopics(member) print 'Receive non-matching topics = %s' % (mlist.getMemberOption( member, mm_cfg.OPTINFO['nmtopics']) and 'Yes' or 'No') if ns.password: print 'Password = %s' % mlist.getMemberPassword(member) if __name__ == '__main__': main()