summaryrefslogtreecommitdiff
path: root/src/mailman/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/commands')
-rw-r--r--src/mailman/commands/cli_aliases.py14
-rw-r--r--src/mailman/commands/cli_control.py29
-rw-r--r--src/mailman/commands/cli_help.py7
-rw-r--r--src/mailman/commands/cli_import.py17
-rw-r--r--src/mailman/commands/cli_info.py28
-rw-r--r--src/mailman/commands/cli_inject.py13
-rw-r--r--src/mailman/commands/cli_lists.py37
-rw-r--r--src/mailman/commands/cli_members.py12
-rw-r--r--src/mailman/commands/cli_qfile.py15
-rw-r--r--src/mailman/commands/cli_status.py11
-rw-r--r--src/mailman/commands/cli_unshunt.py11
-rw-r--r--src/mailman/commands/cli_version.py9
-rw-r--r--src/mailman/commands/cli_withlist.py49
-rw-r--r--src/mailman/commands/docs/end.rst8
-rw-r--r--src/mailman/commands/eml_confirm.py13
-rw-r--r--src/mailman/commands/eml_echo.py4
-rw-r--r--src/mailman/commands/eml_end.py6
-rw-r--r--src/mailman/commands/eml_help.py9
-rw-r--r--src/mailman/commands/eml_membership.py12
19 files changed, 142 insertions, 162 deletions
diff --git a/src/mailman/commands/cli_aliases.py b/src/mailman/commands/cli_aliases.py
index 7c1577c9c..d692ba356 100644
--- a/src/mailman/commands/cli_aliases.py
+++ b/src/mailman/commands/cli_aliases.py
@@ -17,7 +17,7 @@
"""Generate Mailman alias files for your MTA."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -29,7 +29,7 @@ import sys
from operator import attrgetter
from zope.component import getUtility
-from zope.interface import implements
+from zope.interface import implementer
from mailman.config import config
from mailman.core.i18n import _
@@ -41,11 +41,10 @@ from mailman.utilities.modules import call_name
+@implementer(ICLISubCommand)
class Aliases:
"""Regenerate the aliases appropriate for your MTA."""
- implements(ICLISubCommand)
-
name = 'aliases'
def add(self, parser, command_parser):
@@ -91,11 +90,10 @@ class Aliases:
+@implementer(IMailTransportAgentLifecycle)
class Dummy:
"""Dummy aliases implementation for simpler output format."""
- implements(IMailTransportAgentLifecycle)
-
def create(self, mlist):
"""See `IMailTransportAgentLifecycle`."""
raise NotImplementedError
@@ -132,5 +130,5 @@ class Dummy:
for mlist in sorted(by_domain[domain], key=sort_key):
utility = getUtility(IMailTransportAgentAliases)
for alias in utility.aliases(mlist):
- print >> fp, alias
- print >> fp
+ print(alias, file=fp)
+ print(file=fp)
diff --git a/src/mailman/commands/cli_control.py b/src/mailman/commands/cli_control.py
index 2013d6745..8349feb60 100644
--- a/src/mailman/commands/cli_control.py
+++ b/src/mailman/commands/cli_control.py
@@ -17,7 +17,7 @@
"""Module stuff."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -34,7 +34,7 @@ import errno
import signal
import logging
-from zope.interface import implements
+from zope.interface import implementer
from mailman.bin.master import WatcherState, master_state
from mailman.config import config
@@ -46,11 +46,10 @@ qlog = logging.getLogger('mailman.runner')
+@implementer(ICLISubCommand)
class Start:
"""Start the Mailman daemons."""
- implements(ICLISubCommand)
-
name = 'start'
def add(self, parser, command_parser):
@@ -107,7 +106,7 @@ class Start:
'cleanly. Try using --force.'))
def log(message):
if not args.quiet:
- print message
+ print(message)
# Daemon process startup according to Stevens, Advanced Programming in
# the UNIX Environment, Chapter 13.
pid = os.fork()
@@ -147,27 +146,26 @@ def kill_watcher(sig):
pid = int(fp.read().strip())
except (IOError, ValueError) as error:
# For i18n convenience
- print >> sys.stderr, _('PID unreadable in: $config.PID_FILE')
- print >> sys.stderr, error
- print >> sys.stderr, _('Is the master even running?')
+ print(_('PID unreadable in: $config.PID_FILE'), file=sys.stderr)
+ print(error, file=sys.stderr)
+ print(_('Is the master even running?'), file=sys.stderr)
return
try:
os.kill(pid, sig)
except OSError as error:
if error.errno != errno.ESRCH:
raise
- print >> sys.stderr, _('No child with pid: $pid')
- print >> sys.stderr, error
- print >> sys.stderr, _('Stale pid file removed.')
+ print(_('No child with pid: $pid'), file=sys.stderr)
+ print(error, file=sys.stderr)
+ print(_('Stale pid file removed.'), file=sys.stderr)
os.unlink(config.PID_FILE)
+@implementer(ICLISubCommand)
class SignalCommand:
"""Common base class for simple, signal sending commands."""
- implements(ICLISubCommand)
-
name = None
message = None
signal = None
@@ -184,7 +182,7 @@ class SignalCommand:
def process(self, args):
"""See `ICLISubCommand`."""
if not args.quiet:
- print _(self.message)
+ print(_(self.message))
kill_watcher(self.signal)
@@ -204,11 +202,10 @@ class Reopen(SignalCommand):
signal = signal.SIGHUP
+@implementer(ICLISubCommand)
class Restart(SignalCommand):
"""Stop the Mailman daemons."""
- implements(ICLISubCommand)
-
name = 'restart'
message = _('Restarting the Mailman runners')
signal = signal.SIGUSR1
diff --git a/src/mailman/commands/cli_help.py b/src/mailman/commands/cli_help.py
index 538d9c520..a85dcd442 100644
--- a/src/mailman/commands/cli_help.py
+++ b/src/mailman/commands/cli_help.py
@@ -17,7 +17,7 @@
"""The 'help' subcommand."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -25,18 +25,17 @@ __all__ = [
]
-from zope.interface import implements
+from zope.interface import implementer
from mailman.interfaces.command import ICLISubCommand
+@implementer(ICLISubCommand)
class Help:
# Lowercase, to match argparse's default --help text.
"""show this help message and exit"""
- implements(ICLISubCommand)
-
name = 'help'
def add(self, parser, command_parser):
diff --git a/src/mailman/commands/cli_import.py b/src/mailman/commands/cli_import.py
index b703f3ffd..f6c016585 100644
--- a/src/mailman/commands/cli_import.py
+++ b/src/mailman/commands/cli_import.py
@@ -17,7 +17,7 @@
"""Importing list data into Mailman 3."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -29,21 +29,20 @@ import sys
import cPickle
from zope.component import getUtility
-from zope.interface import implements
+from zope.interface import implementer
-from mailman.config import config
from mailman.core.i18n import _
+from mailman.database.transaction import transactional
from mailman.interfaces.command import ICLISubCommand
from mailman.interfaces.listmanager import IListManager
from mailman.utilities.importer import import_config_pck
+@implementer(ICLISubCommand)
class Import21:
"""Import Mailman 2.1 list data."""
- implements(ICLISubCommand)
-
name = 'import21'
def add(self, parser, command_parser):
@@ -59,6 +58,7 @@ class Import21:
'pickle_file', metavar='FILENAME', nargs=1,
help=_('The path to the config.pck file to import.'))
+ @transactional
def process(self, args):
"""See `ICLISubCommand`."""
# Could be None or sequence of length 0.
@@ -90,10 +90,7 @@ class Import21:
return
else:
if not isinstance(config_dict, dict):
- print >> sys.stderr, _(
- 'Ignoring non-dictionary: {0!r}').format(
- config_dict)
+ print(_('Ignoring non-dictionary: {0!r}').format(
+ config_dict), file=sys.stderr)
continue
import_config_pck(mlist, config_dict)
- # Commit the changes to the database.
- config.db.commit()
diff --git a/src/mailman/commands/cli_info.py b/src/mailman/commands/cli_info.py
index 24ccec4fb..0e9c72f60 100644
--- a/src/mailman/commands/cli_info.py
+++ b/src/mailman/commands/cli_info.py
@@ -17,7 +17,7 @@
"""Information about this Mailman instance."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -27,7 +27,7 @@ __all__ = [
import sys
-from zope.interface import implements
+from zope.interface import implementer
from mailman.config import config
from mailman.core.i18n import _
@@ -37,11 +37,10 @@ from mailman.version import MAILMAN_VERSION_FULL
+@implementer(ICLISubCommand)
class Info:
"""Information about this Mailman instance."""
- implements(ICLISubCommand)
-
name = 'info'
def add(self, parser, command_parser):
@@ -65,15 +64,16 @@ class Info:
# We don't need to close output because that will happen
# automatically when the script exits.
output = open(args.output, 'w')
- print >> output, MAILMAN_VERSION_FULL
- print >> output, 'Python', sys.version
- print >> output, 'config file:', config.filename
- print >> output, 'db url:', config.db.url
- print >> output, 'REST root url:', path_to('/')
- print >> output, 'REST credentials: {0}:{1}'.format(
- config.webservice.admin_user, config.webservice.admin_pass)
+ print(MAILMAN_VERSION_FULL, file=output)
+ print('Python', sys.version, file=output)
+ print('config file:', config.filename, file=output)
+ print('db url:', config.db.url, file=output)
+ print('REST root url:', path_to('/'), file=output)
+ print('REST credentials: {0}:{1}'.format(
+ config.webservice.admin_user, config.webservice.admin_pass),
+ file=output)
if args.verbose:
- print >> output, 'File system paths:'
+ print('File system paths:', file=output)
longest = 0
paths = {}
for attribute in dir(config):
@@ -81,5 +81,5 @@ class Info:
paths[attribute] = getattr(config, attribute)
longest = max(longest, len(attribute))
for attribute in sorted(paths):
- print ' {0:{2}} = {1}'.format(attribute, paths[attribute],
- longest)
+ print(' {0:{2}} = {1}'.format(
+ attribute, paths[attribute], longest))
diff --git a/src/mailman/commands/cli_inject.py b/src/mailman/commands/cli_inject.py
index 321a92c78..1434fd2a6 100644
--- a/src/mailman/commands/cli_inject.py
+++ b/src/mailman/commands/cli_inject.py
@@ -17,7 +17,7 @@
"""bin/mailman inject"""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -28,7 +28,7 @@ __all__ = [
import sys
from zope.component import getUtility
-from zope.interface import implements
+from zope.interface import implementer
from mailman.app.inject import inject_text
from mailman.config import config
@@ -38,11 +38,10 @@ from mailman.interfaces.listmanager import IListManager
+@implementer(ICLISubCommand)
class Inject:
"""Inject a message from a file into a mailing list's queue."""
- implements(ICLISubCommand)
-
name = 'inject'
def add(self, parser, command_parser):
@@ -82,9 +81,9 @@ class Inject:
# Process --show first; if given, print output and exit, ignoring all
# other command line switches.
if args.show:
- print 'Available queues:'
+ print('Available queues:')
for switchboard in sorted(config.switchboards):
- print ' ', switchboard
+ print(' ', switchboard)
return
# Could be None or sequence of length 0.
if args.listname is None:
@@ -106,7 +105,7 @@ class Inject:
try:
message_text = sys.stdin.read()
except KeyboardInterrupt:
- print 'Interrupted'
+ print('Interrupted')
sys.exit(1)
else:
with open(args.filename) as fp:
diff --git a/src/mailman/commands/cli_lists.py b/src/mailman/commands/cli_lists.py
index af6afe22d..cf72c51a8 100644
--- a/src/mailman/commands/cli_lists.py
+++ b/src/mailman/commands/cli_lists.py
@@ -17,7 +17,7 @@
"""The 'lists' subcommand."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -28,12 +28,12 @@ __all__ = [
from zope.component import getUtility
-from zope.interface import implements
+from zope.interface import implementer
from mailman.app.lifecycle import create_list, remove_list
-from mailman.config import config
from mailman.core.constants import system_preferences
from mailman.core.i18n import _
+from mailman.database.transaction import transaction, transactional
from mailman.email.message import UserNotification
from mailman.interfaces.address import (
IEmailValidator, InvalidEmailAddressError)
@@ -49,11 +49,10 @@ COMMASPACE = ', '
+@implementer(ICLISubCommand)
class Lists:
"""List all mailing lists"""
- implements(ICLISubCommand)
-
name = 'lists'
def add(self, parser, command_parser):
@@ -98,11 +97,11 @@ class Lists:
# Maybe no mailing lists matched.
if len(mailing_lists) == 0:
if not args.quiet:
- print _('No matching mailing lists found')
+ print(_('No matching mailing lists found'))
return
count = len(mailing_lists)
if not args.quiet:
- print _('$count matching mailing lists found:')
+ print(_('$count matching mailing lists found:'))
# Calculate the longest identifier.
longest = 0
output = []
@@ -120,16 +119,15 @@ class Lists:
else:
format_string = '{0:{2}}'
for identifier, description in output:
- print format_string.format(
- identifier, description, longest, 70 - longest)
+ print(format_string.format(
+ identifier, description, longest, 70 - longest))
+@implementer(ICLISubCommand)
class Create:
"""Create a mailing list"""
- implements(ICLISubCommand)
-
name = 'create'
def add(self, parser, command_parser):
@@ -214,13 +212,13 @@ class Create:
self.parser.error(_('Undefined domain: $domain'))
return
# Find the language associated with the code, then set the mailing
- # list's preferred language to that. The changes then must be
- # committed to the database.
- mlist.preferred_language = getUtility(ILanguageManager)[language_code]
- config.db.commit()
+ # list's preferred language to that.
+ language_manager = getUtility(ILanguageManager)
+ with transaction():
+ mlist.preferred_language = language_manager[language_code]
# Do the notification.
if not args.quiet:
- print _('Created mailing list: $mlist.fqdn_listname')
+ print(_('Created mailing list: $mlist.fqdn_listname'))
if args.notify:
d = dict(
listname = mlist.fqdn_listname,
@@ -242,11 +240,10 @@ class Create:
+@implementer(ICLISubCommand)
class Remove:
"""Remove a mailing list"""
- implements(ICLISubCommand)
-
name = 'remove'
def add(self, parser, command_parser):
@@ -262,11 +259,12 @@ class Remove:
The 'fully qualified list name', i.e. the posting address of the
mailing list."""))
+ @transactional
def process(self, args):
"""See `ICLISubCommand`."""
def log(message):
if not args.quiet:
- print message
+ print(message)
assert len(args.listname) == 1, (
'Unexpected positional arguments: %s' % args.listname)
fqdn_listname = args.listname[0]
@@ -277,4 +275,3 @@ class Remove:
else:
log(_('Removed list: $fqdn_listname'))
remove_list(fqdn_listname, mlist)
- config.db.commit()
diff --git a/src/mailman/commands/cli_members.py b/src/mailman/commands/cli_members.py
index 2bf6be848..7c5d3b8f3 100644
--- a/src/mailman/commands/cli_members.py
+++ b/src/mailman/commands/cli_members.py
@@ -29,14 +29,15 @@ import sys
import codecs
from email.utils import formataddr, parseaddr
-from flufl.password import generate
from operator import attrgetter
+from passlib.utils import generate_password as generate
from zope.component import getUtility
-from zope.interface import implements
+from zope.interface import implementer
from mailman.app.membership import add_member
from mailman.config import config
from mailman.core.i18n import _
+from mailman.database.transaction import transactional
from mailman.interfaces.command import ICLISubCommand
from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.member import (
@@ -44,11 +45,10 @@ from mailman.interfaces.member import (
+@implementer(ICLISubCommand)
class Members:
"""Manage list memberships. With no arguments, list all members."""
- implements(ICLISubCommand)
-
name = 'members'
def add(self, parser, command_parser):
@@ -177,6 +177,7 @@ class Members:
if fp is not sys.stdout:
fp.close()
+ @transactional
def add_members(self, mlist, args):
"""Add the members in a file to a mailing list.
@@ -207,9 +208,8 @@ class Members:
except AlreadySubscribedError:
# It's okay if the address is already subscribed, just
# print a warning and continue.
- print('Already subscribed (skipping):',
+ print('Already subscribed (skipping):',
email, display_name)
finally:
if fp is not sys.stdin:
fp.close()
- config.db.commit()
diff --git a/src/mailman/commands/cli_qfile.py b/src/mailman/commands/cli_qfile.py
index 78156f08c..b9e0eff02 100644
--- a/src/mailman/commands/cli_qfile.py
+++ b/src/mailman/commands/cli_qfile.py
@@ -17,7 +17,7 @@
"""Getting information out of a qfile."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -28,7 +28,7 @@ __all__ = [
import cPickle
from pprint import PrettyPrinter
-from zope.interface import implements
+from zope.interface import implementer
from mailman.core.i18n import _
from mailman.interfaces.command import ICLISubCommand
@@ -39,11 +39,10 @@ m = []
+@implementer(ICLISubCommand)
class QFile:
"""Get information out of a queue file."""
- implements(ICLISubCommand)
-
name = 'qfile'
def add(self, parser, command_parser):
@@ -79,15 +78,15 @@ class QFile:
except EOFError:
break
if args.doprint:
- print _('[----- start pickle -----]')
+ print(_('[----- start pickle -----]'))
for i, obj in enumerate(m):
count = i + 1
- print _('<----- start object $count ----->')
+ print(_('<----- start object $count ----->'))
if isinstance(obj, basestring):
- print obj
+ print(obj)
else:
printer.pprint(obj)
- print _('[----- end pickle -----]')
+ print(_('[----- end pickle -----]'))
count = len(m)
banner = _("The variable 'm' contains $count objects")
if args.interactive:
diff --git a/src/mailman/commands/cli_status.py b/src/mailman/commands/cli_status.py
index 14b0d976b..9cbaa4f22 100644
--- a/src/mailman/commands/cli_status.py
+++ b/src/mailman/commands/cli_status.py
@@ -15,9 +15,9 @@
# You should have received a copy of the GNU General Public License along with
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
-"""Module stuff."""
+"""bin/mailman status."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -27,7 +27,7 @@ __all__ = [
import socket
-from zope.interface import implements
+from zope.interface import implementer
from mailman.bin.master import WatcherState, master_state
from mailman.core.i18n import _
@@ -35,11 +35,10 @@ from mailman.interfaces.command import ICLISubCommand
+@implementer(ICLISubCommand)
class Status:
"""Status of the Mailman system."""
- implements(ICLISubCommand)
-
name = 'status'
def add(self, parser, command_parser):
@@ -64,5 +63,5 @@ class Status:
'Invalid enum value: %s' % status)
message = _('GNU Mailman is in an unexpected state '
'($hostname != $fqdn_name)')
- print message
+ print(message)
return int(status)
diff --git a/src/mailman/commands/cli_unshunt.py b/src/mailman/commands/cli_unshunt.py
index 4ce711b83..bc50d95ef 100644
--- a/src/mailman/commands/cli_unshunt.py
+++ b/src/mailman/commands/cli_unshunt.py
@@ -17,7 +17,7 @@
"""The 'unshunt' command."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -27,7 +27,7 @@ __all__ = [
import sys
-from zope.interface import implements
+from zope.interface import implementer
from mailman.config import config
from mailman.core.i18n import _
@@ -35,11 +35,10 @@ from mailman.interfaces.command import ICLISubCommand
+@implementer(ICLISubCommand)
class Unshunt:
"""Unshunt messages."""
- implements(ICLISubCommand)
-
name = 'unshunt'
def add(self, parser, command_parser):
@@ -64,8 +63,8 @@ class Unshunt:
if not args.discard:
config.switchboards[which_queue].enqueue(msg, msgdata)
except Exception as error:
- print >> sys.stderr, _(
- 'Cannot unshunt message $filebase, skipping:\n$error')
+ print(_('Cannot unshunt message $filebase, skipping:\n$error'),
+ file=sys.stderr)
else:
# Unlink the .bak file left by dequeue()
shunt_queue.finish(filebase)
diff --git a/src/mailman/commands/cli_version.py b/src/mailman/commands/cli_version.py
index 4090b1173..b5e9b65ff 100644
--- a/src/mailman/commands/cli_version.py
+++ b/src/mailman/commands/cli_version.py
@@ -17,7 +17,7 @@
"""The Mailman version."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -25,18 +25,17 @@ __all__ = [
]
-from zope.interface import implements
+from zope.interface import implementer
from mailman.interfaces.command import ICLISubCommand
from mailman.version import MAILMAN_VERSION_FULL
+@implementer(ICLISubCommand)
class Version:
"""Mailman's version."""
- implements(ICLISubCommand)
-
name = 'version'
def add(self, parser, command_parser):
@@ -46,4 +45,4 @@ class Version:
def process(self, args):
"""See `ICLISubCommand`."""
- print MAILMAN_VERSION_FULL
+ print(MAILMAN_VERSION_FULL)
diff --git a/src/mailman/commands/cli_withlist.py b/src/mailman/commands/cli_withlist.py
index e514c798f..4ccdd8798 100644
--- a/src/mailman/commands/cli_withlist.py
+++ b/src/mailman/commands/cli_withlist.py
@@ -17,7 +17,7 @@
"""bin/mailman withlist"""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -31,7 +31,7 @@ import sys
from lazr.config import as_boolean
from zope.component import getUtility
-from zope.interface import implements
+from zope.interface import implementer
from mailman.config import config
from mailman.core.i18n import _
@@ -47,14 +47,13 @@ r = None
+@implementer(ICLISubCommand)
class Withlist:
"""Operate on a mailing list.
For detailed help, see --details
"""
- implements(ICLISubCommand)
-
name = 'withlist'
def add(self, parser, command_parser):
@@ -163,7 +162,7 @@ class Withlist:
ipshell = InteractiveShellEmbed(banner1=banner, user_ns=overrides)
ipshell()
except ImportError:
- print _('ipython is not available, set use_ipython to no')
+ print(_('ipython is not available, set use_ipython to no'))
def _start_python(self, overrides, banner):
# Set the tab completion.
@@ -178,25 +177,25 @@ class Withlist:
def _details(self):
"""Print detailed usage."""
# Split this up into paragraphs for easier translation.
- print _("""\
+ print(_("""\
This script provides you with a general framework for interacting with a
-mailing list.""")
- print
- print _("""\
+mailing list."""))
+ print()
+ print(_("""\
There are two ways to use this script: interactively or programmatically.
Using it interactively allows you to play with, examine and modify a mailing
list from Python's interactive interpreter. When running interactively, the
variable 'm' will be available in the global namespace. It will reference the
-mailing list object.""")
- print
- print _("""\
+mailing list object."""))
+ print()
+ print(_("""\
Programmatically, you can write a function to operate on a mailing list, and
this script will take care of the housekeeping (see below for examples). In
that case, the general usage syntax is:
- % bin/mailman withlist [options] listname [args ...]""")
- print
- print _("""\
+ % bin/mailman withlist [options] listname [args ...]"""))
+ print()
+ print(_("""\
Here's an example of how to use the --run option. Say you have a file in the
Mailman installation directory called 'listaddr.py', with the following two
functions:
@@ -205,26 +204,26 @@ functions:
print mlist.posting_address
def requestaddr(mlist):
- print mlist.request_address""")
- print
- print _("""\
+ print mlist.request_address"""))
+ print()
+ print(_("""\
You can print the list's posting address by running the following from the
command line:
% bin/mailman withlist -r listaddr mylist@example.com
Importing listaddr ...
Running listaddr.listaddr() ...
- mylist@example.com""")
- print
- print _("""\
+ mylist@example.com"""))
+ print()
+ print(_("""\
And you can print the list's request address by running:
% bin/mailman withlist -r listaddr.requestaddr mylist
Importing listaddr ...
Running listaddr.requestaddr() ...
- mylist-request@example.com""")
- print
- print _("""\
+ mylist-request@example.com"""))
+ print()
+ print(_("""\
As another example, say you wanted to change the display name for a particular
mailing list. You could put the following function in a file called
'change.pw':
@@ -236,7 +235,7 @@ mailing list. You could put the following function in a file called
and run this from the command line:
- % bin/mailman withlist -r change mylist@example.com 'My List'""")
+ % bin/mailman withlist -r change mylist@example.com 'My List'"""))
diff --git a/src/mailman/commands/docs/end.rst b/src/mailman/commands/docs/end.rst
index accf91b90..8cd4b2409 100644
--- a/src/mailman/commands/docs/end.rst
+++ b/src/mailman/commands/docs/end.rst
@@ -13,8 +13,8 @@ processing email messages.
The 'end' command takes no arguments.
- >>> command.argument_description
- ''
+ >>> print 'DESCRIPTION:', command.argument_description
+ DESCRIPTION:
The command itself is fairly simple; it just stops command processing, and the
message isn't even looked at.
@@ -31,7 +31,7 @@ The 'stop' command is a synonym for 'end'.
stop
>>> print command.description
An alias for 'end'.
- >>> command.argument_description
- ''
+ >>> print 'DESCRIPTION:', command.argument_description
+ DESCRIPTION:
>>> print command.process(mlist, Message(), {}, (), None)
ContinueProcessing.no
diff --git a/src/mailman/commands/eml_confirm.py b/src/mailman/commands/eml_confirm.py
index 55619a503..c82dc64c3 100644
--- a/src/mailman/commands/eml_confirm.py
+++ b/src/mailman/commands/eml_confirm.py
@@ -17,7 +17,7 @@
"""Module stuff."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -26,7 +26,7 @@ __all__ = [
from zope.component import getUtility
-from zope.interface import implements
+from zope.interface import implementer
from mailman.core.i18n import _
from mailman.interfaces.command import ContinueProcessing, IEmailCommand
@@ -34,11 +34,10 @@ from mailman.interfaces.registrar import IRegistrar
+@implementer(IEmailCommand)
class Confirm:
"""The email 'confirm' command."""
- implements(IEmailCommand)
-
name = 'confirm'
argument_description = 'token'
description = _('Confirm a subscription request.')
@@ -48,7 +47,7 @@ class Confirm:
"""See `IEmailCommand`."""
# The token must be in the arguments.
if len(arguments) == 0:
- print >> results, _('No confirmation token found')
+ print(_('No confirmation token found'), file=results)
return ContinueProcessing.no
# Make sure we don't try to confirm the same token more than once.
token = arguments[0]
@@ -60,7 +59,7 @@ class Confirm:
results.confirms = tokens
succeeded = getUtility(IRegistrar).confirm(token)
if succeeded:
- print >> results, _('Confirmed')
+ print(_('Confirmed'), file=results)
return ContinueProcessing.yes
- print >> results, _('Confirmation token did not match')
+ print(_('Confirmation token did not match'), file=results)
return ContinueProcessing.no
diff --git a/src/mailman/commands/eml_echo.py b/src/mailman/commands/eml_echo.py
index 06d5ee5e7..885edcbae 100644
--- a/src/mailman/commands/eml_echo.py
+++ b/src/mailman/commands/eml_echo.py
@@ -25,7 +25,7 @@ __all__ = [
]
-from zope.interface import implements
+from zope.interface import implementer
from mailman.core.i18n import _
from mailman.interfaces.command import ContinueProcessing, IEmailCommand
@@ -35,9 +35,9 @@ SPACE = ' '
+@implementer(IEmailCommand)
class Echo:
"""The email 'echo' command."""
- implements(IEmailCommand)
name = 'echo'
argument_description = '[args]'
diff --git a/src/mailman/commands/eml_end.py b/src/mailman/commands/eml_end.py
index 3cd70813c..32a024205 100644
--- a/src/mailman/commands/eml_end.py
+++ b/src/mailman/commands/eml_end.py
@@ -17,6 +17,8 @@
"""The email commands 'end' and 'stop'."""
+from __future__ import absolute_import, print_function, unicode_literals
+
__metaclass__ = type
__all__ = [
'End',
@@ -24,16 +26,16 @@ __all__ = [
]
-from zope.interface import implements
+from zope.interface import implementer
from mailman.core.i18n import _
from mailman.interfaces.command import ContinueProcessing, IEmailCommand
+@implementer(IEmailCommand)
class End:
"""The email 'end' command."""
- implements(IEmailCommand)
name = 'end'
argument_description = ''
diff --git a/src/mailman/commands/eml_help.py b/src/mailman/commands/eml_help.py
index 6fddb4ef3..a27717179 100644
--- a/src/mailman/commands/eml_help.py
+++ b/src/mailman/commands/eml_help.py
@@ -25,7 +25,7 @@ __all__ = [
]
-from zope.interface import implements
+from zope.interface import implementer
from mailman.config import config
from mailman.core.i18n import _
@@ -37,11 +37,10 @@ SPACE = ' '
+@implementer(IEmailCommand)
class Help:
"""The email 'help' command."""
- implements(IEmailCommand)
-
name = 'help'
argument_description = '[command]'
description = _('Get help about available email commands.')
@@ -58,14 +57,14 @@ class Help:
command = config.commands[command_name]
short_description = getattr(
command, 'short_description', _('n/a'))
- print(format.format(command.name, short_description),
+ print(format.format(command.name, short_description),
file=results)
return ContinueProcessing.yes
elif len(arguments) == 1:
command_name = arguments[0]
command = config.commands.get(command_name)
if command is None:
- print(_('$self.name: no such command: $command_name'),
+ print(_('$self.name: no such command: $command_name'),
file=results)
return ContinueProcessing.no
print('{0} {1}'.format(command.name, command.argument_description),
diff --git a/src/mailman/commands/eml_membership.py b/src/mailman/commands/eml_membership.py
index d6f7a47d9..860e42f47 100644
--- a/src/mailman/commands/eml_membership.py
+++ b/src/mailman/commands/eml_membership.py
@@ -30,7 +30,7 @@ __all__ = [
from email.utils import formataddr, parseaddr
from zope.component import getUtility
-from zope.interface import implements
+from zope.interface import implementer
from mailman.core.i18n import _
from mailman.interfaces.command import ContinueProcessing, IEmailCommand
@@ -41,11 +41,10 @@ from mailman.interfaces.usermanager import IUserManager
+@implementer(IEmailCommand)
class Join:
"""The email 'join' command."""
- implements(IEmailCommand)
-
name = 'join'
# XXX 2012-02-29 BAW: DeliveryMode.summary is not yet supported.
argument_description = '[digest=<no|mime|plain>]'
@@ -89,7 +88,7 @@ used.
if len(members) > 0:
print(_('$person is already a member'), file=results)
else:
- getUtility(IRegistrar).register(mlist, address,
+ getUtility(IRegistrar).register(mlist, address,
display_name, delivery_mode)
print(_('Confirmation email sent to $person'), file=results)
return ContinueProcessing.yes
@@ -131,14 +130,13 @@ class Subscribe(Join):
+@implementer(IEmailCommand)
class Leave:
"""The email 'leave' command."""
- implements(IEmailCommand)
-
name = 'leave'
argument_description = ''
- description = _("""Leave this mailing list.
+ description = _("""Leave this mailing list.
You may be asked to confirm your request.""")
short_description = _('Leave this mailing list.')