author | Pascal Volk <user@localhost.localdomain.org> |
Sat, 15 Feb 2014 19:00:40 +0000 | |
branch | v0.7.x |
changeset 728 | 69eb7a65d8a4 |
parent 711 | 2a75058fc064 |
child 737 | 81f4bfc34ed8 |
permissions | -rw-r--r-- |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1 |
# -*- coding: UTF-8 -*- |
703
58815c004a61
Updated copyright notices to include the year 2014.
Pascal Volk <user@localhost.localdomain.org>
parents:
675
diff
changeset
|
2 |
# Copyright (c) 2007 - 2014, 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 |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
12 |
import platform |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
13 |
|
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
14 |
from argparse import Action, ArgumentParser, ArgumentTypeError, \ |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
15 |
RawDescriptionHelpFormatter |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
16 |
from textwrap import TextWrapper |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
17 |
from time import strftime, strptime |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
18 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
19 |
from VirtualMailManager import ENCODING |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
20 |
from VirtualMailManager.cli import get_winsize, w_err, w_std |
532
2bb40aaef94e
Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents:
528
diff
changeset
|
21 |
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
|
22 |
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
|
23 |
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
|
24 |
__version__, ACCOUNT_EXISTS, ALIAS_EXISTS, ALIASDOMAIN_ISDOMAIN, \ |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
25 |
DOMAIN_ALIAS_EXISTS, INVALID_ARGUMENT, RELOCATED_EXISTS, TYPE_ACCOUNT, \ |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
26 |
TYPE_ALIAS, TYPE_RELOCATED |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
27 |
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
|
28 |
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
|
29 |
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
|
30 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
31 |
__all__ = ( |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
32 |
'RunContext', 'alias_add', 'alias_delete', 'alias_info', 'aliasdomain_add', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
33 |
'aliasdomain_delete', 'aliasdomain_info', 'aliasdomain_switch', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
34 |
'catchall_add', 'catchall_delete', 'catchall_info', 'config_get', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
35 |
'config_set', 'configure', 'domain_add', 'domain_delete', 'domain_info', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
36 |
'domain_note', 'domain_quota', 'domain_services', 'domain_transport', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
37 |
'get_user', 'list_addresses', 'list_aliases', 'list_domains', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
38 |
'list_pwschemes', 'list_relocated', 'list_users', 'relocated_add', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
39 |
'relocated_delete', 'relocated_info', 'setup_parser', 'user_add', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
40 |
'user_delete', 'user_info', 'user_name', 'user_note', 'user_password', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
41 |
'user_quota', 'user_services', 'user_transport', |
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 |
|
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
44 |
WS_ROWS = get_winsize()[1] - 2 |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
45 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
46 |
_ = lambda msg: msg |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
47 |
txt_wrpr = TextWrapper(width=WS_ROWS) |
606
ab97727357a4
VMM/cli: Activated help subcommand.
Pascal Volk <user@localhost.localdomain.org>
parents:
602
diff
changeset
|
48 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
49 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
50 |
class RunContext(object): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
51 |
"""Contains all information necessary to run a subcommand.""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
52 |
__slots__ = ('args', 'cget', 'hdlr') |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
53 |
plan_a_b = _('Plan A failed ... trying Plan B: %(subcommand)s %(object)s') |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
54 |
|
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
55 |
def __init__(self, args, handler): |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
56 |
"""Create a new RunContext""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
57 |
self.args = args |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
58 |
self.cget = handler.cfg_dget |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
59 |
self.hdlr = handler |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
60 |
|
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 |
def alias_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
63 |
"""create a new alias e-mail address""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
64 |
ctx.hdlr.alias_add(ctx.args.address.lower(), *ctx.args.destination) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
65 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
66 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
67 |
def alias_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
68 |
"""delete the specified alias e-mail address or one of its destinations""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
69 |
destination = ctx.args.destination if ctx.args.destination else None |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
70 |
ctx.hdlr.alias_delete(ctx.args.address.lower(), destination) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
71 |
|
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 |
def alias_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
74 |
"""show the destination(s) of the specified alias""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
75 |
address = ctx.args.address.lower() |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
76 |
try: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
77 |
_print_aliase_info(address, ctx.hdlr.alias_info(address)) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
78 |
except VMMError as err: |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
79 |
if err.code is ACCOUNT_EXISTS: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
80 |
w_err(0, ctx.plan_a_b % {'subcommand': 'userinfo', |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
81 |
'object': address}) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
82 |
ctx.args.scmd = 'userinfo' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
83 |
ctx.args.details = None |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
84 |
user_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
85 |
elif err.code is RELOCATED_EXISTS: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
86 |
w_err(0, ctx.plan_a_b % {'subcommand': 'relocatedinfo', |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
87 |
'object': address}) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
88 |
ctx.args.scmd = 'relocatedinfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
89 |
relocated_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
90 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
91 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
92 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
93 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
94 |
def aliasdomain_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
95 |
"""create a new alias for an existing domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
96 |
ctx.hdlr.aliasdomain_add(ctx.args.fqdn.lower(), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
97 |
ctx.args.destination.lower()) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
98 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
99 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
100 |
def aliasdomain_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
101 |
"""delete the specified alias domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
102 |
ctx.hdlr.aliasdomain_delete(ctx.args.fqdn.lower()) |
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 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
105 |
def aliasdomain_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
106 |
"""show the destination of the given alias domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
107 |
fqdn = ctx.args.fqdn.lower() |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
108 |
try: |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
109 |
_print_aliasdomain_info(ctx.hdlr.aliasdomain_info(fqdn)) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
110 |
except VMMError as err: |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
111 |
if err.code is ALIASDOMAIN_ISDOMAIN: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
112 |
w_err(0, ctx.plan_a_b % {'subcommand': 'domaininfo', |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
113 |
'object': fqdn}) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
114 |
ctx.args.scmd = 'domaininfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
115 |
domain_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
116 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
117 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
118 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
119 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
120 |
def aliasdomain_switch(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
121 |
"""assign the given alias domain to an other domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
122 |
ctx.hdlr.aliasdomain_switch(ctx.args.fqdn.lower(), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
123 |
ctx.args.destination.lower()) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
124 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
125 |
|
506
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
126 |
def catchall_add(ctx): |
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
127 |
"""create a new catchall alias e-mail address""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
128 |
ctx.hdlr.catchall_add(ctx.args.fqdn.lower(), *ctx.args.destination) |
506
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
129 |
|
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
130 |
|
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
131 |
def catchall_delete(ctx): |
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
132 |
"""delete the specified destination or all of the catchall destination""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
133 |
destination = ctx.args.destination if ctx.args.destination else None |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
134 |
ctx.hdlr.catchall_delete(ctx.args.fqdn.lower(), destination) |
506
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
135 |
|
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
136 |
|
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
137 |
def catchall_info(ctx): |
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
138 |
"""show the catchall destination(s) of the specified domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
139 |
address = ctx.args.fqdn.lower() |
506
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
140 |
_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
|
141 |
|
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
142 |
|
345
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
143 |
def config_get(ctx): |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
144 |
"""show the actual value of the configuration option""" |
397
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
145 |
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
|
146 |
opt_formater = { |
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
147 |
'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
|
148 |
'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
|
149 |
} |
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
150 |
|
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
151 |
option = ctx.args.option.lower() |
397
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
152 |
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
|
153 |
noop)(ctx.cget(option)))) |
345
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
154 |
|
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
155 |
|
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
156 |
def config_set(ctx): |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
157 |
"""set a new value for the configuration option""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
158 |
ctx.hdlr.cfg_set(ctx.args.option.lower(), ctx.args.value) |
345
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
159 |
|
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
160 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
161 |
def configure(ctx): |
608
0ed93eb8b364
VMM: Corrected/updated some msgids.
Pascal Volk <user@localhost.localdomain.org>
parents:
607
diff
changeset
|
162 |
"""start interactive configuration mode""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
163 |
ctx.hdlr.configure(ctx.args.section) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
164 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
165 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
166 |
def domain_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
167 |
"""create a new domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
168 |
fqdn = ctx.args.fqdn.lower() |
685
c6024bc1de0f
VMM/cli/subcommands: domain_add: Fixed a coding error.
Pascal Volk <user@localhost.localdomain.org>
parents:
681
diff
changeset
|
169 |
transport = ctx.args.transport.lower() if ctx.args.transport else None |
686
5f4abdab738e
VMM: Added option `-n NOTE' to {domain,user}add.
Pascal Volk <user@localhost.localdomain.org>
parents:
685
diff
changeset
|
170 |
ctx.hdlr.domain_add(fqdn, transport, ctx.args.note) |
456
7847f949d0a2
VMM/cli/subcommands: Small improvement in domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
455
diff
changeset
|
171 |
if ctx.cget('domain.auto_postmaster'): |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
172 |
w_std(_('Creating account for postmaster@%s') % fqdn) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
173 |
ctx.args.scmd = 'useradd' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
174 |
ctx.args.address = 'postmaster@%s' % fqdn |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
175 |
ctx.args.password = None |
686
5f4abdab738e
VMM: Added option `-n NOTE' to {domain,user}add.
Pascal Volk <user@localhost.localdomain.org>
parents:
685
diff
changeset
|
176 |
ctx.args.note = None |
456
7847f949d0a2
VMM/cli/subcommands: Small improvement in domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
455
diff
changeset
|
177 |
user_add(ctx) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
178 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
179 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
180 |
def domain_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
181 |
"""delete the given domain and all its alias domains""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
182 |
ctx.hdlr.domain_delete(ctx.args.fqdn.lower(), ctx.args.force) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
183 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
184 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
185 |
def domain_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
186 |
"""display information about the given domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
187 |
fqdn = ctx.args.fqdn.lower() |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
188 |
details = ctx.args.details |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
189 |
try: |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
190 |
info = ctx.hdlr.domain_info(fqdn, details) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
191 |
except VMMError as err: |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
192 |
if err.code is DOMAIN_ALIAS_EXISTS: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
193 |
w_err(0, ctx.plan_a_b % {'subcommand': 'aliasdomaininfo', |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
194 |
'object': fqdn}) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
195 |
ctx.args.scmd = 'aliasdomaininfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
196 |
aliasdomain_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
197 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
198 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
199 |
else: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
200 |
q_limit = '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
|
201 |
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
|
202 |
info['bytes'] = human_size(info['bytes']) |
653
cf07e4468934
VMM: Post-2to3 fixes.
Pascal Volk <user@localhost.localdomain.org>
parents:
643
diff
changeset
|
203 |
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
|
204 |
info['quota limit/user'] = q_limit % info |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
205 |
_print_info(ctx, info, _('Domain')) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
206 |
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
|
207 |
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
|
208 |
info[0]['messages'] = locale.format('%d', info[0]['messages'], |
657
6515e3b88dec
VMM/cli/subcommands: Fixed some encode/decode issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
656
diff
changeset
|
209 |
True) |
474
4353981e3a7f
VMM/cli/subcommands: Small improvement of domaininfo's output.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
471
diff
changeset
|
210 |
info[0]['quota limit/user'] = q_limit % info[0] |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
211 |
_print_info(ctx, info[0], _('Domain')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
212 |
if details == 'accounts': |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
213 |
_print_list(info[1], _('accounts')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
214 |
elif details == 'aliasdomains': |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
215 |
_print_list(info[1], _('alias domains')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
216 |
elif details == 'aliases': |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
217 |
_print_list(info[1], _('aliases')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
218 |
elif details == 'relocated': |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
219 |
_print_list(info[1], _('relocated users')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
220 |
elif details == 'catchall': |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
221 |
_print_list(info[1], _('catch-all destinations')) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
222 |
else: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
223 |
_print_list(info[1], _('alias domains')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
224 |
_print_list(info[2], _('accounts')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
225 |
_print_list(info[3], _('aliases')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
226 |
_print_list(info[4], _('relocated users')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
227 |
_print_list(info[5], _('catch-all destinations')) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
228 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
229 |
|
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
230 |
def domain_quota(ctx): |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
231 |
"""update the quota limit of the specified domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
232 |
ctx.hdlr.domain_quotalimit(ctx.args.fqdn.lower(), ctx.args.storage, |
681
4cab983479db
VMM: Code cleanup.
Pascal Volk <user@localhost.localdomain.org>
parents:
679
diff
changeset
|
233 |
ctx.args.messages, ctx.args.force) |
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
234 |
|
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
235 |
|
445
b8c94e06cd46
VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
429
diff
changeset
|
236 |
def domain_services(ctx): |
b8c94e06cd46
VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
429
diff
changeset
|
237 |
"""allow all named service and block the uncredited.""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
238 |
services = ctx.args.services if ctx.args.services else [] |
681
4cab983479db
VMM: Code cleanup.
Pascal Volk <user@localhost.localdomain.org>
parents:
679
diff
changeset
|
239 |
ctx.hdlr.domain_services(ctx.args.fqdn.lower(), ctx.args.force, *services) |
445
b8c94e06cd46
VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
429
diff
changeset
|
240 |
|
b8c94e06cd46
VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
429
diff
changeset
|
241 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
242 |
def domain_transport(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
243 |
"""update the transport of the specified domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
244 |
ctx.hdlr.domain_transport(ctx.args.fqdn.lower(), |
681
4cab983479db
VMM: Code cleanup.
Pascal Volk <user@localhost.localdomain.org>
parents:
679
diff
changeset
|
245 |
ctx.args.transport.lower(), ctx.args.force) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
246 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
247 |
|
539
5806fb74130b
Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents:
536
diff
changeset
|
248 |
def domain_note(ctx): |
5806fb74130b
Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents:
536
diff
changeset
|
249 |
"""update the note of the given domain""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
250 |
ctx.hdlr.domain_note(ctx.args.fqdn.lower(), ctx.args.note) |
539
5806fb74130b
Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents:
536
diff
changeset
|
251 |
|
5806fb74130b
Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents:
536
diff
changeset
|
252 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
253 |
def get_user(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
254 |
"""get the address of the user with the given UID""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
255 |
_print_info(ctx, ctx.hdlr.user_by_uid(ctx.args.uid), _('Account')) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
256 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
257 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
258 |
def list_domains(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
259 |
"""list all domains / search domains by pattern""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
260 |
matching = True if ctx.args.pattern else False |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
261 |
pattern = ctx.args.pattern.lower() if matching else None |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
262 |
gids, domains = ctx.hdlr.domain_list(pattern) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
263 |
_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
|
264 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
265 |
|
462
a64c1b5e08b4
VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
458
diff
changeset
|
266 |
def list_pwschemes(ctx_unused): |
a64c1b5e08b4
VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
458
diff
changeset
|
267 |
"""Prints all usable password schemes and password encoding suffixes.""" |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
268 |
keys = (_('Usable password schemes'), _('Usable encoding suffixes')) |
462
a64c1b5e08b4
VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
458
diff
changeset
|
269 |
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
|
270 |
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
|
271 |
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
|
272 |
|
a64c1b5e08b4
VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
458
diff
changeset
|
273 |
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
|
274 |
w_std(key, len(key) * '-') |
656
4bbca60e0ba4
VMM/cli/subcommands: Print usable password schemes in sorted order.
Pascal Volk <user@localhost.localdomain.org>
parents:
653
diff
changeset
|
275 |
w_std('\n'.join(txt_wrpr.wrap(' '.join(sorted(value)))), '') |
462
a64c1b5e08b4
VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
458
diff
changeset
|
276 |
|
a64c1b5e08b4
VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
458
diff
changeset
|
277 |
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
|
278 |
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
|
279 |
|
a64c1b5e08b4
VMM/cli/subcommands: Added new subcommand `listpwschemes' (lp).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
458
diff
changeset
|
280 |
|
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
281 |
def list_addresses(ctx, limit=None): |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
282 |
"""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
|
283 |
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
|
284 |
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
|
285 |
combining all three.""" |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
286 |
if limit is None: |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
287 |
limit = TYPE_ACCOUNT | TYPE_ALIAS | TYPE_RELOCATED |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
288 |
matching = True if ctx.args.pattern else False |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
289 |
pattern = ctx.args.pattern.lower() if matching else None |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
290 |
gids, addresses = ctx.hdlr.address_list(limit, pattern) |
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
291 |
_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
|
292 |
|
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
293 |
|
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
294 |
def list_users(ctx): |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
295 |
"""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
|
296 |
return list_addresses(ctx, TYPE_ACCOUNT) |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
297 |
|
611
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
298 |
|
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
299 |
def list_aliases(ctx): |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
300 |
"""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
|
301 |
return list_addresses(ctx, TYPE_ALIAS) |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
302 |
|
611
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
303 |
|
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
304 |
def list_relocated(ctx): |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
305 |
"""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
|
306 |
return list_addresses(ctx, TYPE_RELOCATED) |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
307 |
|
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
308 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
309 |
def relocated_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
310 |
"""create a new record for a relocated user""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
311 |
ctx.hdlr.relocated_add(ctx.args.address.lower(), ctx.args.newaddress) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
312 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
313 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
314 |
def relocated_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
315 |
"""delete the record of the relocated user""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
316 |
ctx.hdlr.relocated_delete(ctx.args.address.lower()) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
317 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
318 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
319 |
def relocated_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
320 |
"""print information about a relocated user""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
321 |
relocated = ctx.args.address.lower() |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
322 |
try: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
323 |
_print_relocated_info(addr=relocated, |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
324 |
dest=ctx.hdlr.relocated_info(relocated)) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
325 |
except VMMError as err: |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
326 |
if err.code is ACCOUNT_EXISTS: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
327 |
w_err(0, ctx.plan_a_b % {'subcommand': 'userinfo', |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
328 |
'object': relocated}) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
329 |
ctx.args.scmd = 'userinfo' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
330 |
ctx.args.details = None |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
331 |
user_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
332 |
elif err.code is ALIAS_EXISTS: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
333 |
w_err(0, ctx.plan_a_b % {'subcommand': 'aliasinfo', |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
334 |
'object': relocated}) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
335 |
ctx.args.scmd = 'aliasinfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
336 |
alias_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
337 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
338 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
339 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
340 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
341 |
def user_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
342 |
"""create a new e-mail user with the given address""" |
686
5f4abdab738e
VMM: Added option `-n NOTE' to {domain,user}add.
Pascal Volk <user@localhost.localdomain.org>
parents:
685
diff
changeset
|
343 |
gen_pass = ctx.hdlr.user_add(ctx.args.address.lower(), ctx.args.password, |
5f4abdab738e
VMM: Added option `-n NOTE' to {domain,user}add.
Pascal Volk <user@localhost.localdomain.org>
parents:
685
diff
changeset
|
344 |
ctx.args.note) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
345 |
if not ctx.args.password and gen_pass: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
346 |
w_std(_("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
|
347 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
348 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
349 |
def user_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
350 |
"""delete the specified user""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
351 |
ctx.hdlr.user_delete(ctx.args.address.lower(), ctx.args.force) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
352 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
353 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
354 |
def user_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
355 |
"""display information about the given address""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
356 |
address = ctx.args.address.lower() |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
357 |
try: |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
358 |
info = ctx.hdlr.user_info(address, ctx.args.details) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
359 |
except VMMError as err: |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
360 |
if err.code is ALIAS_EXISTS: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
361 |
w_err(0, ctx.plan_a_b % {'subcommand': 'aliasinfo', |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
362 |
'object': address}) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
363 |
ctx.args.scmd = 'aliasinfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
364 |
alias_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
365 |
elif err.code is RELOCATED_EXISTS: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
366 |
w_err(0, ctx.plan_a_b % {'subcommand': 'relocatedinfo', |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
367 |
'object': address}) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
368 |
ctx.args.scmd = 'relocatedinfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
369 |
relocated_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
370 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
371 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
372 |
else: |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
373 |
if ctx.args.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
|
374 |
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
|
375 |
info['uq_bytes'], True, info['ql_domaindefault']) |
611
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
376 |
info['quota messages'] = \ |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
377 |
_format_quota_usage(info['ql_messages'], |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
378 |
info['uq_messages'], |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
379 |
domaindefault=info['ql_domaindefault']) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
380 |
_print_info(ctx, info, _('Account')) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
381 |
else: |
401
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
_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
|
386 |
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
|
387 |
domaindefault=info[0]['ql_domaindefault']) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
388 |
_print_info(ctx, info[0], _('Account')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
389 |
_print_list(info[1], _('alias addresses')) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
390 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
391 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
392 |
def user_name(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
393 |
"""set or update the real name for an address""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
394 |
ctx.hdlr.user_name(ctx.args.address.lower(), ctx.args.name) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
395 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
396 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
397 |
def user_password(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
398 |
"""update the password for the given address""" |
728
69eb7a65d8a4
VMM/cli/subcommands: userpassword added option -s.
Pascal Volk <user@localhost.localdomain.org>
parents:
711
diff
changeset
|
399 |
ctx.hdlr.user_password(ctx.args.address.lower(), ctx.args.password, |
69eb7a65d8a4
VMM/cli/subcommands: userpassword added option -s.
Pascal Volk <user@localhost.localdomain.org>
parents:
711
diff
changeset
|
400 |
ctx.args.scheme) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
401 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
402 |
|
539
5806fb74130b
Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents:
536
diff
changeset
|
403 |
def user_note(ctx): |
5806fb74130b
Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents:
536
diff
changeset
|
404 |
"""update the note of the given address""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
405 |
ctx.hdlr.user_note(ctx.args.address.lower(), ctx.args.note) |
539
5806fb74130b
Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents:
536
diff
changeset
|
406 |
|
5806fb74130b
Add note field to Account/Domain and CLI
martin f. krafft <madduck@madduck.net>
parents:
536
diff
changeset
|
407 |
|
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
408 |
def user_quota(ctx): |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
409 |
"""update the quota limit for the given address""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
410 |
ctx.hdlr.user_quotalimit(ctx.args.address.lower(), ctx.args.storage, |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
411 |
ctx.args.messages) |
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
412 |
|
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
413 |
|
445
b8c94e06cd46
VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
429
diff
changeset
|
414 |
def user_services(ctx): |
b8c94e06cd46
VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
429
diff
changeset
|
415 |
"""allow all named service and block the uncredited.""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
416 |
if 'domain' in ctx.args.services: |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
417 |
services = ['domain'] |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
418 |
else: |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
419 |
services = ctx.args.services |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
420 |
ctx.hdlr.user_services(ctx.args.address.lower(), *services) |
445
b8c94e06cd46
VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
429
diff
changeset
|
421 |
|
b8c94e06cd46
VMM/cli/subcommands: Added subcommand domainservices (ds).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
429
diff
changeset
|
422 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
423 |
def user_transport(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
424 |
"""update the transport of the given address""" |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
425 |
ctx.hdlr.user_transport(ctx.args.address.lower(), ctx.args.transport) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
426 |
|
420
d4a341248500
VMM/cli/subcommands: Added function update_cmd_map().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
418
diff
changeset
|
427 |
|
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
428 |
def setup_parser(): |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
429 |
"""Create the argument parser, add all the subcommands and return it.""" |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
430 |
class ArgParser(ArgumentParser): |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
431 |
"""This class fixes the 'width detection'.""" |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
432 |
def _get_formatter(self): |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
433 |
return self.formatter_class(prog=self.prog, width=WS_ROWS, |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
434 |
max_help_position=26) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
435 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
436 |
class VersionAction(Action): |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
437 |
"""Show version and copyright information.""" |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
438 |
def __call__(self, parser, namespace, values, option_string=None): |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
439 |
"""implements the Action API.""" |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
440 |
vers_info = _('{program}, version {version} (from {rel_date})\n' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
441 |
'Python {py_vers} on {sysname}'.format( |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
442 |
program=parser.prog, version=__version__, |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
443 |
rel_date=strftime( |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
444 |
locale.nl_langinfo(locale.D_FMT), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
445 |
strptime(__date__, '%Y-%m-%d')), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
446 |
py_vers=platform.python_version(), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
447 |
sysname=platform.system())) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
448 |
copy_info = _('{copyright}\n{program} is free software and comes ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
449 |
'with ABSOLUTELY NO WARRANTY.'.format( |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
450 |
copyright=__copyright__, program=parser.prog)) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
451 |
parser.exit(message='\n\n'.join((vers_info, copy_info)) + '\n') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
452 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
453 |
def quota_storage(string): |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
454 |
if string == 'domain': |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
455 |
return string |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
456 |
try: |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
457 |
storage = size_in_bytes(string) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
458 |
except (TypeError, ValueError) as error: |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
459 |
raise ArgumentTypeError(str(error)) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
460 |
return storage |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
461 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
462 |
old_rw = txt_wrpr.replace_whitespace |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
463 |
txt_wrpr.replace_whitespace = False |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
464 |
fill = lambda t: '\n'.join(txt_wrpr.fill(l) for l in t.splitlines(True)) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
465 |
mklst = lambda iterable: '\n\t - ' + '\n\t - '.join(iterable) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
466 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
467 |
description = _('%(prog)s - command line tool to manage email ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
468 |
'domains/accounts/aliases/...') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
469 |
epilog = _('use "%(prog)s <subcommand> -h" for information about the ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
470 |
'given subcommand') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
471 |
parser = ArgParser(description=description, epilog=epilog) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
472 |
parser.add_argument('-v', '--version', action=VersionAction, nargs=0, |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
473 |
help=_("show %(prog)s's version and copyright " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
474 |
"information and exit")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
475 |
subparsers = parser.add_subparsers(metavar=_('<subcommand>'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
476 |
title=_('list of available subcommands')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
477 |
a = subparsers.add_parser |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
478 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
479 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
480 |
# general subcommands |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
481 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
482 |
cg = a('configget', aliases=('cg',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
483 |
help=_('show the actual value of the configuration option'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
484 |
epilog=_("This subcommand is used to display the actual value of " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
485 |
"the given configuration option.")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
486 |
cg.add_argument('option', help=_('the name of a configuration option')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
487 |
cg.set_defaults(func=config_get, scmd='configget') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
488 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
489 |
cs = a('configset', aliases=('cs',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
490 |
help=_('set a new value for the configuration option'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
491 |
epilog=fill(_("Use this subcommand to set or update a single " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
492 |
"configuration option's value. option is the configuration " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
493 |
"option, value is the option's new value.\n\nNote: This " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
494 |
"subcommand will create a new vmm.cfg without any comments. " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
495 |
"Your current configuration file will be backed as " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
496 |
"vmm.cfg.bak.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
497 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
498 |
cs.add_argument('option', help=_('the name of a configuration option')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
499 |
cs.add_argument('value', help=_("the option's new value")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
500 |
cs.set_defaults(func=config_set, scmd='configset') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
501 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
502 |
sections = ('account', 'bin', 'database', 'domain', 'mailbox', 'misc') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
503 |
cf = a('configure', aliases=('cf',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
504 |
help=_('start interactive configuration mode'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
505 |
epilog=fill(_("Starts the interactive configuration for all " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
506 |
"configuration sections.\n\nIn this process the currently set " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
507 |
"value of each option will be displayed in square brackets. " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
508 |
"If no value is configured, the default value of each option " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
509 |
"will be displayed in square brackets. Press the return key, " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
510 |
"to accept the displayed value.\n\n" |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
511 |
"If the optional argument section is given, only the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
512 |
"configuration options from the given section will be " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
513 |
"displayed and will be configurable. The following sections " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
514 |
"are available:\n") + mklst(sections)), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
515 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
516 |
cf.add_argument('-s', choices=sections, metavar='SECTION', dest='section', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
517 |
help=_("configure only options of the given section")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
518 |
cf.set_defaults(func=configure, scmd='configure') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
519 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
520 |
gu = a('getuser', aliases=('gu',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
521 |
help=_('get the address of the user with the given UID'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
522 |
epilog=_("If only the uid is available, for example from process " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
523 |
"list, the subcommand getuser will show the user's " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
524 |
"address.")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
525 |
gu.add_argument('uid', type=int, help=_("a user's unique identifier")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
526 |
gu.set_defaults(func=get_user, scmd='getuser') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
527 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
528 |
ll = a('listaddresses', aliases=('ll',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
529 |
help=_('list all addresses or search for addresses by pattern'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
530 |
epilog=fill(_("This command lists all defined addresses. " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
531 |
"Addresses belonging to alias-domains are prefixed with a '-', " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
532 |
"addresses of regular domains with a '+'. Additionally, the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
533 |
"letters 'u', 'a', and 'r' indicate the type of each address: " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
534 |
"user, alias and relocated respectively. The output can be " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
535 |
"limited with an optional pattern.\n\nTo perform a wild card " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
536 |
"search, the % character can be used at the start and/or the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
537 |
"end of the pattern.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
538 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
539 |
ll.add_argument('-p', help=_("the pattern to search for"), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
540 |
metavar='PATTERN', dest='pattern') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
541 |
ll.set_defaults(func=list_addresses, scmd='listaddresses') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
542 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
543 |
la = a('listaliases', aliases=('la',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
544 |
help=_('list all aliases or search for aliases by pattern'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
545 |
epilog=fill(_("This command lists all defined aliases. Aliases " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
546 |
"belonging to alias-domains are prefixed with a '-', addresses " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
547 |
"of regular domains with a '+'. The output can be limited " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
548 |
"with an optional pattern.\n\nTo perform a wild card search, " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
549 |
"the % character can be used at the start and/or the end of " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
550 |
"the pattern.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
551 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
552 |
la.add_argument('-p', help=_("the pattern to search for"), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
553 |
metavar='PATTERN', dest='pattern') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
554 |
la.set_defaults(func=list_aliases, scmd='listaliases') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
555 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
556 |
ld = a('listdomains', aliases=('ld',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
557 |
help=_('list all domains or search for domains by pattern'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
558 |
epilog=fill(_("This subcommand lists all available domains. All " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
559 |
"domain names will be prefixed either with `[+]', if the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
560 |
"domain is a primary domain, or with `[-]', if it is an alias " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
561 |
"domain name. The output can be limited with an optional " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
562 |
"pattern.\n\nTo perform a wild card search, the % character " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
563 |
"can be used at the start and/or the end of the pattern.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
564 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
565 |
ld.add_argument('-p', help=_("the pattern to search for"), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
566 |
metavar='PATTERN', dest='pattern') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
567 |
ld.set_defaults(func=list_domains, scmd='listdomains') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
568 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
569 |
lr = a('listrelocated', aliases=('lr',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
570 |
help=_('list all relocated users or search for relocated users by ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
571 |
'pattern'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
572 |
epilog=fill(_("This command lists all defined relocated addresses. " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
573 |
"Relocated entries belonging to alias-domains are prefixed " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
574 |
"with a '-', addresses of regular domains with a '+'. The " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
575 |
"output can be limited with an optional pattern.\n\nTo " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
576 |
"perform a wild card search, the % character can be used at " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
577 |
"the start and/or the end of the pattern.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
578 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
579 |
lr.add_argument('-p', help=_("the pattern to search for"), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
580 |
metavar='PATTERN', dest='pattern') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
581 |
lr.set_defaults(func=list_relocated, scmd='listrelocated') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
582 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
583 |
lu = a('listusers', aliases=('lu',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
584 |
help=_('list all user accounts or search for accounts by pattern'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
585 |
epilog=fill(_("This command lists all user accounts. User accounts " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
586 |
"belonging to alias-domains are prefixed with a '-', " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
587 |
"addresses of regular domains with a '+'. The output can be " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
588 |
"limited with an optional pattern.\n\nTo perform a wild card " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
589 |
"search, the % character can be used at the start and/or the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
590 |
"end of the pattern.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
591 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
592 |
lu.add_argument('-p', help=_("the pattern to search for"), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
593 |
metavar='PATTERN', dest='pattern') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
594 |
lu.set_defaults(func=list_users, scmd='listusers') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
595 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
596 |
lp = a('listpwschemes', aliases=('lp',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
597 |
help=_('lists all usable password schemes and password encoding ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
598 |
'suffixes'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
599 |
epilog=fill(_("This subcommand lists all password schemes which " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
600 |
"could be used in the vmm.cfg as value of the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
601 |
"misc.password_scheme option. The output varies, depending " |
691
932cd76bf879
VMM: Dropped support for Dovecot versions before v1.2.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
689
diff
changeset
|
602 |
"on the used Dovecot version and the system's libc.\n" |
932cd76bf879
VMM: Dropped support for Dovecot versions before v1.2.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
689
diff
changeset
|
603 |
"Additionally a few usable encoding suffixes will be " |
932cd76bf879
VMM: Dropped support for Dovecot versions before v1.2.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
689
diff
changeset
|
604 |
"displayed. One of them can be appended to the password " |
932cd76bf879
VMM: Dropped support for Dovecot versions before v1.2.0.
Pascal Volk <user@localhost.localdomain.org>
parents:
689
diff
changeset
|
605 |
"scheme.")), |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
606 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
607 |
lp.set_defaults(func=list_pwschemes, scmd='listpwschemes') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
608 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
609 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
610 |
# domain subcommands |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
611 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
612 |
da = a('domainadd', aliases=('da',), help=_('create a new domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
613 |
epilog=fill(_("Adds the new domain into the database and creates " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
614 |
"the domain directory.\n\nIf the optional argument transport " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
615 |
"is given, it will override the default transport " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
616 |
"(domain.transport) from vmm.cfg. The specified transport " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
617 |
"will be the default transport for all new accounts in this " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
618 |
"domain.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
619 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
620 |
da.add_argument('fqdn', help=_('a fully qualified domain name')) |
686
5f4abdab738e
VMM: Added option `-n NOTE' to {domain,user}add.
Pascal Volk <user@localhost.localdomain.org>
parents:
685
diff
changeset
|
621 |
da.add_argument('-n', metavar='NOTE', dest='note', |
5f4abdab738e
VMM: Added option `-n NOTE' to {domain,user}add.
Pascal Volk <user@localhost.localdomain.org>
parents:
685
diff
changeset
|
622 |
help=_('the note that should be set')) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
623 |
da.add_argument('-t', metavar='TRANSPORT', dest='transport', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
624 |
help=_('a Postfix transport (transport: or ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
625 |
'transport:nexthop)')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
626 |
da.set_defaults(func=domain_add, scmd='domainadd') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
627 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
628 |
details = ('accounts', 'aliasdomains', 'aliases', 'catchall', 'relocated', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
629 |
'full') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
630 |
di = a('domaininfo', aliases=('di',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
631 |
help=_('display information about the given domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
632 |
epilog=fill(_("This subcommand shows some information about the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
633 |
"given domain.\n\nFor a more detailed information about the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
634 |
"domain the optional argument details can be specified. A " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
635 |
"possible details value can be one of the following six " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
636 |
"keywords:\n") + mklst(details)), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
637 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
638 |
di.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
639 |
di.add_argument('-d', choices=details, dest='details', metavar='DETAILS', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
640 |
help=_('additionally details to display')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
641 |
di.set_defaults(func=domain_info, scmd='domaininfo') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
642 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
643 |
do = a('domainnote', aliases=('do',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
644 |
help=_('set, update or delete the note of the given domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
645 |
epilog=_('With this subcommand, it is possible to attach a note to ' |
689
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
646 |
'the specified domain. In order to delete an existing ' |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
647 |
'note, pass the -d option.')) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
648 |
do.add_argument('fqdn', help=_('a fully qualified domain name')) |
689
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
649 |
do_grp = do.add_mutually_exclusive_group(required=True) |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
650 |
do_grp.add_argument('-d', action='store_true', dest='delete', |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
651 |
help=_('delete the note, if any')) |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
652 |
do_grp.add_argument('-n', metavar='NOTE', dest='note', |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
653 |
help=_('the note that should be set')) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
654 |
do.set_defaults(func=domain_note, scmd='domainnote') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
655 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
656 |
dq = a('domainquota', aliases=('dq',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
657 |
help=_('update the quota limit of the specified domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
658 |
epilog=fill(_("This subcommand is used to configure a new quota " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
659 |
"limit for the accounts of the domain - not for the domain " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
660 |
"itself.\n\nThe default quota limit for accounts is defined " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
661 |
"in the vmm.cfg (domain.quota_bytes and " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
662 |
"domain.quota_messages).\n\nThe new quota limit will affect " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
663 |
"only those accounts for which the limit has not been " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
664 |
"overridden. If you want to restore the default to all " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
665 |
"accounts, you may pass the optional argument --force. When " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
666 |
"the argument messages was omitted the default number of " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
667 |
"messages 0 (zero) will be applied.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
668 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
669 |
dq.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
670 |
dq.add_argument('storage', type=quota_storage, |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
671 |
help=_('quota limit in {kilo,mega,giga}bytes e.g. 2G ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
672 |
'or 2048M',)) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
673 |
dq.add_argument('-m', default=0, type=int, metavar='MESSAGES', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
674 |
dest='messages', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
675 |
help=_('quota limit in number of messages (default: 0)')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
676 |
dq.add_argument('--force', action='store_true', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
677 |
help=_('enforce the limit for all accounts')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
678 |
dq.set_defaults(func=domain_quota, scmd='domainquota') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
679 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
680 |
ds = a('domainservices', aliases=('ds',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
681 |
help=_('enables the specified services and disables all not ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
682 |
'specified services of the given domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
683 |
epilog=fill(_("To define which services could be used by the users " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
684 |
"of the domain — with the given fqdn — use this " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
685 |
"subcommand.\n\nEach specified service will be enabled/" |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
686 |
"usable. All other services will be deactivated/unusable. " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
687 |
"Possible service names are: imap, pop3, sieve and smtp.\nThe " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
688 |
"new service set will affect only those accounts for which " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
689 |
"the set has not been overridden. If you want to restore the " |
679
b6ef80a8daa2
VMM/cli/subcommands: Rephrased two help messages.
Pascal Volk <user@localhost.localdomain.org>
parents:
676
diff
changeset
|
690 |
"default to all accounts, you may pass the option--force.")), |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
691 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
692 |
ds.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
693 |
ds.add_argument('-s', choices=SERVICES, |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
694 |
help=_('services which should be usable'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
695 |
metavar='SERVICE', nargs='+', dest='services') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
696 |
ds.add_argument('--force', action='store_true', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
697 |
help=_('enforce the service set for all accounts')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
698 |
ds.set_defaults(func=domain_services, scmd='domainservices') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
699 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
700 |
dt = a('domaintransport', aliases=('dt',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
701 |
help=_('update the transport of the specified domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
702 |
epilog=fill(_("A new transport for the indicated domain can be set " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
703 |
"with this subcommand.\n\nThe new transport will affect only " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
704 |
"those accounts for which the transport has not been " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
705 |
"overridden. If you want to restore the default to all " |
679
b6ef80a8daa2
VMM/cli/subcommands: Rephrased two help messages.
Pascal Volk <user@localhost.localdomain.org>
parents:
676
diff
changeset
|
706 |
"accounts, you may give the option --force.")), |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
707 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
708 |
dt.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
709 |
dt.add_argument('transport', help=_('a Postfix transport (transport: or ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
710 |
'transport:nexthop)')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
711 |
dt.add_argument('--force', action='store_true', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
712 |
help=_('enforce the transport for all accounts')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
713 |
dt.set_defaults(func=domain_transport, scmd='domaintransport') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
714 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
715 |
dd = a('domaindelete', aliases=('dd',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
716 |
help=_('delete the given domain and all its alias domains'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
717 |
epilog=fill(_("This subcommand deletes the domain specified by " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
718 |
"fqdn.\n\nIf there are accounts, aliases and/or relocated " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
719 |
"users assigned to the given domain, vmm will abort the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
720 |
"requested operation and show an error message. If you know, " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
721 |
"what you are doing, you can specify the optional argument " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
722 |
"--force.\n\nIf you really always know what you are doing, " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
723 |
"edit your vmm.cfg and set the option domain.force_deletion " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
724 |
"to true.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
725 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
726 |
dd.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
727 |
dd.add_argument('--force', action='store_true', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
728 |
help=_('also delete all accounts, aliases and/or ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
729 |
'relocated users')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
730 |
dd.set_defaults(func=domain_delete, scmd='domaindelete') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
731 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
732 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
733 |
# alias domain subcommands |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
734 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
735 |
ada = a('aliasdomainadd', aliases=('ada',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
736 |
help=_('create a new alias for an existing domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
737 |
epilog=_('This subcommand adds the new alias domain (fqdn) to ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
738 |
'the destination domain that should be aliased.')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
739 |
ada.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
740 |
ada.add_argument('destination', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
741 |
help=_('the fqdn of the destination domain')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
742 |
ada.set_defaults(func=aliasdomain_add, scmd='aliasdomainadd') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
743 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
744 |
adi = a('aliasdomaininfo', aliases=('adi',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
745 |
help=_('show the destination of the given alias domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
746 |
epilog=_('This subcommand shows to which domain the alias domain ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
747 |
'fqdn is assigned to.')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
748 |
adi.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
749 |
adi.set_defaults(func=aliasdomain_info, scmd='aliasdomaininfo') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
750 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
751 |
ads = a('aliasdomainswitch', aliases=('ads',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
752 |
help=_('assign the given alias domain to an other domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
753 |
epilog=_('If the destination of the existing alias domain fqdn ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
754 |
'should be switched to another destination use this ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
755 |
'subcommand.')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
756 |
ads.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
757 |
ads.add_argument('destination', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
758 |
help=_('the fqdn of the destination domain')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
759 |
ads.set_defaults(func=aliasdomain_switch, scmd='aliasdomainswitch') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
760 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
761 |
add = a('aliasdomaindelete', aliases=('add',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
762 |
help=_('delete the specified alias domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
763 |
epilog=_('Use this subcommand if the alias domain fqdn should be ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
764 |
'removed.')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
765 |
add.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
766 |
add.set_defaults(func=aliasdomain_delete, scmd='aliasdomaindelete') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
767 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
768 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
769 |
# account subcommands |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
770 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
771 |
ua = a('useradd', aliases=('ua',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
772 |
help=_('create a new e-mail user with the given address'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
773 |
epilog=fill(_('Use this subcommand to create a new e-mail account ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
774 |
'for the given address.\n\nIf the password is not provided, ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
775 |
'vmm will prompt for it interactively. When no password is ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
776 |
'provided and account.random_password is set to true, vmm ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
777 |
'will generate a random password and print it to stdout ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
778 |
'after the account has been created.')), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
779 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
780 |
ua.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
781 |
help=_("an account's e-mail address (local-part@fqdn)")) |
686
5f4abdab738e
VMM: Added option `-n NOTE' to {domain,user}add.
Pascal Volk <user@localhost.localdomain.org>
parents:
685
diff
changeset
|
782 |
ua.add_argument('-n', metavar='NOTE', dest='note', |
5f4abdab738e
VMM: Added option `-n NOTE' to {domain,user}add.
Pascal Volk <user@localhost.localdomain.org>
parents:
685
diff
changeset
|
783 |
help=_('the note that should be set')) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
784 |
ua.add_argument('-p', metavar='PASSWORD', dest='password', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
785 |
help=_("the new user's password")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
786 |
ua.set_defaults(func=user_add, scmd='useradd') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
787 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
788 |
details = ('aliases', 'du', 'full') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
789 |
ui = a('userinfo', aliases=('ui',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
790 |
help=_('display information about the given address'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
791 |
epilog=fill(_('This subcommand displays some information about ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
792 |
'the account specified by the given address.\n\nIf the ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
793 |
'optional argument details is given some more information ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
794 |
'will be displayed.\nPossible values for details are:\n') + |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
795 |
mklst(details)), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
796 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
797 |
ui.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
798 |
help=_("an account's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
799 |
ui.add_argument('-d', choices=details, metavar='DETAILS', dest='details', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
800 |
help=_('additionally details to display')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
801 |
ui.set_defaults(func=user_info, scmd='userinfo') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
802 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
803 |
un = a('username', aliases=('un',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
804 |
help=_('set, update or delete the real name for an address'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
805 |
epilog=fill(_("The user's real name can be set/updated with this " |
689
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
806 |
"subcommand.\n\nIn order to delete the value stored for the " |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
807 |
"account, pass the -d option.")), |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
808 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
809 |
un.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
810 |
help=_("an account's e-mail address (local-part@fqdn)")) |
689
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
811 |
un_grp = un.add_mutually_exclusive_group(required=True) |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
812 |
un_grp.add_argument('-d', action='store_true', dest='delete', |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
813 |
help=_("delete the user's name if any")) |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
814 |
un_grp.add_argument('-n', help=_("a user's real name"), metavar='NAME', |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
815 |
dest='name') |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
816 |
un.set_defaults(func=user_name, scmd='username') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
817 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
818 |
uo = a('usernote', aliases=('uo',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
819 |
help=_('set, update or delete the note of the given address'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
820 |
epilog=_('With this subcommand, it is possible to attach a note to ' |
689
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
821 |
'the specified account. In order to delete an existing note, ' |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
822 |
'pass the -d option.')) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
823 |
uo.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
824 |
help=_("an account's e-mail address (local-part@fqdn)")) |
689
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
825 |
uo_grp = uo.add_mutually_exclusive_group(required=True) |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
826 |
uo_grp.add_argument('-d', action='store_true', dest='delete', |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
827 |
help=_('delete the note, if any')) |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
828 |
uo_grp.add_argument('-n', metavar='NOTE', dest='note', |
dab0630947a2
VMM/cli/subcommands: Avoid the accidentally deletion of values.
Pascal Volk <user@localhost.localdomain.org>
parents:
686
diff
changeset
|
829 |
help=_('the note that should be set')) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
830 |
uo.set_defaults(func=user_note, scmd='usernote') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
831 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
832 |
up = a('userpassword', aliases=('up',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
833 |
help=_('update the password for the given address'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
834 |
epilog=fill(_("The password of an account can be updated with this " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
835 |
"subcommand.\n\nIf no password was provided, vmm will prompt " |
728
69eb7a65d8a4
VMM/cli/subcommands: userpassword added option -s.
Pascal Volk <user@localhost.localdomain.org>
parents:
711
diff
changeset
|
836 |
"for it interactively. When the scheme was omitted, vmm will " |
69eb7a65d8a4
VMM/cli/subcommands: userpassword added option -s.
Pascal Volk <user@localhost.localdomain.org>
parents:
711
diff
changeset
|
837 |
"use misc.password_scheme from vmm.cfg. ")), |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
838 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
839 |
up.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
840 |
help=_("an account's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
841 |
up.add_argument('-p', metavar='PASSWORD', dest='password', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
842 |
help=_("the user's new password")) |
728
69eb7a65d8a4
VMM/cli/subcommands: userpassword added option -s.
Pascal Volk <user@localhost.localdomain.org>
parents:
711
diff
changeset
|
843 |
up.add_argument('-s', metavar='SCHEME', dest='scheme', |
69eb7a65d8a4
VMM/cli/subcommands: userpassword added option -s.
Pascal Volk <user@localhost.localdomain.org>
parents:
711
diff
changeset
|
844 |
help=_('scheme used for password hashing')) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
845 |
up.set_defaults(func=user_password, scmd='userpassword') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
846 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
847 |
uq = a('userquota', aliases=('uq',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
848 |
help=_('update the quota limit for the given address'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
849 |
epilog=fill(_("This subcommand is used to set a new quota limit " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
850 |
"for the given account.\n\nWhen the argument messages was " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
851 |
"omitted the default number of messages 0 (zero) will be " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
852 |
"applied.\n\nInstead of a storage limit pass the keyword " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
853 |
"'domain' to remove the account-specific override, causing " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
854 |
"the domain's value to be in effect.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
855 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
856 |
uq.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
857 |
help=_("an account's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
858 |
uq.add_argument('storage', type=quota_storage, |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
859 |
help=_('quota limit in {kilo,mega,giga}bytes e.g. 2G ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
860 |
'or 2048M')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
861 |
uq.add_argument('-m', default=0, type=int, metavar='MESSAGES', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
862 |
dest='messages', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
863 |
help=_('quota limit in number of messages (default: 0)')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
864 |
uq.set_defaults(func=user_quota, scmd='userquota') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
865 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
866 |
us = a('userservices', aliases=('us',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
867 |
help=_('enable the specified services and disables all not ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
868 |
'specified services'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
869 |
epilog=fill(_("To grant a user access to the specified service(s), " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
870 |
"use this command.\n\nAll omitted services will be " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
871 |
"deactivated/unusable for the user with the given " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
872 |
"address.\n\nInstead of any service pass the keyword " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
873 |
"'domain' to remove the account-specific override, causing " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
874 |
"the domain's value to be in effect.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
875 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
876 |
us.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
877 |
help=_("an account's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
878 |
us.add_argument('-s', choices=SERVICES + ('domain',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
879 |
help=_('services which should be usable'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
880 |
metavar='SERVICE', nargs='+', dest='services') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
881 |
us.set_defaults(func=user_services, scmd='userservices') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
882 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
883 |
ut = a('usertransport', aliases=('ut',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
884 |
help=_('update the transport of the given address'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
885 |
epilog=fill(_("A different transport for an account can be " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
886 |
"specified with this subcommand.\n\nInstead of a transport " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
887 |
"pass the keyword 'domain' to remove the account-specific " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
888 |
"override, causing the domain's value to be in effect.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
889 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
890 |
ut.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
891 |
help=_("an account's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
892 |
ut.add_argument('transport', help=_('a Postfix transport (transport: or ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
893 |
'transport:nexthop)')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
894 |
ut.set_defaults(func=user_transport, scmd='usertransport') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
895 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
896 |
ud = a('userdelete', aliases=('ud',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
897 |
help=_('delete the specified user'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
898 |
epilog=fill(_('Use this subcommand to delete the account with the ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
899 |
'given address.\n\nIf there are one or more aliases with an ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
900 |
'identical destination address, vmm will abort the requested ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
901 |
'operation and show an error message. To prevent this, ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
902 |
'give the optional argument --force.')), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
903 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
904 |
ud.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
905 |
help=_("an account's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
906 |
ud.add_argument('--force', action='store_true', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
907 |
help=_('also delete assigned alias addresses')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
908 |
ud.set_defaults(func=user_delete, scmd='userdelete') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
909 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
910 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
911 |
# alias subcommands |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
912 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
913 |
aa = a('aliasadd', aliases=('aa',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
914 |
help=_('create a new alias e-mail address with one or more ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
915 |
'destinations'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
916 |
epilog=fill(_("This subcommand is used to create a new alias " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
917 |
"address with one or more destination addresses.\n\nWithin " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
918 |
"the destination address, the placeholders %n, %d, and %= " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
919 |
"will be replaced by the local part, the domain, or the " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
920 |
"email address with '@' replaced by '=' respectively. In " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
921 |
"combination with alias domains, this enables " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
922 |
"domain-specific destinations.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
923 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
924 |
aa.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
925 |
help=_("an alias' e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
926 |
aa.add_argument('destination', nargs='+', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
927 |
help=_("a destination's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
928 |
aa.set_defaults(func=alias_add, scmd='aliasadd') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
929 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
930 |
ai = a('aliasinfo', aliases=('ai',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
931 |
help=_('show the destination(s) of the specified alias'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
932 |
epilog=_('Information about the alias with the given address can ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
933 |
'be displayed with this subcommand.')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
934 |
ai.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
935 |
help=_("an alias' e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
936 |
ai.set_defaults(func=alias_info, scmd='aliasinfo') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
937 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
938 |
ad = a('aliasdelete', aliases=('ad',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
939 |
help=_('delete the specified alias e-mail address or one of its ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
940 |
'destinations'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
941 |
epilog=fill(_("This subcommand is used to delete one or multiple " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
942 |
"destinations from the alias with the given address.\n\nWhen " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
943 |
"no destination address was specified the alias with all its " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
944 |
"destinations will be deleted.")), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
945 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
946 |
ad.add_argument('address', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
947 |
help=_("an alias' e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
948 |
ad.add_argument('destination', nargs='*', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
949 |
help=_("a destination's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
950 |
ad.set_defaults(func=alias_delete, scmd='aliasdelete') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
951 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
952 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
953 |
# catch-all subcommands |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
954 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
955 |
caa = a('catchalladd', aliases=('caa',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
956 |
help=_('add one or more catch-all destinations for a domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
957 |
epilog=fill(_('This subcommand allows to specify destination ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
958 |
'addresses for a domain, which shall receive mail addressed ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
959 |
'to unknown local parts within that domain. Those catch-all ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
960 |
'aliases hence "catch all" mail to any address in the domain ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
961 |
'(unless a more specific alias, mailbox or relocated entry ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
962 |
'exists).\n\nWARNING: Catch-all addresses can cause mail ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
963 |
'server flooding because spammers like to deliver mail to ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
964 |
'all possible combinations of names, e.g. to all addresses ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
965 |
'between abba@example.org and zztop@example.org.')), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
966 |
formatter_class=RawDescriptionHelpFormatter) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
967 |
caa.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
968 |
caa.add_argument('destination', nargs='+', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
969 |
help=_("a destination's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
970 |
caa.set_defaults(func=catchall_add, scmd='catchalladd') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
971 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
972 |
cai = a('catchallinfo', aliases=('cai',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
973 |
help=_('show the catch-all destination(s) of the specified ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
974 |
'domain'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
975 |
epilog=_('This subcommand displays information about catch-all ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
976 |
'aliases defined for a domain.')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
977 |
cai.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
978 |
cai.set_defaults(func=catchall_info, scmd='catchallinfo') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
979 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
980 |
cad = a('catchalldelete', aliases=('cad',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
981 |
help=_("delete the specified catch-all destination or all of a " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
982 |
"domain's destinations"), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
983 |
epilog=_('With this subcommand, catch-all aliases defined for a ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
984 |
'domain can be removed, either all of them, or those ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
985 |
'destinations which were specified explicitly.')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
986 |
cad.add_argument('fqdn', help=_('a fully qualified domain name')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
987 |
cad.add_argument('destination', nargs='*', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
988 |
help=_("a destination's e-mail address (local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
989 |
cad.set_defaults(func=catchall_delete, scmd='catchalldelete') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
990 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
991 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
992 |
# relocated subcommands |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
993 |
### |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
994 |
ra = a('relocatedadd', aliases=('ra',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
995 |
help=_('create a new record for a relocated user'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
996 |
epilog=_("A new relocated user can be created with this " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
997 |
"subcommand.")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
998 |
ra.add_argument('address', help=_("a relocated user's e-mail address " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
999 |
"(local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1000 |
ra.add_argument('newaddress', |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1001 |
help=_('e-mail address where the user can be reached now')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1002 |
ra.set_defaults(func=relocated_add, scmd='relocatedadd') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1003 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1004 |
ri = a('relocatedinfo', aliases=('ri',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1005 |
help=_('print information about a relocated user'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1006 |
epilog=_('This subcommand shows the new address of the relocated ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1007 |
'user with the given address.')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1008 |
ri.add_argument('address', help=_("a relocated user's e-mail address " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1009 |
"(local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1010 |
ri.set_defaults(func=relocated_info, scmd='relocatedinfo') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1011 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1012 |
rd = a('relocateddelete', aliases=('rd',), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1013 |
help=_('delete the record of the relocated user'), |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1014 |
epilog=_('Use this subcommand in order to delete the relocated ' |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1015 |
'user with the given address.')) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1016 |
rd.add_argument('address', help=_("a relocated user's e-mail address " |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1017 |
"(local-part@fqdn)")) |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1018 |
rd.set_defaults(func=relocated_delete, scmd='relocateddelete') |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1019 |
|
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1020 |
txt_wrpr.replace_whitespace = old_rw |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1021 |
return parser |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1022 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1023 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1024 |
def _get_order(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1025 |
"""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
|
1026 |
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
|
1027 |
order = () |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1028 |
if ctx.args.scmd == 'domaininfo': |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1029 |
order = (('domain name', 0), ('gid', 1), ('domain directory', 0), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1030 |
('quota limit/user', 0), ('active services', 0), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1031 |
('transport', 0), ('alias domains', 0), ('accounts', 0), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1032 |
('aliases', 0), ('relocated', 0), ('catch-all dests', 0)) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1033 |
elif ctx.args.scmd == 'userinfo': |
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1034 |
if ctx.args.details in ('du', 'full') or \ |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1035 |
ctx.cget('account.disk_usage'): |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1036 |
order = (('address', 0), ('name', 0), ('uid', 1), ('gid', 1), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1037 |
('home', 0), ('mail_location', 0), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1038 |
('quota storage', 0), ('quota messages', 0), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1039 |
('disk usage', 0), ('transport', 0), ('smtp', 1), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1040 |
('pop3', 1), ('imap', 1), ('sieve', 1)) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1041 |
else: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1042 |
order = (('address', 0), ('name', 0), ('uid', 1), ('gid', 1), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1043 |
('home', 0), ('mail_location', 0), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1044 |
('quota storage', 0), ('quota messages', 0), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1045 |
('transport', 0), ('smtp', 1), ('pop3', 1), |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1046 |
('imap', 1), ('sieve', 1)) |
665
33d15936b53a
VMM/cli/subcommands: Switched argument parsing over to argparse.
Pascal Volk <user@localhost.localdomain.org>
parents:
657
diff
changeset
|
1047 |
elif ctx.args.scmd == 'getuser': |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1048 |
order = (('uid', 1), ('gid', 1), ('address', 0)) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1049 |
return order |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1050 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1051 |
|
532
2bb40aaef94e
Modify userinfo output to indicate when domain defaults are displayed
martin f. krafft <madduck@madduck.net>
parents:
528
diff
changeset
|
1052 |
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
|
1053 |
"""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
|
1054 |
if human: |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
1055 |
q_usage = { |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
1056 |
'used': human_size(used), |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
1057 |
'limit': human_size(limit), |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
1058 |
} |
398
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
1059 |
else: |
401
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
1060 |
q_usage = { |
653
cf07e4468934
VMM: Post-2to3 fixes.
Pascal Volk <user@localhost.localdomain.org>
parents:
643
diff
changeset
|
1061 |
'used': locale.format('%d', used, True), |
cf07e4468934
VMM: Post-2to3 fixes.
Pascal Volk <user@localhost.localdomain.org>
parents:
643
diff
changeset
|
1062 |
'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
|
1063 |
} |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
1064 |
if limit: |
414
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
1065 |
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
|
1066 |
else: |
414
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
1067 |
q_usage['percent'] = locale.format('%6.2f', 0, True) |
638
0de0b9e75c9f
VMM: Partial PEP-308-ification.
Pascal Volk <user@localhost.localdomain.org>
parents:
618
diff
changeset
|
1068 |
fmt = format_domain_default if domaindefault else lambda s: s |
609
56ec275911f2
Added a few comments for the Translation Project.
Pascal Volk <user@localhost.localdomain.org>
parents:
608
diff
changeset
|
1069 |
# TP: e.g.: [ 0.00%] 21.09 KiB/1.00 GiB |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1070 |
return fmt(_('[%(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
|
1071 |
|
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
1072 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1073 |
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
|
1074 |
"""Print info dicts.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1075 |
# TP: used in e.g. 'Domain information' or 'Account information' |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1076 |
msg = '%s %s' % (title, _('information')) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1077 |
w_std(msg, '-' * len(msg)) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1078 |
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
|
1079 |
if upper: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1080 |
w_std('\t%s: %s' % (key.upper().ljust(17, '.'), info[key])) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1081 |
else: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1082 |
w_std('\t%s: %s' % (key.title().ljust(17, '.'), info[key])) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1083 |
print() |
593
3dc1764c23d2
VMM/cli/subcommands: Added 'missing' newline below domain notes.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
1084 |
note = info.get('note') |
3dc1764c23d2
VMM/cli/subcommands: Added 'missing' newline below domain notes.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
1085 |
if note: |
3dc1764c23d2
VMM/cli/subcommands: Added 'missing' newline below domain notes.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
1086 |
_print_note(note + '\n') |
3dc1764c23d2
VMM/cli/subcommands: Added 'missing' newline below domain notes.
Pascal Volk <user@localhost.localdomain.org>
parents:
568
diff
changeset
|
1087 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1088 |
|
542
c3b98364f03d
Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents:
539
diff
changeset
|
1089 |
def _print_note(note): |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1090 |
msg = _('Note') |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1091 |
w_std(msg, '-' * len(msg)) |
542
c3b98364f03d
Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents:
539
diff
changeset
|
1092 |
old_ii = txt_wrpr.initial_indent |
c3b98364f03d
Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents:
539
diff
changeset
|
1093 |
old_si = txt_wrpr.subsequent_indent |
c3b98364f03d
Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents:
539
diff
changeset
|
1094 |
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
|
1095 |
txt_wrpr.width -= 8 |
c3b98364f03d
Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents:
539
diff
changeset
|
1096 |
for para in note.split('\n'): |
c3b98364f03d
Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents:
539
diff
changeset
|
1097 |
w_std(txt_wrpr.fill(para)) |
c3b98364f03d
Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents:
539
diff
changeset
|
1098 |
txt_wrpr.width += 8 |
c3b98364f03d
Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents:
539
diff
changeset
|
1099 |
txt_wrpr.subsequent_indent = old_si |
c3b98364f03d
Display formatted notes in info output
martin f. krafft <madduck@madduck.net>
parents:
539
diff
changeset
|
1100 |
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
|
1101 |
|
611
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1102 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1103 |
def _print_list(alist, title): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1104 |
"""Print a list.""" |
429
9842650569c2
Messages: Replaced some 'Available' by 'Existing'.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
423
diff
changeset
|
1105 |
# TP: used in e.g. 'Existing alias addresses' or 'Existing accounts' |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1106 |
msg = '%s %s' % (_('Existing'), title) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1107 |
w_std(msg, '-' * len(msg)) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1108 |
if alist: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1109 |
if title != _('alias domains'): |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1110 |
w_std(*('\t%s' % item for item in alist)) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1111 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1112 |
for domain in alist: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1113 |
if not domain.startswith('xn--'): |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1114 |
w_std('\t%s' % domain) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1115 |
else: |
657
6515e3b88dec
VMM/cli/subcommands: Fixed some encode/decode issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
656
diff
changeset
|
1116 |
w_std('\t%s (%s)' % (domain, |
6515e3b88dec
VMM/cli/subcommands: Fixed some encode/decode issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
656
diff
changeset
|
1117 |
domain.encode('utf-8').decode('idna'))) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1118 |
print() |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1119 |
else: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1120 |
w_std(_('\tNone'), '') |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1121 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1122 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1123 |
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
|
1124 |
"""Print the alias address and all its destinations""" |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1125 |
title = _('Alias information') |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1126 |
w_std(title, '-' * len(title)) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1127 |
w_std(_('\tMail for %s will be redirected to:') % alias) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1128 |
w_std(*('\t * %s' % dest for dest in destinations)) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1129 |
print() |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1130 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1131 |
|
506
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
1132 |
def _print_catchall_info(domain, destinations): |
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
1133 |
"""Print the catchall destinations of a domain""" |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1134 |
title = _('Catch-all information') |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1135 |
w_std(title, '-' * len(title)) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1136 |
w_std(_('\tMail to unknown local-parts in domain %s will be sent to:') |
506
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
1137 |
% domain) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1138 |
w_std(*('\t * %s' % dest for dest in destinations)) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1139 |
print() |
506
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
1140 |
|
fb0ffde628d6
Teach CLI about catchall* commands
martin f. krafft <madduck@madduck.net>
parents:
487
diff
changeset
|
1141 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1142 |
def _print_relocated_info(**kwargs): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1143 |
"""Print the old and new addresses of a relocated user.""" |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1144 |
title = _('Relocated information') |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1145 |
w_std(title, '-' * len(title)) |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1146 |
w_std(_("\tUser '%(addr)s' has moved to '%(dest)s'") % kwargs, '') |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1147 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1148 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1149 |
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
|
1150 |
"""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
|
1151 |
if domain.startswith('xn--'): |
657
6515e3b88dec
VMM/cli/subcommands: Fixed some encode/decode issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
656
diff
changeset
|
1152 |
domain = '%s (%s)' % (domain, domain.encode('utf-8').decode('idna')) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1153 |
if main: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1154 |
return '\t[+] %s' % domain |
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1155 |
return '\t[-] %s' % domain |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1156 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1157 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1158 |
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
|
1159 |
"""Print a list of (matching) domains/alias domains.""" |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1160 |
title = _('Matching domains') if matching else _('Existing domains') |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1161 |
w_std(title, '-' * len(title)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1162 |
if domains: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1163 |
for did in dids: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1164 |
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
|
1165 |
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
|
1166 |
if len(domains[did]) > 1: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1167 |
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
|
1168 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1169 |
w_std(_('\tNone')) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1170 |
print() |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1171 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1172 |
|
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1173 |
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
|
1174 |
"""Print a list of (matching) addresses.""" |
611
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1175 |
_trans = { |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1176 |
TYPE_ACCOUNT: _('user accounts'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1177 |
TYPE_ALIAS: _('aliases'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1178 |
TYPE_RELOCATED: _('relocated users'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1179 |
TYPE_ACCOUNT | TYPE_ALIAS: _('user accounts and aliases'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1180 |
TYPE_ACCOUNT | TYPE_RELOCATED: _('user accounts and relocated users'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1181 |
TYPE_ALIAS | TYPE_RELOCATED: _('aliases and relocated users'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1182 |
TYPE_ACCOUNT | TYPE_ALIAS | TYPE_RELOCATED: _('addresses'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1183 |
} |
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1184 |
try: |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1185 |
if matching: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1186 |
title = _('Matching %s') % _trans[which] |
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1187 |
else: |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1188 |
title = _('Existing %s') % _trans[which] |
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1189 |
w_std(title, '-' * len(title)) |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1190 |
except KeyError: |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1191 |
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
|
1192 |
INVALID_ARGUMENT) |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1193 |
if addresses: |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1194 |
if which & (which - 1) == 0: |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1195 |
# only one type is requested, so no type indicator |
611
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1196 |
_trans = {TYPE_ACCOUNT: '', TYPE_ALIAS: '', TYPE_RELOCATED: ''} |
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1197 |
else: |
609
56ec275911f2
Added a few comments for the Translation Project.
Pascal Volk <user@localhost.localdomain.org>
parents:
608
diff
changeset
|
1198 |
# TP: the letters 'u', 'a' and 'r' are abbreviations of user, |
56ec275911f2
Added a few comments for the Translation Project.
Pascal Volk <user@localhost.localdomain.org>
parents:
608
diff
changeset
|
1199 |
# alias and relocated user |
611
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1200 |
_trans = { |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1201 |
TYPE_ACCOUNT: _('u'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1202 |
TYPE_ALIAS: _('a'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1203 |
TYPE_RELOCATED: _('r'), |
8e9b0046bc8f
PEP8: Fixed all PEP8 related issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
609
diff
changeset
|
1204 |
} |
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1205 |
for did in dids: |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1206 |
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
|
1207 |
if aliasdomain: |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1208 |
leader = '[%s-]' % _trans[atype] |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1209 |
else: |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1210 |
leader = '[%s+]' % _trans[atype] |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1211 |
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
|
1212 |
else: |
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1213 |
w_std(_('\tNone')) |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1214 |
print() |
555
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1215 |
|
499c63f52462
Provide list{addresses,aliases,users,relocated} subcommands
martin f. krafft <madduck@madduck.net>
parents:
551
diff
changeset
|
1216 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1217 |
def _print_aliasdomain_info(info): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1218 |
"""Print alias domain information.""" |
643
df1e3b67882a
Ran 2to3 from Python 3.2.3.
Pascal Volk <user@localhost.localdomain.org>
parents:
640
diff
changeset
|
1219 |
title = _('Alias domain information') |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1220 |
for key in ('alias', 'domain'): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1221 |
if info[key].startswith('xn--'): |
657
6515e3b88dec
VMM/cli/subcommands: Fixed some encode/decode issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
656
diff
changeset
|
1222 |
info[key] = '%s (%s)' % (info[key], |
6515e3b88dec
VMM/cli/subcommands: Fixed some encode/decode issues.
Pascal Volk <user@localhost.localdomain.org>
parents:
656
diff
changeset
|
1223 |
info[key].encode(ENCODING).decode('idna')) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1224 |
w_std(title, '-' * len(title), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1225 |
_('\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
|
1226 |
info, '') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1227 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1228 |
del _ |