VirtualMailManager/cli/subcommands.py
author Pascal Volk <user@localhost.localdomain.org>
Mon, 27 Aug 2012 22:24:11 +0000
changeset 596 607aa5c2acc4
parent 593 3dc1764c23d2
child 597 c79fdce49908
permissions -rw-r--r--
pgsql/create_tables.pgsql: Eliminated two unnecessary differences. Yeah, cosmetic only.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
# -*- coding: UTF-8 -*-
568
14abdd04ddf5 Updated copyright notices to include the year 2012.
Pascal Volk <user@localhost.localdomain.org>
parents: 565
diff changeset
     2
# Copyright (c) 2007 - 2012, Pascal Volk
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     3
# See COPYING for distribution information.
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     4
"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     5
    VirtualMailManager.cli.subcommands
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     6
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     7
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     8
    VirtualMailManager's cli subcommands.
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     9
"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    10
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    11
import locale
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    12
import os
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    13
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    14
from textwrap import TextWrapper
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    15
from time import strftime, strptime
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    16
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    17
from VirtualMailManager import ENCODING
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    18
from VirtualMailManager.cli import get_winsize, prog, w_err, w_std
596
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    19
from VirtualMailManager.cli.clihelp import help_msgs
532
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
    20
from VirtualMailManager.common import human_size, size_in_bytes, \
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
    21
     version_str, format_domain_default
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    22
from VirtualMailManager.constants import __copyright__, __date__, \
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    23
     __version__, ACCOUNT_EXISTS, ALIAS_EXISTS, ALIASDOMAIN_ISDOMAIN, \
555
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
    24
     DOMAIN_ALIAS_EXISTS, INVALID_ARGUMENT, EX_MISSING_ARGS, \
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
    25
     RELOCATED_EXISTS, TYPE_ACCOUNT, TYPE_ALIAS, TYPE_RELOCATED
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    26
from VirtualMailManager.errors import VMMError
462
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
    27
from VirtualMailManager.password import list_schemes
445
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
    28
from VirtualMailManager.serviceset import SERVICES
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    29
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    30
__all__ = (
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    31
    'Command', 'RunContext', 'cmd_map', 'usage', 'alias_add', 'alias_delete',
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    32
    'alias_info', 'aliasdomain_add', 'aliasdomain_delete', 'aliasdomain_info',
506
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
    33
    'aliasdomain_switch', 'catchall_add', 'catchall_info', 'catchall_delete',
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
    34
    'config_get', 'config_set', 'configure',
403
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
    35
    'domain_add', 'domain_delete',  'domain_info', 'domain_quota',
539
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
    36
    'domain_services', 'domain_transport', 'domain_note', 'get_user', 'help_',
555
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
    37
    'list_domains', 'list_pwschemes', 'list_users', 'list_aliases',
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
    38
    'list_relocated', 'list_addresses', 'relocated_add', 'relocated_delete',
539
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
    39
    'relocated_info', 'user_add', 'user_delete', 'user_info', 'user_name',
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
    40
    'user_password', 'user_quota', 'user_services', 'user_transport',
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
    41
    'user_note', 'version',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    42
)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    43
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    44
_ = lambda msg: msg
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    45
txt_wrpr = TextWrapper(width=get_winsize()[1] - 1)
420
d4a341248500 VMM/cli/subcommands: Added function update_cmd_map().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 418
diff changeset
    46
cmd_map = {}
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    47
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    48
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    49
class Command(object):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    50
    """Container class for command information."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    51
    __slots__ = ('name', 'alias', 'func', 'args', 'descr')
596
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    52
    FMT_HLP_USAGE = """
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    53
usage: %(prog)s %(name)s %(args)s
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    54
       %(prog)s %(alias)s %(args)s
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    55
"""
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    56
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    57
    def __init__(self, name, alias, func, args, descr):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    58
        """Create a new Command instance.
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    59
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    60
        Arguments:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    61
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    62
        `name` : str
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    63
          the command name, e.g. ``addalias``
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    64
        `alias` : str
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    65
          the command's short alias, e.g. ``aa``
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    66
        `func` : callable
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    67
          the function to handle the command
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    68
        `args` : str
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    69
          argument placeholders, e.g. ``aliasaddress``
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    70
        `descr` : str
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    71
          short description of the command
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    72
        """
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    73
        self.name = name
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    74
        self.alias = alias
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    75
        self.func = func
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    76
        self.args = args
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    77
        self.descr = descr
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    78
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    79
    @property
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    80
    def usage(self):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    81
        """the command's usage info."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    82
        return u'%s %s %s' % (prog, self.name, self.args)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    83
596
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    84
    def help_(self):
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    85
        old_ii = txt_wrpr.initial_indent
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    86
        old_si = txt_wrpr.subsequent_indent
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    87
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    88
        txt_wrpr.subsequent_indent = (len(self.name) + 2) * ' '
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    89
        w_std(txt_wrpr.fill('%s: %s' % (self.name, self.descr)))
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    90
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    91
        info = Command.FMT_HLP_USAGE % dict(alias=self.alias, args=self.args,
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    92
                                            name=self.name, prog=prog)
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    93
        w_std(info)
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    94
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    95
        txt_wrpr.initial_indent = txt_wrpr.subsequent_indent = ' '
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    96
        try:
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    97
            [w_std(txt_wrpr.fill(_(para)) + '\n') for para
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    98
                    in help_msgs[self.name]]
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
    99
        except KeyError:
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
   100
            w_err(1, "'help %s' not yet documented." % self.name,
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
   101
                  'see also: vmm(1)')
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
   102
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   103
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   104
class RunContext(object):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   105
    """Contains all information necessary to run a subcommand."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   106
    __slots__ = ('argc', 'args', 'cget', 'hdlr', 'scmd')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   107
    plan_a_b = _(u'Plan A failed ... trying Plan B: %(subcommand)s %(object)s')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   108
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   109
    def __init__(self, argv, handler, command):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   110
        """Create a new RunContext"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   111
        self.argc = len(argv)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   112
        self.args = [unicode(arg, ENCODING) for arg in argv]
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   113
        self.cget = handler.cfg_dget
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   114
        self.hdlr = handler
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   115
        self.scmd = command
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   116
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   117
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   118
def alias_add(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   119
    """create a new alias e-mail address"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   120
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   121
        usage(EX_MISSING_ARGS, _(u'Missing alias address and destination.'),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   122
              ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   123
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   124
        usage(EX_MISSING_ARGS, _(u'Missing destination address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   125
    ctx.hdlr.alias_add(ctx.args[2].lower(), *ctx.args[3:])
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   126
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   127
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   128
def alias_delete(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   129
    """delete the specified alias e-mail address or one of its destinations"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   130
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   131
        usage(EX_MISSING_ARGS, _(u'Missing alias address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   132
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   133
        ctx.hdlr.alias_delete(ctx.args[2].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   134
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   135
        ctx.hdlr.alias_delete(ctx.args[2].lower(), ctx.args[3])
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   136
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   137
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   138
def alias_info(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   139
    """show the destination(s) of the specified alias"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   140
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   141
        usage(EX_MISSING_ARGS, _(u'Missing alias address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   142
    address = ctx.args[2].lower()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   143
    try:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   144
        _print_aliase_info(address, ctx.hdlr.alias_info(address))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   145
    except VMMError, err:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   146
        if err.code is ACCOUNT_EXISTS:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   147
            w_err(0, ctx.plan_a_b % {'subcommand': u'userinfo',
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   148
                  'object': address})
376
2af61bc06215 VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
   149
            ctx.scmd = ctx.args[1] = 'userinfo'
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   150
            user_info(ctx)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   151
        elif err.code is RELOCATED_EXISTS:
455
b15960e9c53c VMM/cli/subcommands: Fixed a small failure in alias_info().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 448
diff changeset
   152
            w_err(0, ctx.plan_a_b % {'subcommand': u'relocatedinfo',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   153
                  'object': address})
376
2af61bc06215 VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
   154
            ctx.scmd = ctx.args[1] = 'relocatedinfo'
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   155
            relocated_info(ctx)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   156
        else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   157
            raise
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   158
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   159
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   160
def aliasdomain_add(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   161
    """create a new alias for an existing domain"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   162
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   163
        usage(EX_MISSING_ARGS, _(u'Missing alias domain name and destination '
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   164
                                 u'domain name.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   165
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   166
        usage(EX_MISSING_ARGS, _(u'Missing destination domain name.'),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   167
              ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   168
    ctx.hdlr.aliasdomain_add(ctx.args[2].lower(), ctx.args[3].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   169
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   170
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   171
def aliasdomain_delete(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   172
    """delete the specified alias domain"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   173
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   174
        usage(EX_MISSING_ARGS, _(u'Missing alias domain name.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   175
    ctx.hdlr.aliasdomain_delete(ctx.args[2].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   176
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   177
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   178
def aliasdomain_info(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   179
    """show the destination of the given alias domain"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   180
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   181
        usage(EX_MISSING_ARGS, _(u'Missing alias domain name.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   182
    try:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   183
        _print_aliasdomain_info(ctx.hdlr.aliasdomain_info(ctx.args[2].lower()))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   184
    except VMMError, err:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   185
        if err.code is ALIASDOMAIN_ISDOMAIN:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   186
            w_err(0, ctx.plan_a_b % {'subcommand': u'domaininfo',
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   187
                  'object': ctx.args[2].lower()})
409
54a89c19e534 VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents: 408
diff changeset
   188
            ctx.scmd = ctx.args[1] = 'domaininfo'
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   189
            domain_info(ctx)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   190
        else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   191
            raise
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   192
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   193
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   194
def aliasdomain_switch(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   195
    """assign the given alias domain to an other domain"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   196
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   197
        usage(EX_MISSING_ARGS, _(u'Missing alias domain name and destination '
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   198
                                 u'domain name.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   199
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   200
        usage(EX_MISSING_ARGS, _(u'Missing destination domain name.'),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   201
              ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   202
    ctx.hdlr.aliasdomain_switch(ctx.args[2].lower(), ctx.args[3].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   203
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   204
506
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   205
def catchall_add(ctx):
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   206
    """create a new catchall alias e-mail address"""
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   207
    if ctx.argc < 3:
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   208
        usage(EX_MISSING_ARGS, _(u'Missing domain and destination.'),
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   209
              ctx.scmd)
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   210
    elif ctx.argc < 4:
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   211
        usage(EX_MISSING_ARGS, _(u'Missing destination address.'), ctx.scmd)
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   212
    ctx.hdlr.catchall_add(ctx.args[2].lower(), *ctx.args[3:])
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   213
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   214
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   215
def catchall_delete(ctx):
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   216
    """delete the specified destination or all of the catchall destination"""
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   217
    if ctx.argc < 3:
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   218
        usage(EX_MISSING_ARGS, _(u'Missing domain.'), ctx.scmd)
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   219
    elif ctx.argc < 4:
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   220
        ctx.hdlr.catchall_delete(ctx.args[2].lower())
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   221
    else:
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   222
        ctx.hdlr.catchall_delete(ctx.args[2].lower(), ctx.args[3])
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   223
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   224
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   225
def catchall_info(ctx):
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   226
    """show the catchall destination(s) of the specified domain"""
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   227
    if ctx.argc < 3:
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   228
        usage(EX_MISSING_ARGS, _(u'Missing domain.'), ctx.scmd)
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   229
    address = ctx.args[2].lower()
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   230
    _print_catchall_info(address, ctx.hdlr.catchall_info(address))
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   231
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   232
345
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   233
def config_get(ctx):
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   234
    """show the actual value of the configuration option"""
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   235
    if ctx.argc < 3:
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   236
        usage(EX_MISSING_ARGS, _(u"Missing option name."), ctx.scmd)
397
cf661a40266d VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents: 376
diff changeset
   237
cf661a40266d VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents: 376
diff changeset
   238
    noop = lambda option: option
cf661a40266d VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents: 376
diff changeset
   239
    opt_formater = {
cf661a40266d VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents: 376
diff changeset
   240
        'misc.dovecot_version': version_str,
458
4ff0fa3ba0fa VMM/config: Moved some options to section `domain':
Pascal Volk <neverseen@users.sourceforge.net>
parents: 456
diff changeset
   241
        'domain.quota_bytes': human_size,
397
cf661a40266d VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents: 376
diff changeset
   242
    }
cf661a40266d VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents: 376
diff changeset
   243
345
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   244
    option = ctx.args[2].lower()
397
cf661a40266d VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents: 376
diff changeset
   245
    w_std('%s = %s' % (option, opt_formater.get(option,
cf661a40266d VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents: 376
diff changeset
   246
                       noop)(ctx.cget(option))))
345
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   247
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   248
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   249
def config_set(ctx):
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   250
    """set a new value for the configuration option"""
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   251
    if ctx.argc < 3:
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   252
        usage(EX_MISSING_ARGS, _(u'Missing option and new value.'), ctx.scmd)
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   253
    if ctx.argc < 4:
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   254
        usage(EX_MISSING_ARGS, _(u'Missing new configuration value.'),
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   255
              ctx.scmd)
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   256
    ctx.hdlr.cfg_set(ctx.args[2].lower(), ctx.args[3])
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   257
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   258
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   259
def configure(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   260
    """start interactive configuration modus"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   261
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   262
        ctx.hdlr.configure()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   263
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   264
        ctx.hdlr.configure(ctx.args[2].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   265
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   266
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   267
def domain_add(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   268
    """create a new domain"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   269
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   270
        usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   271
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   272
        ctx.hdlr.domain_add(ctx.args[2].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   273
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   274
        ctx.hdlr.domain_add(ctx.args[2].lower(), ctx.args[3])
456
7847f949d0a2 VMM/cli/subcommands: Small improvement in domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 455
diff changeset
   275
    if ctx.cget('domain.auto_postmaster'):
7847f949d0a2 VMM/cli/subcommands: Small improvement in domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 455
diff changeset
   276
        w_std(_(u'Creating account for postmaster@%s') % ctx.args[2].lower())
7847f949d0a2 VMM/cli/subcommands: Small improvement in domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 455
diff changeset
   277
        ctx.scmd = 'useradd'
7847f949d0a2 VMM/cli/subcommands: Small improvement in domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 455
diff changeset
   278
        ctx.args = [prog, ctx.scmd, u'postmaster@' + ctx.args[2].lower()]
7847f949d0a2 VMM/cli/subcommands: Small improvement in domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 455
diff changeset
   279
        ctx.argc = 3
7847f949d0a2 VMM/cli/subcommands: Small improvement in domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 455
diff changeset
   280
        user_add(ctx)
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   281
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   282
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   283
def domain_delete(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   284
    """delete the given domain and all its alias domains"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   285
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   286
        usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   287
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   288
        ctx.hdlr.domain_delete(ctx.args[2].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   289
    elif ctx.args[3].lower() == 'force':
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   290
        ctx.hdlr.domain_delete(ctx.args[2].lower(), True)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   291
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   292
        usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % ctx.args[3],
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   293
              ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   294
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   295
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   296
def domain_info(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   297
    """display information about the given domain"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   298
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   299
        usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   300
    if ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   301
        details = None
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   302
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   303
        details = ctx.args[3].lower()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   304
        if details not in ('accounts', 'aliasdomains', 'aliases', 'full',
510
1fa354bbdb90 Add catchall info to domain_info output
martin f. krafft <madduck@madduck.net>
parents: 506
diff changeset
   305
                           'relocated', 'catchall'):
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   306
            usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % details,
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   307
                  ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   308
    try:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   309
        info = ctx.hdlr.domain_info(ctx.args[2].lower(), details)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   310
    except VMMError, err:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   311
        if err.code is DOMAIN_ALIAS_EXISTS:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   312
            w_err(0, ctx.plan_a_b % {'subcommand': u'aliasdomaininfo',
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   313
                  'object': ctx.args[2].lower()})
409
54a89c19e534 VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents: 408
diff changeset
   314
            ctx.scmd = ctx.args[1] = 'aliasdomaininfo'
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   315
            aliasdomain_info(ctx)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   316
        else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   317
            raise
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   318
    else:
414
ae1a8428298c VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents: 413
diff changeset
   319
        q_limit = u'Storage: %(bytes)s; Messages: %(messages)s'
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   320
        if not details:
408
f6e55b27fe07 VMM/cli/subcommands: Fixed a msgid issue (format string with unnamed arguments).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 406
diff changeset
   321
            info['bytes'] = human_size(info['bytes'])
414
ae1a8428298c VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents: 413
diff changeset
   322
            info['messages'] = locale.format('%d', info['messages'], True)
474
4353981e3a7f VMM/cli/subcommands: Small improvement of domaininfo's output.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 471
diff changeset
   323
            info['quota limit/user'] = q_limit % info
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   324
            _print_info(ctx, info, _(u'Domain'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   325
        else:
408
f6e55b27fe07 VMM/cli/subcommands: Fixed a msgid issue (format string with unnamed arguments).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 406
diff changeset
   326
            info[0]['bytes'] = human_size(info[0]['bytes'])
414
ae1a8428298c VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents: 413
diff changeset
   327
            info[0]['messages'] = locale.format('%d', info[0]['messages'],
ae1a8428298c VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents: 413
diff changeset
   328
                                                True)
474
4353981e3a7f VMM/cli/subcommands: Small improvement of domaininfo's output.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 471
diff changeset
   329
            info[0]['quota limit/user'] = q_limit % info[0]
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   330
            _print_info(ctx, info[0], _(u'Domain'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   331
            if details == u'accounts':
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   332
                _print_list(info[1], _(u'accounts'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   333
            elif details == u'aliasdomains':
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   334
                _print_list(info[1], _(u'alias domains'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   335
            elif details == u'aliases':
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   336
                _print_list(info[1], _(u'aliases'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   337
            elif details == u'relocated':
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   338
                _print_list(info[1], _(u'relocated users'))
510
1fa354bbdb90 Add catchall info to domain_info output
martin f. krafft <madduck@madduck.net>
parents: 506
diff changeset
   339
            elif details == u'catchall':
1fa354bbdb90 Add catchall info to domain_info output
martin f. krafft <madduck@madduck.net>
parents: 506
diff changeset
   340
                _print_list(info[1], _(u'catch-all destinations'))
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   341
            else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   342
                _print_list(info[1], _(u'alias domains'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   343
                _print_list(info[2], _(u'accounts'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   344
                _print_list(info[3], _(u'aliases'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   345
                _print_list(info[4], _(u'relocated users'))
510
1fa354bbdb90 Add catchall info to domain_info output
martin f. krafft <madduck@madduck.net>
parents: 506
diff changeset
   346
                _print_list(info[5], _(u'catch-all destinations'))
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   347
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   348
403
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   349
def domain_quota(ctx):
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   350
    """update the quota limit of the specified domain"""
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   351
    if ctx.argc < 3:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   352
        usage(EX_MISSING_ARGS, _(u'Missing domain name and storage value.'),
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   353
              ctx.scmd)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   354
    if ctx.argc < 4:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   355
        usage(EX_MISSING_ARGS, _(u'Missing storage value.'), ctx.scmd)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   356
    messages = 0
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   357
    force = None
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   358
    try:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   359
        bytes_ = size_in_bytes(ctx.args[3])
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   360
    except (ValueError, TypeError):
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   361
        usage(INVALID_ARGUMENT, _(u"Invalid storage value: '%s'") %
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   362
              ctx.args[3], ctx.scmd)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   363
    if ctx.argc < 5:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   364
        pass
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   365
    elif ctx.argc < 6:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   366
        try:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   367
            messages = int(ctx.args[4])
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   368
        except ValueError:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   369
            if ctx.args[4].lower() != 'force':
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   370
                usage(INVALID_ARGUMENT,
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   371
                      _(u"Neither a valid number of messages nor the keyword "
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   372
                        u"'force': '%s'") % ctx.args[4], ctx.scmd)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   373
            force = 'force'
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   374
    else:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   375
        try:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   376
            messages = int(ctx.args[4])
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   377
        except ValueError:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   378
            usage(INVALID_ARGUMENT,
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   379
                  _(u"Not a valid number of messages: '%s'") % ctx.args[4],
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   380
                  ctx.scmd)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   381
        if ctx.args[5].lower() != 'force':
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   382
            usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % ctx.args[5],
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   383
                  ctx.scmd)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   384
        force = 'force'
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   385
    ctx.hdlr.domain_quotalimit(ctx.args[2].lower(), bytes_, messages, force)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   386
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   387
445
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   388
def domain_services(ctx):
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   389
    """allow all named service and block the uncredited."""
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   390
    if ctx.argc < 3:
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   391
        usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd)
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   392
    services = []
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   393
    force = False
448
45c917e6a386 VMM/cli/subcommands: domainservices: Don't fail when neither a
Pascal Volk <neverseen@users.sourceforge.net>
parents: 447
diff changeset
   394
    if ctx.argc is 3:
45c917e6a386 VMM/cli/subcommands: domainservices: Don't fail when neither a
Pascal Volk <neverseen@users.sourceforge.net>
parents: 447
diff changeset
   395
        pass
45c917e6a386 VMM/cli/subcommands: domainservices: Don't fail when neither a
Pascal Volk <neverseen@users.sourceforge.net>
parents: 447
diff changeset
   396
    elif ctx.argc is 4:
445
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   397
        arg = ctx.args[3].lower()
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   398
        if arg in SERVICES:
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   399
            services.append(arg)
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   400
        elif arg == 'force':
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   401
            force = True
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   402
        else:
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   403
            usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % arg,
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   404
                  ctx.scmd)
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   405
    else:
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   406
        services.extend([service.lower() for service in ctx.args[3:-1]])
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   407
        arg = ctx.args[-1].lower()
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   408
        if arg == 'force':
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   409
            force = True
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   410
        else:
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   411
            services.append(arg)
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   412
        unknown = [service for service in services if service not in SERVICES]
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   413
        if unknown:
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   414
            usage(INVALID_ARGUMENT, _(u'Invalid service arguments: %s') %
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   415
                  ' '.join(unknown), ctx.scmd)
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   416
    ctx.hdlr.domain_services(ctx.args[2].lower(), (None, 'force')[force],
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   417
                             *services)
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   418
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   419
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   420
def domain_transport(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   421
    """update the transport of the specified domain"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   422
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   423
        usage(EX_MISSING_ARGS, _(u'Missing domain name and new transport.'),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   424
              ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   425
    if ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   426
        usage(EX_MISSING_ARGS, _(u'Missing new transport.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   427
    if ctx.argc < 5:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   428
        ctx.hdlr.domain_transport(ctx.args[2].lower(), ctx.args[3])
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   429
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   430
        force = ctx.args[4].lower()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   431
        if force != 'force':
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   432
            usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % force,
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   433
                  ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   434
        ctx.hdlr.domain_transport(ctx.args[2].lower(), ctx.args[3], force)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   435
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   436
539
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   437
def domain_note(ctx):
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   438
    """update the note of the given domain"""
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   439
    if ctx.argc < 3:
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   440
        usage(EX_MISSING_ARGS, _(u'Missing domain name.'),
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   441
              ctx.scmd)
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   442
    elif ctx.argc < 4:
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   443
        note = None
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   444
    else:
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   445
        note = ' '.join(ctx.args[3:])
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   446
    ctx.hdlr.domain_note(ctx.args[2].lower(), note)
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   447
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   448
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   449
def get_user(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   450
    """get the address of the user with the given UID"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   451
    if ctx.argc < 3:
417
8209da83e256 VMM: Updated some messages. (doesn't, isn't) -> (does not, is not)
Pascal Volk <neverseen@users.sourceforge.net>
parents: 414
diff changeset
   452
        usage(EX_MISSING_ARGS, _(u'Missing UID.'), ctx.scmd)
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   453
    _print_info(ctx, ctx.hdlr.user_by_uid(ctx.args[2]), _(u'Account'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   454
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   455
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   456
def help_(ctx):
403
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   457
    """print help messages."""
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   458
    if ctx.argc > 2:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   459
        hlptpc = ctx.args[2].lower()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   460
        if hlptpc in cmd_map:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   461
            topic = hlptpc
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   462
        else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   463
            for scmd in cmd_map.itervalues():
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   464
                if scmd.alias == hlptpc:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   465
                    topic = scmd.name
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   466
                    break
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   467
            else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   468
                usage(INVALID_ARGUMENT, _(u"Unknown help topic: '%s'") %
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   469
                      ctx.args[2], ctx.scmd)
596
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
   470
        if topic != u'help':
607aa5c2acc4 pgsql/create_tables.pgsql: Eliminated two unnecessary differences.
Pascal Volk <user@localhost.localdomain.org>
parents: 593
diff changeset
   471
            return cmd_map[topic].help_()
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   472
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   473
    old_ii = txt_wrpr.initial_indent
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   474
    old_si = txt_wrpr.subsequent_indent
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   475
    txt_wrpr.initial_indent = ' '
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   476
    # len(max(_overview.iterkeys(), key=len)) #Py25
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   477
    txt_wrpr.subsequent_indent = 20 * ' '
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   478
    order = cmd_map.keys()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   479
    order.sort()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   480
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   481
    w_std(_(u'List of available subcommands:') + '\n')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   482
    for key in order:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   483
        w_std('\n'.join(txt_wrpr.wrap('%-18s %s' % (key, cmd_map[key].descr))))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   484
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   485
    txt_wrpr.initial_indent = old_ii
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   486
    txt_wrpr.subsequent_indent = old_si
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   487
    txt_wrpr.initial_indent = ''
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   488
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   489
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   490
def list_domains(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   491
    """list all domains / search domains by pattern"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   492
    matching = ctx.argc > 2
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   493
    if matching:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   494
        gids, domains = ctx.hdlr.domain_list(ctx.args[2].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   495
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   496
        gids, domains = ctx.hdlr.domain_list()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   497
    _print_domain_list(gids, domains, matching)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   498
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   499
462
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   500
def list_pwschemes(ctx_unused):
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   501
    """Prints all usable password schemes and password encoding suffixes."""
471
5d0114f7bb99 VMM/cli/subcommands: Use the common output formatting in list_pwschemes().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 469
diff changeset
   502
    # TODO: Remove trailing colons from keys.
5d0114f7bb99 VMM/cli/subcommands: Use the common output formatting in list_pwschemes().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 469
diff changeset
   503
    # For now it is to late, the translators has stared their work
462
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   504
    keys = (_(u'Usable password schemes:'), _(u'Usable encoding suffixes:'))
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   505
    old_ii, old_si = txt_wrpr.initial_indent, txt_wrpr.subsequent_indent
471
5d0114f7bb99 VMM/cli/subcommands: Use the common output formatting in list_pwschemes().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 469
diff changeset
   506
    txt_wrpr.initial_indent = txt_wrpr.subsequent_indent = '\t'
5d0114f7bb99 VMM/cli/subcommands: Use the common output formatting in list_pwschemes().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 469
diff changeset
   507
    txt_wrpr.width = txt_wrpr.width - 8
462
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   508
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   509
    for key, value in zip(keys, list_schemes()):
471
5d0114f7bb99 VMM/cli/subcommands: Use the common output formatting in list_pwschemes().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 469
diff changeset
   510
        if key.endswith(':'):  # who knows … (see TODO above)
481
90d69ae4f40d VMM: The Python 2.4.x compatibility commit.
Pascal Volk <user@localhost.localdomain.org>
parents: 474
diff changeset
   511
            #key = key.rpartition(':')[0]
90d69ae4f40d VMM: The Python 2.4.x compatibility commit.
Pascal Volk <user@localhost.localdomain.org>
parents: 474
diff changeset
   512
            key = key[:-1]  # This one is for Py24
471
5d0114f7bb99 VMM/cli/subcommands: Use the common output formatting in list_pwschemes().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 469
diff changeset
   513
        w_std(key, len(key) * '-')
5d0114f7bb99 VMM/cli/subcommands: Use the common output formatting in list_pwschemes().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 469
diff changeset
   514
        w_std('\n'.join(txt_wrpr.wrap(' '.join(value))), '')
462
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   515
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   516
    txt_wrpr.initial_indent, txt_wrpr.subsequent_indent = old_ii, old_si
471
5d0114f7bb99 VMM/cli/subcommands: Use the common output formatting in list_pwschemes().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 469
diff changeset
   517
    txt_wrpr.width = txt_wrpr.width + 8
462
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   518
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   519
555
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   520
def list_addresses(ctx, limit=None):
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   521
    """List all addresses / search addresses by pattern. The output can be
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   522
    limited with TYPE_ACCOUNT, TYPE_ALIAS and TYPE_RELOCATED, which can be
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   523
    bitwise ORed as a combination. Not specifying a limit is the same as
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   524
    combining all three."""
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   525
    if limit is None:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   526
        limit = TYPE_ACCOUNT | TYPE_ALIAS | TYPE_RELOCATED
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   527
    matching = ctx.argc > 2
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   528
    if matching:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   529
        gids, addresses = ctx.hdlr.address_list(limit, ctx.args[2].lower())
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   530
    else:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   531
        gids, addresses = ctx.hdlr.address_list(limit)
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   532
    _print_address_list(limit, gids, addresses, matching)
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   533
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   534
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   535
def list_users(ctx):
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   536
    """list all user accounts / search user accounts by pattern"""
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   537
    return list_addresses(ctx, TYPE_ACCOUNT)
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   538
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   539
def list_aliases(ctx):
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   540
    """list all aliases / search aliases by pattern"""
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   541
    return list_addresses(ctx, TYPE_ALIAS)
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   542
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   543
def list_relocated(ctx):
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   544
    """list all relocated records / search relocated records by pattern"""
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   545
    return list_addresses(ctx, TYPE_RELOCATED)
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   546
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   547
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   548
def relocated_add(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   549
    """create a new record for a relocated user"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   550
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   551
        usage(EX_MISSING_ARGS,
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   552
              _(u'Missing relocated address and destination.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   553
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   554
        usage(EX_MISSING_ARGS, _(u'Missing destination address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   555
    ctx.hdlr.relocated_add(ctx.args[2].lower(), ctx.args[3])
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   556
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   557
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   558
def relocated_delete(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   559
    """delete the record of the relocated user"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   560
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   561
        usage(EX_MISSING_ARGS, _(u'Missing relocated address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   562
    ctx.hdlr.relocated_delete(ctx.args[2].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   563
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   564
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   565
def relocated_info(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   566
    """print information about a relocated user"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   567
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   568
        usage(EX_MISSING_ARGS, _(u'Missing relocated address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   569
    relocated = ctx.args[2].lower()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   570
    try:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   571
        _print_relocated_info(addr=relocated,
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   572
                              dest=ctx.hdlr.relocated_info(relocated))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   573
    except VMMError, err:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   574
        if err.code is ACCOUNT_EXISTS:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   575
            w_err(0, ctx.plan_a_b % {'subcommand': u'userinfo',
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   576
                  'object': relocated})
376
2af61bc06215 VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
   577
            ctx.scmd = ctx.args[1] = 'userinfoi'
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   578
            user_info(ctx)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   579
        elif err.code is ALIAS_EXISTS:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   580
            w_err(0, ctx.plan_a_b % {'subcommand': u'aliasinfo',
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   581
                  'object': relocated})
376
2af61bc06215 VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
   582
            ctx.scmd = ctx.args[1] = 'aliasinfo'
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   583
            alias_info(ctx)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   584
        else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   585
            raise
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   586
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   587
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   588
def user_add(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   589
    """create a new e-mail user with the given address"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   590
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   591
        usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   592
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   593
        password = None
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   594
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   595
        password = ctx.args[3]
361
971577b89d26 VMM/cli/handler: Added support for random passwords in user_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 345
diff changeset
   596
    gen_pass = ctx.hdlr.user_add(ctx.args[2].lower(), password)
423
a43a2e20de71 VMM/cli/subcommands: user_add() show only generated passwords - not the given.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 420
diff changeset
   597
    if ctx.argc < 4 and gen_pass:
361
971577b89d26 VMM/cli/handler: Added support for random passwords in user_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 345
diff changeset
   598
        w_std(_(u"Generated password: %s") % gen_pass)
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   599
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   600
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   601
def user_delete(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   602
    """delete the specified user"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   603
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   604
        usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   605
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   606
        ctx.hdlr.user_delete(ctx.args[2].lower())
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   607
    elif ctx.args[3].lower() == 'force':
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   608
        ctx.hdlr.user_delete(ctx.args[2].lower(), True)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   609
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   610
        usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % ctx.args[3],
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   611
              ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   612
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   613
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   614
def user_info(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   615
    """display information about the given address"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   616
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   617
        usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   618
    if ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   619
        details = None
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   620
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   621
        details = ctx.args[3].lower()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   622
        if details not in ('aliases', 'du', 'full'):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   623
            usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % details,
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   624
                  ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   625
    try:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   626
        info = ctx.hdlr.user_info(ctx.args[2].lower(), details)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   627
    except VMMError, err:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   628
        if err.code is ALIAS_EXISTS:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   629
            w_err(0, ctx.plan_a_b % {'subcommand': u'aliasinfo',
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   630
                  'object': ctx.args[2].lower()})
376
2af61bc06215 VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
   631
            ctx.scmd = ctx.args[1] = 'aliasinfo'
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   632
            alias_info(ctx)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   633
        elif err.code is RELOCATED_EXISTS:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   634
            w_err(0, ctx.plan_a_b % {'subcommand': u'relocatedinfo',
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   635
                  'object': ctx.args[2].lower()})
376
2af61bc06215 VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents: 366
diff changeset
   636
            ctx.scmd = ctx.args[1] = 'relocatedinfo'
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   637
            relocated_info(ctx)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   638
        else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   639
            raise
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   640
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   641
        if details in (None, 'du'):
401
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   642
            info['quota storage'] = _format_quota_usage(info['ql_bytes'],
532
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
   643
                    info['uq_bytes'], True, info['ql_domaindefault'])
401
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   644
            info['quota messages'] = _format_quota_usage(info['ql_messages'],
532
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
   645
                    info['uq_messages'], domaindefault=info['ql_domaindefault'])
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   646
            _print_info(ctx, info, _(u'Account'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   647
        else:
401
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   648
            info[0]['quota storage'] = _format_quota_usage(info[0]['ql_bytes'],
532
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
   649
                    info[0]['uq_bytes'], True, info[0]['ql_domaindefault'])
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
   650
            info[0]['quota messages'] = \
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
   651
                _format_quota_usage(info[0]['ql_messages'],
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
   652
                                    info[0]['uq_messages'],
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
   653
                                    domaindefault=info[0]['ql_domaindefault'])
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   654
            _print_info(ctx, info[0], _(u'Account'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   655
            _print_list(info[1], _(u'alias addresses'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   656
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   657
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   658
def user_name(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   659
    """set or update the real name for an address"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   660
    if ctx.argc < 3:
341
6709d0faf2f5 VMM/…: Unified messages and removed non-ASCII quotes.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 340
diff changeset
   661
        usage(EX_MISSING_ARGS, _(u"Missing e-mail address and user's name."),
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   662
              ctx.scmd)
536
c340ba4bd544 Allow username to take no argument to erase value
martin f. krafft <madduck@madduck.net>
parents: 533
diff changeset
   663
    elif ctx.argc < 4:
c340ba4bd544 Allow username to take no argument to erase value
martin f. krafft <madduck@madduck.net>
parents: 533
diff changeset
   664
        name = None
c340ba4bd544 Allow username to take no argument to erase value
martin f. krafft <madduck@madduck.net>
parents: 533
diff changeset
   665
    else:
c340ba4bd544 Allow username to take no argument to erase value
martin f. krafft <madduck@madduck.net>
parents: 533
diff changeset
   666
        name = ctx.args[3]
c340ba4bd544 Allow username to take no argument to erase value
martin f. krafft <madduck@madduck.net>
parents: 533
diff changeset
   667
    ctx.hdlr.user_name(ctx.args[2].lower(), name)
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   668
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   669
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   670
def user_password(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   671
    """update the password for the given address"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   672
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   673
        usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   674
    elif ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   675
        password = None
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   676
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   677
        password = ctx.args[3]
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   678
    ctx.hdlr.user_password(ctx.args[2].lower(), password)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   679
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   680
539
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   681
def user_note(ctx):
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   682
    """update the note of the given address"""
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   683
    if ctx.argc < 3:
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   684
        usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'),
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   685
              ctx.scmd)
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   686
    elif ctx.argc < 4:
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   687
        note = None
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   688
    else:
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   689
        note = ' '.join(ctx.args[3:])
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   690
    ctx.hdlr.user_note(ctx.args[2].lower(), note)
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   691
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   692
403
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   693
def user_quota(ctx):
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   694
    """update the quota limit for the given address"""
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   695
    if ctx.argc < 3:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   696
        usage(EX_MISSING_ARGS, _(u'Missing e-mail address and storage value.'),
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   697
              ctx.scmd)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   698
    elif ctx.argc < 4:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   699
        usage(EX_MISSING_ARGS, _(u'Missing storage value.'), ctx.scmd)
565
a75923ce2842 VMM/cli/subcommands: Replaced the keyword `default' by `domain'.
Pascal Volk <user@localhost.localdomain.org>
parents: 561
diff changeset
   700
    if ctx.args[3] != 'domain':
559
cc0f67f99780 VMM: The Python 2.4.x compatibility commit.
Pascal Volk <user@localhost.localdomain.org>
parents: 555
diff changeset
   701
        try:
cc0f67f99780 VMM: The Python 2.4.x compatibility commit.
Pascal Volk <user@localhost.localdomain.org>
parents: 555
diff changeset
   702
            bytes_ = size_in_bytes(ctx.args[3])
cc0f67f99780 VMM: The Python 2.4.x compatibility commit.
Pascal Volk <user@localhost.localdomain.org>
parents: 555
diff changeset
   703
        except (ValueError, TypeError):
cc0f67f99780 VMM: The Python 2.4.x compatibility commit.
Pascal Volk <user@localhost.localdomain.org>
parents: 555
diff changeset
   704
            usage(INVALID_ARGUMENT, _(u"Invalid storage value: '%s'") %
cc0f67f99780 VMM: The Python 2.4.x compatibility commit.
Pascal Volk <user@localhost.localdomain.org>
parents: 555
diff changeset
   705
                  ctx.args[3], ctx.scmd)
cc0f67f99780 VMM: The Python 2.4.x compatibility commit.
Pascal Volk <user@localhost.localdomain.org>
parents: 555
diff changeset
   706
    else:
cc0f67f99780 VMM: The Python 2.4.x compatibility commit.
Pascal Volk <user@localhost.localdomain.org>
parents: 555
diff changeset
   707
        bytes_ = ctx.args[3]
403
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   708
    if ctx.argc < 5:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   709
        messages = 0
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   710
    else:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   711
        try:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   712
            messages = int(ctx.args[4])
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   713
        except ValueError:
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   714
            usage(INVALID_ARGUMENT,
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   715
                  _(u"Not a valid number of messages: '%s'") % ctx.args[4],
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   716
                  ctx.scmd)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   717
    ctx.hdlr.user_quotalimit(ctx.args[2].lower(), bytes_, messages)
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   718
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   719
445
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   720
def user_services(ctx):
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   721
    """allow all named service and block the uncredited."""
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   722
    if ctx.argc < 3:
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   723
        usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   724
    services = []
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   725
    if ctx.argc >= 4:
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   726
        services.extend([service.lower() for service in ctx.args[3:]])
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   727
        unknown = [service for service in services if service not in SERVICES]
565
a75923ce2842 VMM/cli/subcommands: Replaced the keyword `default' by `domain'.
Pascal Volk <user@localhost.localdomain.org>
parents: 561
diff changeset
   728
        if unknown and ctx.args[3] != 'domain':
445
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   729
            usage(INVALID_ARGUMENT, _(u'Invalid service arguments: %s') %
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   730
                  ' '.join(unknown), ctx.scmd)
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   731
    ctx.hdlr.user_services(ctx.args[2].lower(), *services)
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   732
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   733
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   734
def user_transport(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   735
    """update the transport of the given address"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   736
    if ctx.argc < 3:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   737
        usage(EX_MISSING_ARGS, _(u'Missing e-mail address and transport.'),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   738
              ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   739
    if ctx.argc < 4:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   740
        usage(EX_MISSING_ARGS, _(u'Missing transport.'), ctx.scmd)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   741
    ctx.hdlr.user_transport(ctx.args[2].lower(), ctx.args[3])
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   742
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   743
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   744
def usage(errno, errmsg, subcommand=None):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   745
    """print usage message for the given command or all commands.
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   746
    When errno > 0, sys,exit(errno) will interrupt the program.
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   747
    """
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   748
    if subcommand and subcommand in cmd_map:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   749
        w_err(errno, _(u"Error: %s") % errmsg,
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   750
              _(u"usage: ") + cmd_map[subcommand].usage)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   751
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   752
    # TP: Please adjust translated words like the original text.
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   753
    # (It's a table header.) Extract from usage text:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   754
    # usage: vmm subcommand arguments
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   755
    #   short long
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   756
    #   subcommand                arguments
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   757
    #
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   758
    #   da    domainadd           fqdn [transport]
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   759
    #   dd    domaindelete        fqdn [force]
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   760
    u_head = _(u"""usage: %s subcommand arguments
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   761
  short long
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   762
  subcommand                arguments\n""") % prog
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   763
    order = cmd_map.keys()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   764
    order.sort()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   765
    w_err(0, u_head)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   766
    for key in order:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   767
        scmd = cmd_map[key]
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   768
        w_err(0, '  %-5s %-19s %s' % (scmd.alias, scmd.name, scmd.args))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   769
    w_err(errno, '', _(u"Error: %s") % errmsg)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   770
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   771
462
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   772
def version(ctx_unused):
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   773
    """Write version and copyright information to stdout."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   774
    w_std('%s, %s %s (%s %s)\nPython %s %s %s\n\n%s\n%s %s' % (prog,
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   775
    # TP: The words 'from', 'version' and 'on' are used in
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   776
    # the version information, e.g.:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   777
    # vmm, version 0.5.2 (from 09/09/09)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   778
    # Python 2.5.4 on FreeBSD
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   779
        _(u'version'), __version__, _(u'from'),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   780
        strftime(locale.nl_langinfo(locale.D_FMT),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   781
            strptime(__date__, '%Y-%m-%d')).decode(ENCODING, 'replace'),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   782
        os.sys.version.split()[0], _(u'on'), os.uname()[0],
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   783
        __copyright__, prog,
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   784
        _(u'is free software and comes with ABSOLUTELY NO WARRANTY.')))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   785
420
d4a341248500 VMM/cli/subcommands: Added function update_cmd_map().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 418
diff changeset
   786
d4a341248500 VMM/cli/subcommands: Added function update_cmd_map().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 418
diff changeset
   787
def update_cmd_map():
d4a341248500 VMM/cli/subcommands: Added function update_cmd_map().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 418
diff changeset
   788
    """Update the cmd_map, after gettext's _ was installed."""
d4a341248500 VMM/cli/subcommands: Added function update_cmd_map().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 418
diff changeset
   789
    cmd = Command
d4a341248500 VMM/cli/subcommands: Added function update_cmd_map().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 418
diff changeset
   790
    cmd_map.update({
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   791
    # Account commands
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   792
    'getuser': cmd('getuser', 'gu', get_user, 'uid',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   793
                   _(u'get the address of the user with the given UID')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   794
    'useradd': cmd('useradd', 'ua', user_add, 'address [password]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   795
                   _(u'create a new e-mail user with the given address')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   796
    'userdelete': cmd('userdelete', 'ud', user_delete, 'address [force]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   797
                      _(u'delete the specified user')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   798
    'userinfo': cmd('userinfo', 'ui', user_info, 'address [details]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   799
                    _(u'display information about the given address')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   800
    'username': cmd('username', 'un', user_name, 'address name',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   801
                    _(u'set or update the real name for an address')),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   802
    'userpassword': cmd('userpassword', 'up', user_password,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   803
                        'address [password]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   804
                        _(u'update the password for the given address')),
403
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   805
    'userquota': cmd('userquota', 'uq', user_quota,
565
a75923ce2842 VMM/cli/subcommands: Replaced the keyword `default' by `domain'.
Pascal Volk <user@localhost.localdomain.org>
parents: 561
diff changeset
   806
                     'address storage [messages] | address domain',
403
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   807
                     _(u'update the quota limit for the given address')),
445
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   808
    'userservices': cmd('userservices', 'us', user_services,
565
a75923ce2842 VMM/cli/subcommands: Replaced the keyword `default' by `domain'.
Pascal Volk <user@localhost.localdomain.org>
parents: 561
diff changeset
   809
                        'address [service ...] | address domain',
445
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   810
                        _(u'enables the specified services and disables all '
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   811
                          u'not specified services')),
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   812
    'usertransport': cmd('usertransport', 'ut', user_transport,
565
a75923ce2842 VMM/cli/subcommands: Replaced the keyword `default' by `domain'.
Pascal Volk <user@localhost.localdomain.org>
parents: 561
diff changeset
   813
                         'address transport | address domain',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   814
                         _(u'update the transport of the given address')),
539
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   815
    'usernote': cmd('usernote', 'uo', user_note,
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   816
                    'address note',
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   817
                    _(u'update the note of the given address')),
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   818
    # Alias commands
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   819
    'aliasadd': cmd('aliasadd', 'aa', alias_add, 'address destination ...',
406
58e23bd7c97f VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 403
diff changeset
   820
                    _(u'create a new alias e-mail address with one or more '
58e23bd7c97f VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 403
diff changeset
   821
                      u'destinations')),
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   822
    'aliasdelete': cmd('aliasdelete', 'ad', alias_delete,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   823
                       'address [destination]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   824
                       _(u'delete the specified alias e-mail address or one '
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   825
                         u'of its destinations')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   826
    'aliasinfo': cmd('aliasinfo', 'ai', alias_info, 'address',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   827
                     _(u'show the destination(s) of the specified alias')),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   828
    # AliasDomain commands
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   829
    'aliasdomainadd': cmd('aliasdomainadd', 'ada', aliasdomain_add,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   830
                          'fqdn destination',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   831
                          _(u'create a new alias for an existing domain')),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   832
    'aliasdomaindelete': cmd('aliasdomaindelete', 'add', aliasdomain_delete,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   833
                             'fqdn', _(u'delete the specified alias domain')),
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   834
    'aliasdomaininfo': cmd('aliasdomaininfo', 'adi', aliasdomain_info, 'fqdn',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   835
                         _(u'show the destination of the given alias domain')),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   836
    'aliasdomainswitch': cmd('aliasdomainswitch', 'ads', aliasdomain_switch,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   837
                             'fqdn destination', _(u'assign the given alias '
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   838
                             'domain to an other domain')),
506
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   839
    # CatchallAlias commands
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   840
    'catchalladd': cmd('catchalladd', 'caa', catchall_add,
551
62f2daff853e VMM/cli/subcommands: Use the `fqdn' argument placeholder also for
Pascal Volk <user@localhost.localdomain.org>
parents: 542
diff changeset
   841
                       'fqdn destination ...',
506
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   842
                       _(u'add one or more catch-all destinations for a '
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   843
                         u'domain')),
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   844
    'catchalldelete': cmd('catchalldelete', 'cad', catchall_delete,
551
62f2daff853e VMM/cli/subcommands: Use the `fqdn' argument placeholder also for
Pascal Volk <user@localhost.localdomain.org>
parents: 542
diff changeset
   845
                       'fqdn [destination]',
506
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   846
                       _(u'delete the specified catch-all destination or all '
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   847
                         u'of a domain\'s destinations')),
551
62f2daff853e VMM/cli/subcommands: Use the `fqdn' argument placeholder also for
Pascal Volk <user@localhost.localdomain.org>
parents: 542
diff changeset
   848
    'catchallinfo': cmd('catchallinfo', 'cai', catchall_info, 'fqdn',
506
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
   849
                     _(u'show the catch-all destination(s) of the specified domain')),
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   850
    # Domain commands
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   851
    'domainadd': cmd('domainadd', 'da', domain_add, 'fqdn [transport]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   852
                     _(u'create a new domain')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   853
    'domaindelete': cmd('domaindelete', 'dd', domain_delete, 'fqdn [force]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   854
                      _(u'delete the given domain and all its alias domains')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   855
    'domaininfo': cmd('domaininfo', 'di', domain_info, 'fqdn [details]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   856
                      _(u'display information about the given domain')),
403
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   857
    'domainquota': cmd('domainquota', 'dq', domain_quota,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   858
                       'fqdn storage [messages] [force]',
403
a4f5d4cd886d VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 401
diff changeset
   859
                       _(u'update the quota limit of the specified domain')),
445
b8c94e06cd46 VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 429
diff changeset
   860
    'domainservices': cmd('domainservices', 'ds', domain_services,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   861
                          'fqdn [service ...] [force]',
446
18b75e6a39d5 VMM/cli/subcommands: Small indent fix.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 445
diff changeset
   862
                          _(u'enables the specified services and disables all '
18b75e6a39d5 VMM/cli/subcommands: Small indent fix.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 445
diff changeset
   863
                            u'not specified services of the given domain')),
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   864
    'domaintransport': cmd('domaintransport', 'dt', domain_transport,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   865
                           'fqdn transport [force]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   866
                           _(u'update the transport of the specified domain')),
539
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   867
    'domainnote': cmd('domainnote', 'do', domain_note,
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   868
                      'fqdn note',
5806fb74130b Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents: 536
diff changeset
   869
                      _(u'update the note of the given domain')),
555
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   870
    # List commands
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   871
    'listdomains': cmd('listdomains', 'ld', list_domains, '[pattern]',
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   872
                      _(u'list all domains or search for domains by pattern')),
555
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   873
    'listaddresses': cmd('listaddresses', 'll', list_addresses, '[pattern]',
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   874
                      _(u'list all addresses or search for addresses by pattern')),
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   875
    'listusers': cmd('listusers', 'lu', list_users, '[pattern]',
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   876
                      _(u'list all user accounts or search for accounts by pattern')),
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   877
    'listaliases': cmd('listaliases', 'la', list_aliases, '[pattern]',
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   878
                      _(u'list all aliases or search for aliases by pattern')),
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   879
    'listrelocated': cmd('listrelocated', 'lr', list_relocated, '[pattern]',
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
   880
                      _(u'list all relocated entries or search for entries by pattern')),
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   881
    # Relocated commands
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   882
    'relocatedadd': cmd('relocatedadd', 'ra', relocated_add,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   883
                        'address newaddress',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   884
                        _(u'create a new record for a relocated user')),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   885
    'relocateddelete': cmd('relocateddelete', 'rd', relocated_delete,
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   886
                           'address',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   887
                           _(u'delete the record of the relocated user')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   888
    'relocatedinfo': cmd('relocatedinfo', 'ri', relocated_info, 'address',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   889
                         _(u'print information about a relocated user')),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   890
    # cli commands
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   891
    'configget': cmd('configget', 'cg', config_get, 'option',
345
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   892
                     _('show the actual value of the configuration option')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   893
    'configset': cmd('configset', 'cs', config_set, 'option value',
345
f8d5c8bb8bce VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 341
diff changeset
   894
                      _('set a new value for the configuration option')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   895
    'configure': cmd('configure', 'cf', configure, '[section]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   896
                     _(u'start interactive configuration modus')),
462
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   897
    'listpwschemes': cmd('listpwschemes', 'lp', list_pwschemes, '',
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   898
                         _(u'lists all usable password schemes and password '
a64c1b5e08b4 VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents: 458
diff changeset
   899
                           u'encoding suffixes')),
469
1ebb6b88f589 VMM/cli/subcommands: Subcommand argument placeholders are no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 462
diff changeset
   900
    'help': cmd('help', 'h', help_, '[subcommand]',
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   901
                _(u'show a help overview or help for the given subcommand')),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   902
    'version': cmd('version', 'v', version, '',
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   903
                   _(u'show version and copyright information')),
420
d4a341248500 VMM/cli/subcommands: Added function update_cmd_map().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 418
diff changeset
   904
    })
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   905
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   906
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   907
def _get_order(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   908
    """returns a tuple with (key, 1||0) tuples. Used by functions, which
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   909
    get a dict from the handler."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   910
    order = ()
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   911
    if ctx.scmd == 'domaininfo':
447
c31d604e26d3 VMM/domain: Extended/updated Domain.get_info() in order to:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 446
diff changeset
   912
        order = ((u'domain name', 0), (u'gid', 1), (u'domain directory', 0),
474
4353981e3a7f VMM/cli/subcommands: Small improvement of domaininfo's output.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 471
diff changeset
   913
                 (u'quota limit/user', 0), (u'active services', 0),
447
c31d604e26d3 VMM/domain: Extended/updated Domain.get_info() in order to:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 446
diff changeset
   914
                 (u'transport', 0), (u'alias domains', 0), (u'accounts', 0),
515
09fa019bb330 Include catch-all count in domaininfo output
martin f. krafft <madduck@madduck.net>
parents: 510
diff changeset
   915
                 (u'aliases', 0), (u'relocated', 0), (u'catch-all dests', 0))
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   916
    elif ctx.scmd == 'userinfo':
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   917
        if ctx.argc == 4 and ctx.args[3] != u'aliases' or \
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   918
           ctx.cget('account.disk_usage'):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   919
            order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
398
3e5ed678d535 VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents: 397
diff changeset
   920
                     (u'home', 0), (u'mail_location', 0),
401
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   921
                     (u'quota storage', 0), (u'quota messages', 0),
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   922
                     (u'disk usage', 0), (u'transport', 0), (u'smtp', 1),
447
c31d604e26d3 VMM/domain: Extended/updated Domain.get_info() in order to:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 446
diff changeset
   923
                     (u'pop3', 1), (u'imap', 1), (u'sieve', 1))
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   924
        else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   925
            order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
401
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   926
                     (u'home', 0), (u'mail_location', 0),
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   927
                     (u'quota storage', 0), (u'quota messages', 0),
398
3e5ed678d535 VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents: 397
diff changeset
   928
                     (u'transport', 0), (u'smtp', 1), (u'pop3', 1),
447
c31d604e26d3 VMM/domain: Extended/updated Domain.get_info() in order to:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 446
diff changeset
   929
                     (u'imap', 1), (u'sieve', 1))
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   930
    elif ctx.scmd == 'getuser':
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   931
        order = ((u'uid', 1), (u'gid', 1), (u'address', 0))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   932
    return order
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   933
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   934
532
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
   935
def _format_quota_usage(limit, used, human=False, domaindefault=False):
401
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   936
    """Put quota's limit / usage / percentage in a formatted string."""
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   937
    if human:
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   938
        q_usage = {
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   939
            'used': human_size(used),
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   940
            'limit': human_size(limit),
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   941
        }
398
3e5ed678d535 VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents: 397
diff changeset
   942
    else:
401
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   943
        q_usage = {
414
ae1a8428298c VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents: 413
diff changeset
   944
            'used': locale.format('%d', used, True),
ae1a8428298c VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents: 413
diff changeset
   945
            'limit': locale.format('%d', limit, True),
401
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   946
        }
00a8c12a3da3 VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents: 398
diff changeset
   947
    if limit:
414
ae1a8428298c VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents: 413
diff changeset
   948
        q_usage['percent'] = locale.format('%6.2f', 100. / limit * used, True)
398
3e5ed678d535 VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents: 397
diff changeset
   949
    else:
414
ae1a8428298c VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents: 413
diff changeset
   950
        q_usage['percent'] = locale.format('%6.2f', 0, True)
561
b0165b7af7a3 VMM: The Python 2.4.x compatibility commit - part III.
Pascal Volk <user@localhost.localdomain.org>
parents: 559
diff changeset
   951
    #  Py25: fmt = format_domain_default if domaindefault else lambda s: s
b0165b7af7a3 VMM: The Python 2.4.x compatibility commit - part III.
Pascal Volk <user@localhost.localdomain.org>
parents: 559
diff changeset
   952
    if domaindefault:
b0165b7af7a3 VMM: The Python 2.4.x compatibility commit - part III.
Pascal Volk <user@localhost.localdomain.org>
parents: 559
diff changeset
   953
        fmt = format_domain_default
b0165b7af7a3 VMM: The Python 2.4.x compatibility commit - part III.
Pascal Volk <user@localhost.localdomain.org>
parents: 559
diff changeset
   954
    else:
b0165b7af7a3 VMM: The Python 2.4.x compatibility commit - part III.
Pascal Volk <user@localhost.localdomain.org>
parents: 559
diff changeset
   955
        fmt = lambda s: s
532
2bb40aaef94e Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents: 528
diff changeset
   956
    return fmt(_(u'[%(percent)s%%] %(used)s/%(limit)s') % q_usage)
398
3e5ed678d535 VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents: 397
diff changeset
   957
3e5ed678d535 VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents: 397
diff changeset
   958
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   959
def _print_info(ctx, info, title):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   960
    """Print info dicts."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   961
    # TP: used in e.g. 'Domain information' or 'Account information'
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   962
    msg = u'%s %s' % (title, _(u'information'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   963
    w_std(msg, u'-' * len(msg))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   964
    for key, upper in _get_order(ctx):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   965
        if upper:
447
c31d604e26d3 VMM/domain: Extended/updated Domain.get_info() in order to:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 446
diff changeset
   966
            w_std(u'\t%s: %s' % (key.upper().ljust(17, u'.'), info[key]))
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   967
        else:
447
c31d604e26d3 VMM/domain: Extended/updated Domain.get_info() in order to:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 446
diff changeset
   968
            w_std(u'\t%s: %s' % (key.title().ljust(17, u'.'), info[key]))
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   969
    print
593
3dc1764c23d2 VMM/cli/subcommands: Added 'missing' newline below domain notes.
Pascal Volk <user@localhost.localdomain.org>
parents: 568
diff changeset
   970
    note = info.get('note')
3dc1764c23d2 VMM/cli/subcommands: Added 'missing' newline below domain notes.
Pascal Volk <user@localhost.localdomain.org>
parents: 568
diff changeset
   971
    if note:
3dc1764c23d2 VMM/cli/subcommands: Added 'missing' newline below domain notes.
Pascal Volk <user@localhost.localdomain.org>
parents: 568
diff changeset
   972
        _print_note(note + '\n')
3dc1764c23d2 VMM/cli/subcommands: Added 'missing' newline below domain notes.
Pascal Volk <user@localhost.localdomain.org>
parents: 568
diff changeset
   973
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   974
542
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   975
def _print_note(note):
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   976
    msg = _(u'Note')
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   977
    w_std(msg, u'-' * len(msg))
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   978
    old_ii = txt_wrpr.initial_indent
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   979
    old_si = txt_wrpr.subsequent_indent
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   980
    txt_wrpr.initial_indent = txt_wrpr.subsequent_indent = '\t'
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   981
    txt_wrpr.width -= 8
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   982
    for para in note.split('\n'):
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   983
        w_std(txt_wrpr.fill(para))
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   984
    txt_wrpr.width += 8
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   985
    txt_wrpr.subsequent_indent = old_si
c3b98364f03d Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents: 539
diff changeset
   986
    txt_wrpr.initial_indent = old_ii
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   987
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   988
def _print_list(alist, title):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   989
    """Print a list."""
429
9842650569c2 Messages: Replaced some 'Available' by 'Existing'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 423
diff changeset
   990
    # TP: used in e.g. 'Existing alias addresses' or 'Existing accounts'
9842650569c2 Messages: Replaced some 'Available' by 'Existing'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 423
diff changeset
   991
    msg = u'%s %s' % (_(u'Existing'), title)
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   992
    w_std(msg, u'-' * len(msg))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   993
    if alist:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   994
        if title != _(u'alias domains'):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   995
            w_std(*(u'\t%s' % item for item in alist))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   996
        else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   997
            for domain in alist:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   998
                if not domain.startswith('xn--'):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   999
                    w_std(u'\t%s' % domain)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1000
                else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1001
                    w_std(u'\t%s (%s)' % (domain, domain.decode('idna')))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1002
        print
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1003
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1004
        w_std(_(u'\tNone'), '')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1005
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1006
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1007
def _print_aliase_info(alias, destinations):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1008
    """Print the alias address and all its destinations"""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1009
    title = _(u'Alias information')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1010
    w_std(title, u'-' * len(title))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1011
    w_std(_(u'\tMail for %s will be redirected to:') % alias)
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1012
    w_std(*(u'\t     * %s' % dest for dest in destinations))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1013
    print
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1014
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1015
506
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1016
def _print_catchall_info(domain, destinations):
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1017
    """Print the catchall destinations of a domain"""
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1018
    title = _(u'Catch-all information')
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1019
    w_std(title, u'-' * len(title))
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1020
    w_std(_(u'\tMail to unknown localparts in domain %s will be sent to:')
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1021
          % domain)
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1022
    w_std(*(u'\t     * %s' % dest for dest in destinations))
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1023
    print
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1024
fb0ffde628d6 Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents: 487
diff changeset
  1025
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1026
def _print_relocated_info(**kwargs):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1027
    """Print the old and new addresses of a relocated user."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1028
    title = _(u'Relocated information')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1029
    w_std(title, u'-' * len(title))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1030
    w_std(_(u"\tUser '%(addr)s' has moved to '%(dest)s'") % kwargs, '')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1031
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1032
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1033
def _format_domain(domain, main=True):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1034
    """format (prefix/convert) the domain name."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1035
    if domain.startswith('xn--'):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1036
        domain = u'%s (%s)' % (domain, domain.decode('idna'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1037
    if main:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1038
        return u'\t[+] %s' % domain
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1039
    return u'\t[-]     %s' % domain
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1040
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1041
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1042
def _print_domain_list(dids, domains, matching):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1043
    """Print a list of (matching) domains/alias domains."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1044
    if matching:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1045
        title = _(u'Matching domains')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1046
    else:
429
9842650569c2 Messages: Replaced some 'Available' by 'Existing'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 423
diff changeset
  1047
        title = _(u'Existing domains')
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1048
    w_std(title, '-' * len(title))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1049
    if domains:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1050
        for did in dids:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1051
            if domains[did][0] is not None:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1052
                w_std(_format_domain(domains[did][0]))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1053
            if len(domains[did]) > 1:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1054
                w_std(*(_format_domain(a, False) for a in domains[did][1:]))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1055
    else:
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1056
        w_std(_('\tNone'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1057
    print
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1058
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1059
555
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1060
def _print_address_list(which, dids, addresses, matching):
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1061
    """Print a list of (matching) addresses."""
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1062
    _trans = { TYPE_ACCOUNT                  : _('user accounts')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1063
             , TYPE_ALIAS                    : _('aliases')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1064
             , TYPE_RELOCATED                : _('relocated entries')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1065
             , TYPE_ACCOUNT | TYPE_ALIAS
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1066
                 : _('user accounts and aliases')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1067
             , TYPE_ACCOUNT | TYPE_RELOCATED
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1068
                 : _('user accounts and relocated entries')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1069
             , TYPE_ALIAS | TYPE_RELOCATED
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1070
                 : _('aliases and relocated entries')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1071
             , TYPE_ACCOUNT | TYPE_ALIAS | TYPE_RELOCATED : _('addresses')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1072
             }
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1073
    try:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1074
        if matching:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1075
            title = _(u'Matching %s') % _trans[which]
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1076
        else:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1077
            title = _(u'Existing %s') % _trans[which]
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1078
        w_std(title, '-' * len(title))
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1079
    except KeyError:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1080
        raise VMMError(_("Invalid address type for list: '%s'") % which,
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1081
                       INVALID_ARGUMENT)
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1082
    if addresses:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1083
        if which & (which - 1) == 0:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1084
            # only one type is requested, so no type indicator
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1085
            _trans = { TYPE_ACCOUNT   : _('')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1086
                     , TYPE_ALIAS     : _('')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1087
                     , TYPE_RELOCATED : _('')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1088
                     }
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1089
        else:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1090
            _trans = { TYPE_ACCOUNT   : _('u')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1091
                     , TYPE_ALIAS     : _('a')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1092
                     , TYPE_RELOCATED : _('r')
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1093
                     }
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1094
        for did in dids:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1095
            for addr, atype, aliasdomain in addresses[did]:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1096
                if aliasdomain:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1097
                    leader = '[%s-]' % _trans[atype]
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1098
                else:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1099
                    leader = '[%s+]' % _trans[atype]
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1100
                w_std('\t%s %s' % (leader, addr))
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1101
    else:
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1102
        w_std(_('\tNone'))
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1103
    print
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1104
499c63f52462 Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents: 551
diff changeset
  1105
340
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1106
def _print_aliasdomain_info(info):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1107
    """Print alias domain information."""
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1108
    title = _(u'Alias domain information')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1109
    for key in ('alias', 'domain'):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1110
        if info[key].startswith('xn--'):
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1111
            info[key] = u'%s (%s)' % (info[key], info[key].decode('idna'))
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1112
    w_std(title, '-' * len(title),
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1113
          _('\tThe alias domain %(alias)s belongs to:\n\t    * %(domain)s') %
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1114
          info, '')
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1115
4515afec62e5 vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
  1116
del _