Update of /cvsroot/mailman/mailman3/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12298
Modified Files:
Tag: 3.0
lists
Log Message:
Command line script for creating and deleting mailing lists.
--- NEW FILE: lists ---
#! /usr/bin/env python
# Copyright (C) 2004 Barry A. Warsaw
#
# 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.
import os
import sys
from optparse import OptionParser
import paths
from mailman import errors
from mailman.config import configuration
from mailman.config.versions import version
from mailman.i18n import _
from mailman.mlist import MailList
SPACE = ' '
def parseargs():
parser = OptionParser(version='Mailman ' + version,
usage="""\
%prog [options]""")
parser.add_option('-C', '--configfile', metavar='FILE',
help=_("""\
The configuration file for Mailman's qrunners."""))
parser.add_option('-c', '--create', metavar='LISTNAME',
help=_("""\
The name of the mailing list to create. This should be a qualified list name,
giving both the name of the list and the domain, separated by an @."""))
parser.add_option('-d', '--delete', metavar='LISTNAME',
help=_("""\
The name of the mailing list to delete. This must be a qualified list name,
giving both the name of the list and the domain, separated by an @."""))
parser.add_option('--showdomains', action='store_true', default=False,
help=_('Show the names of all defined domains'))
# BAW find a way to display the availble styles.
parser.add_option('-s', '--style', default='default',
help=_('The style to create the list in.'))
# BAW: a hack to make formatted help fit in an Emacs buffer better
parser.formatter.width -= 1
parser.formatter.help_width -= 1
opts, args = parser.parse_args()
if args:
extraargs = SPACE.join(args)
parser.print_help()
print
print _('Illegal arguments: $extraargs')
sys.exit(1)
# We must have a config file. If one wasn't given, look for
# ../etc/mailman.conf
if opts.configfile is None:
here = os.path.abspath(os.path.dirname(__file__))
parent = os.path.normpath(os.path.join(here, '..', 'etc'))
cfile = os.path.join(parent, 'mailman.conf')
if os.path.exists(cfile):
opts.configfile = cfile
else:
parser.print_help()
print
print _('No configuration file found, please use -C')
sys.exit(1)
return opts, parser
def main():
if options.showdomains:
domains = configuration.domains.bydomain.keys()
domains.sort()
for d in domains:
mailhost, webhost = configuration.domains.bydomain[d]
print _('name: $d, mailhost: $mailhost, webhost: $webhost')
sys.exit(0)
# Delete any lists first.
if options.delete:
listname, domain = options.delete.split('@', 1)
try:
mlist = MailList.open(listname, domain)
except errors.NoListError:
print _('List does not exist: [EMAIL PROTECTED]')
else:
mlist.delete()
print _('Deleted list: [EMAIL PROTECTED]')
elif options.create:
listname, domain = options.create.split('@', 1)
try:
mlist = MailList.create(listname, domain, options.style)
except errors.ListExistsError:
print _('List already exists: [EMAIL PROTECTED]')
else:
print _('List created:')
print _('\tname : $listname')
print _('\tdomain : $domain')
print _('\tmailhost: $mlist.mailhost')
print _('\twebhost : $mlist.webhost')
print _('\tstyle : $options.style')
print _('\tcreated : $mlist.created')
if __name__ == '__main__':
options, parser = parseargs()
configuration.configure(options.configfile)
main()
_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org