diff options
| author | bwarsaw | 1999-01-02 20:41:54 +0000 |
|---|---|---|
| committer | bwarsaw | 1999-01-02 20:41:54 +0000 |
| commit | 3b7180329327cafd8568a3b7427d7fa1fb23375a (patch) | |
| tree | cbb339ec4f7f507243338e1f74fb2541dbf4db95 | |
| parent | d930617da90bdbf650371c5f11c1852e54266400 (diff) | |
| download | mailman-3b7180329327cafd8568a3b7427d7fa1fb23375a.tar.gz mailman-3b7180329327cafd8568a3b7427d7fa1fb23375a.tar.zst mailman-3b7180329327cafd8568a3b7427d7fa1fb23375a.zip | |
list_members - a new script for dumping a list's members to stdout or a file
remove_members - admin script for removing members from the command line
subscribe_enmasse - obsolete
| -rw-r--r-- | bin/Makefile.in | 2 | ||||
| -rwxr-xr-x | bin/list_members | 133 | ||||
| -rwxr-xr-x | bin/remove_members | 104 | ||||
| -rwxr-xr-x | bin/subscribe_enmasse | 31 |
4 files changed, 238 insertions, 32 deletions
diff --git a/bin/Makefile.in b/bin/Makefile.in index 1bdad7879..88d508a95 100644 --- a/bin/Makefile.in +++ b/bin/Makefile.in @@ -44,7 +44,7 @@ SCRIPTSDIR= $(prefix)/bin SHELL= /bin/sh SCRIPTS= digest_arch mmsitepass newlist rmlist add_members \ - subscribe_enmasse update arch + list_members remove_members update arch # Modes for directories and executables created by the install # process. Default to group-writable directories but diff --git a/bin/list_members b/bin/list_members new file mode 100755 index 000000000..65c0e134d --- /dev/null +++ b/bin/list_members @@ -0,0 +1,133 @@ +#! /usr/bin/env python +# +# Copyright (C) 1998 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +"""List all the members of a mailing list. + +Usage: %(program)s [-o file] [-r] [-d] [-p] [-h] listname + +Where: + + --output file + -o file + Write output to specified file instead of standard out. + + --regular + -r + Print just the regular (non-digest) members. + + --digest + -d + Print just the digest members. + + --preserve + -p + Output member addresses case preserved the way they were added to the + list. Otherwise, addresses are printed in all lowercase. + + --help + -h + Print this help message and exit. + + listname is the name of the mailing list to use. + +Note that if neither -r or -d is supplied, both regular members are printed +first, followed by digest members, but no indication is given as to address +status. + +""" + +import sys +import getopt +import paths +from Mailman import MailList +from Mailman import Errors + +program = sys.argv[0] + +def usage(status, msg=''): + print __doc__ % globals() + if msg: + print msg + sys.exit(status) + + + +def main(): + try: + opts, args = getopt.getopt( + sys.argv[1:], + 'dpro:h', + ['digest', 'regular', 'preserve', 'output=', 'help']) + except getopt.error, msg: + usage(1, msg) + + if len(args) <> 1: + usage(1) + + listname = args[0] + outfile = None + regular = None + digest = None + preserve = None + + for opt, arg in opts: + if opt in ('-h', '--help'): + usage(0) + elif opt in ('-o', '--output'): + outfile = arg + elif opt in ('-r', '--regular'): + regular = 1 + elif opt in ('-d', '--digest'): + digest = 1 + elif opt in ('-p', '--preserve'): + preserve = 1 + + if regular is None and digest is None: + regular = digest = 1 + + if outfile: + try: + fp = open(outfile, 'w') + except IOError: + print 'Could not open file for writing:', outfile + sys.exit(1) + else: + fp = sys.stdout + + try: + mlist = MailList.MailList(listname, lock=0) + except Errors.MMUnknownListError: + print 'No list:', listname + sys.exit(1) + + if preserve: + rmembers = mlist.GetDeliveryMembers() + dmembers = mlist.GetDigestDeliveryMembers() + else: + rmembers = mlist.GetMembers() + dmembers = mlist.GetDigestMembers() + + if regular: + for addr in rmembers: + print addr + if digest: + for addr in dmembers: + print addr + +if __name__ == '__main__': + main() diff --git a/bin/remove_members b/bin/remove_members new file mode 100755 index 000000000..65eff01fe --- /dev/null +++ b/bin/remove_members @@ -0,0 +1,104 @@ +#! /usr/bin/env python +# +# Copyright (C) 1998 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +"""Remove members from a list. + +Usage: + remove_members [-f file] [-h] listname [addr1 ...] + +Where: + + --file file + -f file + Remove member addresses found in the given file. + + --help + -h + Print this help message and exit. + + listname is the name of the mailing list to use. + + addr1 ... are additional addresses to remove. + +""" + +import sys +import string +import getopt +import paths +from Mailman import MailList +from Mailman import Errors + +def usage(status, msg=''): + if msg: + print msg + print __doc__ % globals() + sys.exit(status) + + + +def main(): + try: + opts, args = getopt.getopt( + sys.argv[1:], + 'f:h', + ['file=', 'help']) + except getopt.error, msg: + usage(1, msg) + + if not len(args) >= 1: + usage(1) + + listname = args[0] + addresses = args[1:] + filename = None + + for opt, arg in opts: + if opt in ('-h', '--help'): + usage(0) + elif opt in ('-f', '--file'): + filename = arg + + if filename: + try: + fp = open(filename) + addresses = addresses + \ + filter(None, map(string.strip, fp.readlines())) + fp.close() + except IOError: + print 'Could not open file for reading: %s. Ignoring...' % \ + filename + + try: + # open locked + mlist = MailList.MailList(listname) + except Errors.MMUnknownListError: + print 'No list:', listname + sys.exit(1) + + for addr in addresses: + try: + mlist.DeleteMember(addr) + except Errors.MMNoSuchUserError: + print "User `%s' not found." % addr + + mlist.Save() + mlist.Unlock() + +if __name__ == '__main__': + main() diff --git a/bin/subscribe_enmasse b/bin/subscribe_enmasse deleted file mode 100755 index 29a718aaf..000000000 --- a/bin/subscribe_enmasse +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env python -# -# Copyright (C) 1998 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -"""This program gets called when the list admin posts a list of names -to be subscribed on the admin page.""" - -# This is here because mailman # needs to fork this off and make it do the -# work for the following # reasons: -# -# 1) We need to fork so the web browser can return in a reasonable time -# 2) We need to run a ton of mailman processes to avoid holding the -# lock for an unreasonable amount of time. - -import sys -names = sys.stdin.read() -print names |
