diff options
| author | Barry Warsaw | 2017-07-22 03:02:06 +0000 |
|---|---|---|
| committer | Barry Warsaw | 2017-07-22 03:02:06 +0000 |
| commit | 02826321d0430d7ffc1f674eeff4221941689ef7 (patch) | |
| tree | 1a8e56dff0eab71e58e5fc9ecc5f3c614d7edca7 /src/mailman/commands/cli_unshunt.py | |
| parent | f54c045519300f6f70947d1114f46c2b8ae0d368 (diff) | |
| parent | f00b94f18e1d82d1488cbcee6053f03423bc2f49 (diff) | |
| download | mailman-02826321d0430d7ffc1f674eeff4221941689ef7.tar.gz mailman-02826321d0430d7ffc1f674eeff4221941689ef7.tar.zst mailman-02826321d0430d7ffc1f674eeff4221941689ef7.zip | |
Diffstat (limited to 'src/mailman/commands/cli_unshunt.py')
| -rw-r--r-- | src/mailman/commands/cli_unshunt.py | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/src/mailman/commands/cli_unshunt.py b/src/mailman/commands/cli_unshunt.py index 0c1d0a0dd..98f57b838 100644 --- a/src/mailman/commands/cli_unshunt.py +++ b/src/mailman/commands/cli_unshunt.py @@ -18,45 +18,44 @@ """The 'unshunt' command.""" import sys +import click from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from mailman.utilities.options import I18nCommand from public import public from zope.interface import implementer +@click.command( + cls=I18nCommand, + help=_('Unshunt messages.')) +@click.option( + '--discard', '-d', + is_flag=True, default=False, + help=_("""\ + Discard all shunted messages instead of moving them back to their original + queue.""")) +def unshunt(discard): + shunt_queue = config.switchboards['shunt'] + shunt_queue.recover_backup_files() + for filebase in shunt_queue.files: + try: + msg, msgdata = shunt_queue.dequeue(filebase) + which_queue = msgdata.get('whichq', 'in') + if not discard: + config.switchboards[which_queue].enqueue(msg, msgdata) + except Exception as error: + print(_('Cannot unshunt message $filebase, skipping:\n$error'), + file=sys.stderr) + else: + # Unlink the .bak file left by dequeue() + shunt_queue.finish(filebase) + + @public @implementer(ICLISubCommand) class Unshunt: - """Unshunt messages.""" - name = 'unshunt' - - def add(self, parser, command_parser): - """See `ICLISubCommand`.""" - self.parser = parser - command_parser.add_argument( - '-d', '--discard', - default=False, action='store_true', - help=_("""\ - Discard all shunted messages instead of moving them back to their - original queue.""")) - - def process(self, args): - """See `ICLISubCommand`.""" - shunt_queue = config.switchboards['shunt'] - shunt_queue.recover_backup_files() - - for filebase in shunt_queue.files: - try: - msg, msgdata = shunt_queue.dequeue(filebase) - which_queue = msgdata.get('whichq', 'in') - if not args.discard: - config.switchboards[which_queue].enqueue(msg, msgdata) - except Exception: - print(_('Cannot unshunt message $filebase, skipping:\n$error'), - file=sys.stderr) - else: - # Unlink the .bak file left by dequeue() - shunt_queue.finish(filebase) + command = unshunt |
