author | Pascal Volk <neverseen@users.sourceforge.net> |
Thu, 24 Feb 2011 22:15:10 +0000 | |
branch | v0.6.x |
changeset 419 | 241b192bfcc8 |
parent 418 | 542a4d23a9f0 |
child 420 | d4a341248500 |
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 -*- |
366
d6573da35b5f
Updated copyright notices to include the year 2011.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
362
diff
changeset
|
2 |
# Copyright 2007 - 2011, Pascal Volk |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
3 |
# See COPYING for distribution information. |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
4 |
""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
5 |
VirtualMailManager.cli.subcommands |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
6 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
7 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
8 |
VirtualMailManager's cli subcommands. |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
9 |
""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
10 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
11 |
import locale |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
12 |
import os |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
13 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
14 |
from textwrap import TextWrapper |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
15 |
from time import strftime, strptime |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
16 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
17 |
from VirtualMailManager import ENCODING |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
18 |
from VirtualMailManager.account import SERVICES |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
19 |
from VirtualMailManager.cli import get_winsize, prog, w_err, w_std |
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
20 |
from VirtualMailManager.common import human_size, size_in_bytes, version_str |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
21 |
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
|
22 |
__version__, ACCOUNT_EXISTS, ALIAS_EXISTS, ALIASDOMAIN_ISDOMAIN, \ |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
23 |
DOMAIN_ALIAS_EXISTS, INVALID_ARGUMENT, EX_MISSING_ARGS, RELOCATED_EXISTS |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
24 |
from VirtualMailManager.errors import VMMError |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
25 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
26 |
__all__ = ( |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
27 |
'Command', 'RunContext', 'cmd_map', 'usage', 'alias_add', 'alias_delete', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
28 |
'alias_info', 'aliasdomain_add', 'aliasdomain_delete', 'aliasdomain_info', |
345
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
29 |
'aliasdomain_switch', 'config_get', 'config_set', 'configure', |
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
30 |
'domain_add', 'domain_delete', 'domain_info', 'domain_quota', |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
31 |
'domain_transport', 'get_user', 'help_', 'list_domains', 'relocated_add', |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
32 |
'relocated_delete', 'relocated_info', 'user_add', 'user_delete', |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
33 |
'user_disable', 'user_enable', 'user_info', 'user_name', 'user_password', |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
34 |
'user_quota', 'user_transport', 'version', |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
35 |
) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
36 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
37 |
_ = lambda msg: msg |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
38 |
txt_wrpr = TextWrapper(width=get_winsize()[1] - 1) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
39 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
40 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
41 |
class Command(object): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
42 |
"""Container class for command information.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
43 |
__slots__ = ('name', 'alias', 'func', 'args', 'descr') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
44 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
45 |
def __init__(self, name, alias, func, args, descr): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
46 |
"""Create a new Command instance. |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
47 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
48 |
Arguments: |
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 |
`name` : str |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
51 |
the command name, e.g. ``addalias`` |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
52 |
`alias` : str |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
53 |
the command's short alias, e.g. ``aa`` |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
54 |
`func` : callable |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
55 |
the function to handle the command |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
56 |
`args` : str |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
57 |
argument placeholders, e.g. ``aliasaddress`` |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
58 |
`descr` : str |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
59 |
short description of the command |
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 |
self.name = name |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
62 |
self.alias = alias |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
63 |
self.func = func |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
64 |
self.args = args |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
65 |
self.descr = descr |
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 |
@property |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
68 |
def usage(self): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
69 |
"""the command's usage info.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
70 |
return u'%s %s %s' % (prog, self.name, self.args) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
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 |
class RunContext(object): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
74 |
"""Contains all information necessary to run a subcommand.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
75 |
__slots__ = ('argc', 'args', 'cget', 'hdlr', 'scmd') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
76 |
plan_a_b = _(u'Plan A failed ... trying Plan B: %(subcommand)s %(object)s') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
77 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
78 |
def __init__(self, argv, handler, command): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
79 |
"""Create a new RunContext""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
80 |
self.argc = len(argv) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
81 |
self.args = [unicode(arg, ENCODING) for arg in argv] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
82 |
self.cget = handler.cfg_dget |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
83 |
self.hdlr = handler |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
84 |
self.scmd = command |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
85 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
86 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
87 |
def alias_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
88 |
"""create a new alias e-mail address""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
89 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
90 |
usage(EX_MISSING_ARGS, _(u'Missing alias address and destination.'), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
91 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
92 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
93 |
usage(EX_MISSING_ARGS, _(u'Missing destination address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
94 |
ctx.hdlr.alias_add(ctx.args[2].lower(), *ctx.args[3:]) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
95 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
96 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
97 |
def alias_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
98 |
"""delete the specified alias e-mail address or one of its destinations""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
99 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
100 |
usage(EX_MISSING_ARGS, _(u'Missing alias address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
101 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
102 |
ctx.hdlr.alias_delete(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
103 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
104 |
ctx.hdlr.alias_delete(ctx.args[2].lower(), ctx.args[3]) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
105 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
106 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
107 |
def alias_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
108 |
"""show the destination(s) of the specified alias""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
109 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
110 |
usage(EX_MISSING_ARGS, _(u'Missing alias address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
111 |
address = ctx.args[2].lower() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
112 |
try: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
113 |
_print_aliase_info(address, ctx.hdlr.alias_info(address)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
114 |
except VMMError, err: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
115 |
if err.code is ACCOUNT_EXISTS: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
116 |
w_err(0, ctx.plan_a_b % {'subcommand': u'userinfo', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
117 |
'object': address}) |
376
2af61bc06215
VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
118 |
ctx.scmd = ctx.args[1] = 'userinfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
119 |
user_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
120 |
elif err.code is RELOCATED_EXISTS: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
121 |
w_std(0, ctx.plan_a_b % {'subcommand': u'relocatedinfo', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
122 |
'object': address}) |
376
2af61bc06215
VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
123 |
ctx.scmd = ctx.args[1] = 'relocatedinfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
124 |
relocated_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
125 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
126 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
127 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
128 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
129 |
def aliasdomain_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
130 |
"""create a new alias for an existing domain""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
131 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
132 |
usage(EX_MISSING_ARGS, _(u'Missing alias domain name and destination ' |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
133 |
u'domain name.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
134 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
135 |
usage(EX_MISSING_ARGS, _(u'Missing destination domain name.'), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
136 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
137 |
ctx.hdlr.aliasdomain_add(ctx.args[2].lower(), ctx.args[3].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
138 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
139 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
140 |
def aliasdomain_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
141 |
"""delete the specified alias domain""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
142 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
143 |
usage(EX_MISSING_ARGS, _(u'Missing alias domain name.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
144 |
ctx.hdlr.aliasdomain_delete(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
145 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
146 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
147 |
def aliasdomain_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
148 |
"""show the destination of the given alias domain""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
149 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
150 |
usage(EX_MISSING_ARGS, _(u'Missing alias domain name.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
151 |
try: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
152 |
_print_aliasdomain_info(ctx.hdlr.aliasdomain_info(ctx.args[2].lower())) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
153 |
except VMMError, err: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
154 |
if err.code is ALIASDOMAIN_ISDOMAIN: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
155 |
w_err(0, ctx.plan_a_b % {'subcommand': u'domaininfo', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
156 |
'object': ctx.args[2].lower()}) |
409
54a89c19e534
VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents:
408
diff
changeset
|
157 |
ctx.scmd = ctx.args[1] = 'domaininfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
158 |
domain_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
159 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
160 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
161 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
162 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
163 |
def aliasdomain_switch(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
164 |
"""assign the given alias domain to an other domain""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
165 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
166 |
usage(EX_MISSING_ARGS, _(u'Missing alias domain name and destination ' |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
167 |
u'domain name.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
168 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
169 |
usage(EX_MISSING_ARGS, _(u'Missing destination domain name.'), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
170 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
171 |
ctx.hdlr.aliasdomain_switch(ctx.args[2].lower(), ctx.args[3].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
172 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
173 |
|
345
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
174 |
def config_get(ctx): |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
175 |
"""show the actual value of the configuration option""" |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
176 |
if ctx.argc < 3: |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
177 |
usage(EX_MISSING_ARGS, _(u"Missing option name."), ctx.scmd) |
397
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
178 |
|
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
179 |
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
|
180 |
opt_formater = { |
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
181 |
'misc.dovecot_version': version_str, |
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
182 |
'misc.quota_bytes': human_size, |
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
183 |
} |
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
184 |
|
345
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
185 |
option = ctx.args[2].lower() |
397
cf661a40266d
VMM/cli/subcommands: config_get: Print configured misc.quota_bytes
Pascal Volk <neverseen@users.sourceforge.net>
parents:
376
diff
changeset
|
186 |
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
|
187 |
noop)(ctx.cget(option)))) |
345
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
188 |
|
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
189 |
|
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
190 |
def config_set(ctx): |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
191 |
"""set a new value for the configuration option""" |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
192 |
if ctx.argc < 3: |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
193 |
usage(EX_MISSING_ARGS, _(u'Missing option and new value.'), ctx.scmd) |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
194 |
if ctx.argc < 4: |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
195 |
usage(EX_MISSING_ARGS, _(u'Missing new configuration value.'), |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
196 |
ctx.scmd) |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
197 |
ctx.hdlr.cfg_set(ctx.args[2].lower(), ctx.args[3]) |
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
198 |
|
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
199 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
200 |
def configure(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
201 |
"""start interactive configuration modus""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
202 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
203 |
ctx.hdlr.configure() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
204 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
205 |
ctx.hdlr.configure(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
206 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
207 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
208 |
def domain_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
209 |
"""create a new domain""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
210 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
211 |
usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
212 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
213 |
ctx.hdlr.domain_add(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
214 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
215 |
ctx.hdlr.domain_add(ctx.args[2].lower(), ctx.args[3]) |
362
c2e8eab2616d
VMM/cli/subcommands: Added 'auto postmaster' to domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
361
diff
changeset
|
216 |
if not ctx.cget('domain.auto_postmaster'): |
c2e8eab2616d
VMM/cli/subcommands: Added 'auto postmaster' to domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
361
diff
changeset
|
217 |
return |
c2e8eab2616d
VMM/cli/subcommands: Added 'auto postmaster' to domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
361
diff
changeset
|
218 |
ctx.scmd = 'useradd' |
c2e8eab2616d
VMM/cli/subcommands: Added 'auto postmaster' to domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
361
diff
changeset
|
219 |
ctx.args = [prog, ctx.scmd, u'postmaster@' + ctx.args[2].lower()] |
c2e8eab2616d
VMM/cli/subcommands: Added 'auto postmaster' to domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
361
diff
changeset
|
220 |
ctx.argc = 3 |
c2e8eab2616d
VMM/cli/subcommands: Added 'auto postmaster' to domain_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
361
diff
changeset
|
221 |
user_add(ctx) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
222 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
223 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
224 |
def domain_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
225 |
"""delete the given domain and all its alias domains""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
226 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
227 |
usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
228 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
229 |
ctx.hdlr.domain_delete(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
230 |
elif ctx.args[3].lower() == 'force': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
231 |
ctx.hdlr.domain_delete(ctx.args[2].lower(), True) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
232 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
233 |
usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % ctx.args[3], |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
234 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
235 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
236 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
237 |
def domain_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
238 |
"""display information about the given domain""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
239 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
240 |
usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
241 |
if ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
242 |
details = None |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
243 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
244 |
details = ctx.args[3].lower() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
245 |
if details not in ('accounts', 'aliasdomains', 'aliases', 'full', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
246 |
'relocated'): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
247 |
usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % details, |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
248 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
249 |
try: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
250 |
info = ctx.hdlr.domain_info(ctx.args[2].lower(), details) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
251 |
except VMMError, err: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
252 |
if err.code is DOMAIN_ALIAS_EXISTS: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
253 |
w_err(0, ctx.plan_a_b % {'subcommand': u'aliasdomaininfo', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
254 |
'object': ctx.args[2].lower()}) |
409
54a89c19e534
VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents:
408
diff
changeset
|
255 |
ctx.scmd = ctx.args[1] = 'aliasdomaininfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
256 |
aliasdomain_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
257 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
258 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
259 |
else: |
414
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
260 |
q_limit = u'Storage: %(bytes)s; Messages: %(messages)s' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
261 |
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
|
262 |
info['bytes'] = human_size(info['bytes']) |
414
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
263 |
info['messages'] = locale.format('%d', info['messages'], True) |
408
f6e55b27fe07
VMM/cli/subcommands: Fixed a msgid issue (format string with unnamed arguments).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
406
diff
changeset
|
264 |
info['quota limit'] = q_limit % info |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
265 |
_print_info(ctx, info, _(u'Domain')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
266 |
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
|
267 |
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
|
268 |
info[0]['messages'] = locale.format('%d', info[0]['messages'], |
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
269 |
True) |
408
f6e55b27fe07
VMM/cli/subcommands: Fixed a msgid issue (format string with unnamed arguments).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
406
diff
changeset
|
270 |
info[0]['quota limit'] = q_limit % info[0] |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
271 |
_print_info(ctx, info[0], _(u'Domain')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
272 |
if details == u'accounts': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
273 |
_print_list(info[1], _(u'accounts')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
274 |
elif details == u'aliasdomains': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
275 |
_print_list(info[1], _(u'alias domains')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
276 |
elif details == u'aliases': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
277 |
_print_list(info[1], _(u'aliases')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
278 |
elif details == u'relocated': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
279 |
_print_list(info[1], _(u'relocated users')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
280 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
281 |
_print_list(info[1], _(u'alias domains')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
282 |
_print_list(info[2], _(u'accounts')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
283 |
_print_list(info[3], _(u'aliases')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
284 |
_print_list(info[4], _(u'relocated users')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
285 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
286 |
|
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
287 |
def domain_quota(ctx): |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
288 |
"""update the quota limit of the specified domain""" |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
289 |
if ctx.argc < 3: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
290 |
usage(EX_MISSING_ARGS, _(u'Missing domain name and storage value.'), |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
291 |
ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
292 |
if ctx.argc < 4: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
293 |
usage(EX_MISSING_ARGS, _(u'Missing storage value.'), ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
294 |
messages = 0 |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
295 |
force = None |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
296 |
try: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
297 |
bytes_ = size_in_bytes(ctx.args[3]) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
298 |
except (ValueError, TypeError): |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
299 |
usage(INVALID_ARGUMENT, _(u"Invalid storage value: '%s'") % |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
300 |
ctx.args[3], ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
301 |
if ctx.argc < 5: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
302 |
pass |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
303 |
elif ctx.argc < 6: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
304 |
try: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
305 |
messages = int(ctx.args[4]) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
306 |
except ValueError: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
307 |
if ctx.args[4].lower() != 'force': |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
308 |
usage(INVALID_ARGUMENT, |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
309 |
_(u"Neither a valid number of messages nor the keyword " |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
310 |
u"'force': '%s'") % ctx.args[4], ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
311 |
force = 'force' |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
312 |
else: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
313 |
try: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
314 |
messages = int(ctx.args[4]) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
315 |
except ValueError: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
316 |
usage(INVALID_ARGUMENT, |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
317 |
_(u"Not a valid number of messages: '%s'") % ctx.args[4], |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
318 |
ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
319 |
if ctx.args[5].lower() != 'force': |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
320 |
usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % ctx.args[5], |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
321 |
ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
322 |
force = 'force' |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
323 |
ctx.hdlr.domain_quotalimit(ctx.args[2].lower(), bytes_, messages, force) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
324 |
|
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
325 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
326 |
def domain_transport(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
327 |
"""update the transport of the specified domain""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
328 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
329 |
usage(EX_MISSING_ARGS, _(u'Missing domain name and new transport.'), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
330 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
331 |
if ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
332 |
usage(EX_MISSING_ARGS, _(u'Missing new transport.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
333 |
if ctx.argc < 5: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
334 |
ctx.hdlr.domain_transport(ctx.args[2].lower(), ctx.args[3]) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
335 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
336 |
force = ctx.args[4].lower() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
337 |
if force != 'force': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
338 |
usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % force, |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
339 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
340 |
ctx.hdlr.domain_transport(ctx.args[2].lower(), ctx.args[3], force) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
341 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
342 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
343 |
def get_user(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
344 |
"""get the address of the user with the given UID""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
345 |
if ctx.argc < 3: |
417
8209da83e256
VMM: Updated some messages. (doesn't, isn't) -> (does not, is not)
Pascal Volk <neverseen@users.sourceforge.net>
parents:
414
diff
changeset
|
346 |
usage(EX_MISSING_ARGS, _(u'Missing UID.'), ctx.scmd) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
347 |
_print_info(ctx, ctx.hdlr.user_by_uid(ctx.args[2]), _(u'Account')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
348 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
349 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
350 |
def help_(ctx): |
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
351 |
"""print help messages.""" |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
352 |
if ctx.argc > 2: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
353 |
hlptpc = ctx.args[2].lower() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
354 |
if hlptpc in cmd_map: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
355 |
topic = hlptpc |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
356 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
357 |
for scmd in cmd_map.itervalues(): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
358 |
if scmd.alias == hlptpc: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
359 |
topic = scmd.name |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
360 |
break |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
361 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
362 |
usage(INVALID_ARGUMENT, _(u"Unknown help topic: '%s'") % |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
363 |
ctx.args[2], ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
364 |
# FIXME |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
365 |
w_err(1, "'help %s' not yet implemented." % topic, 'see also: vmm(1)') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
366 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
367 |
old_ii = txt_wrpr.initial_indent |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
368 |
old_si = txt_wrpr.subsequent_indent |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
369 |
txt_wrpr.initial_indent = ' ' |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
370 |
# len(max(_overview.iterkeys(), key=len)) #Py25 |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
371 |
txt_wrpr.subsequent_indent = 20 * ' ' |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
372 |
order = cmd_map.keys() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
373 |
order.sort() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
374 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
375 |
w_std(_(u'List of available subcommands:') + '\n') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
376 |
for key in order: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
377 |
w_std('\n'.join(txt_wrpr.wrap('%-18s %s' % (key, cmd_map[key].descr)))) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
378 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
379 |
txt_wrpr.initial_indent = old_ii |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
380 |
txt_wrpr.subsequent_indent = old_si |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
381 |
txt_wrpr.initial_indent = '' |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
382 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
383 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
384 |
def list_domains(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
385 |
"""list all domains / search domains by pattern""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
386 |
matching = ctx.argc > 2 |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
387 |
if matching: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
388 |
gids, domains = ctx.hdlr.domain_list(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
389 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
390 |
gids, domains = ctx.hdlr.domain_list() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
391 |
_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
|
392 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
393 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
394 |
def relocated_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
395 |
"""create a new record for a relocated user""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
396 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
397 |
usage(EX_MISSING_ARGS, |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
398 |
_(u'Missing relocated address and destination.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
399 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
400 |
usage(EX_MISSING_ARGS, _(u'Missing destination address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
401 |
ctx.hdlr.relocated_add(ctx.args[2].lower(), ctx.args[3]) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
402 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
403 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
404 |
def relocated_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
405 |
"""delete the record of the relocated user""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
406 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
407 |
usage(EX_MISSING_ARGS, _(u'Missing relocated address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
408 |
ctx.hdlr.relocated_delete(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
409 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
410 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
411 |
def relocated_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
412 |
"""print information about a relocated user""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
413 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
414 |
usage(EX_MISSING_ARGS, _(u'Missing relocated address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
415 |
relocated = ctx.args[2].lower() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
416 |
try: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
417 |
_print_relocated_info(addr=relocated, |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
418 |
dest=ctx.hdlr.relocated_info(relocated)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
419 |
except VMMError, err: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
420 |
if err.code is ACCOUNT_EXISTS: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
421 |
w_err(0, ctx.plan_a_b % {'subcommand': u'userinfo', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
422 |
'object': relocated}) |
376
2af61bc06215
VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
423 |
ctx.scmd = ctx.args[1] = 'userinfoi' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
424 |
user_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
425 |
elif err.code is ALIAS_EXISTS: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
426 |
w_err(0, ctx.plan_a_b % {'subcommand': u'aliasinfo', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
427 |
'object': relocated}) |
376
2af61bc06215
VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
428 |
ctx.scmd = ctx.args[1] = 'aliasinfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
429 |
alias_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
430 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
431 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
432 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
433 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
434 |
def user_add(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
435 |
"""create a new e-mail user with the given address""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
436 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
437 |
usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
438 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
439 |
password = None |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
440 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
441 |
password = ctx.args[3] |
361
971577b89d26
VMM/cli/handler: Added support for random passwords in user_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
345
diff
changeset
|
442 |
gen_pass = ctx.hdlr.user_add(ctx.args[2].lower(), password) |
971577b89d26
VMM/cli/handler: Added support for random passwords in user_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
345
diff
changeset
|
443 |
if gen_pass: |
971577b89d26
VMM/cli/handler: Added support for random passwords in user_add().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
345
diff
changeset
|
444 |
w_std(_(u"Generated password: %s") % gen_pass) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
445 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
446 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
447 |
def user_delete(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
448 |
"""delete the specified user""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
449 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
450 |
usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
451 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
452 |
ctx.hdlr.user_delete(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
453 |
elif ctx.args[3].lower() == 'force': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
454 |
ctx.hdlr.user_delete(ctx.args[2].lower(), True) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
455 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
456 |
usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % ctx.args[3], |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
457 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
458 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
459 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
460 |
def user_disable(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
461 |
"""deactivate all/the given service(s) for a user""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
462 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
463 |
usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
464 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
465 |
ctx.hdlr.user_disable(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
466 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
467 |
services = [service.lower() for service in ctx.args[3:]] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
468 |
unknown = [service for service in services if service not in SERVICES] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
469 |
if unknown: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
470 |
usage(INVALID_ARGUMENT, _(u"Invalid service arguments: %s") % |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
471 |
' '.join(unknown), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
472 |
ctx.hdlr.user_disable(ctx.args[2].lower(), services) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
473 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
474 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
475 |
def user_enable(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
476 |
"""activate all or the given service(s) for a user""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
477 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
478 |
usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
479 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
480 |
ctx.hdlr.user_enable(ctx.args[2].lower()) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
481 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
482 |
services = [service.lower() for service in ctx.args[3:]] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
483 |
unknown = [service for service in services if service not in SERVICES] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
484 |
if unknown: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
485 |
usage(INVALID_ARGUMENT, _(u"Invalid service arguments: %s") % |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
486 |
' '.join(unknown), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
487 |
ctx.hdlr.user_enable(ctx.args[2].lower(), services) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
488 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
489 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
490 |
def user_info(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
491 |
"""display information about the given address""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
492 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
493 |
usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
494 |
if ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
495 |
details = None |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
496 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
497 |
details = ctx.args[3].lower() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
498 |
if details not in ('aliases', 'du', 'full'): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
499 |
usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % details, |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
500 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
501 |
try: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
502 |
info = ctx.hdlr.user_info(ctx.args[2].lower(), details) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
503 |
except VMMError, err: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
504 |
if err.code is ALIAS_EXISTS: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
505 |
w_err(0, ctx.plan_a_b % {'subcommand': u'aliasinfo', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
506 |
'object': ctx.args[2].lower()}) |
376
2af61bc06215
VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
507 |
ctx.scmd = ctx.args[1] = 'aliasinfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
508 |
alias_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
509 |
elif err.code is RELOCATED_EXISTS: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
510 |
w_err(0, ctx.plan_a_b % {'subcommand': u'relocatedinfo', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
511 |
'object': ctx.args[2].lower()}) |
376
2af61bc06215
VMM/cli/subcommands: Update also the RunContext's subcommand if
Pascal Volk <neverseen@users.sourceforge.net>
parents:
366
diff
changeset
|
512 |
ctx.scmd = ctx.args[1] = 'relocatedinfo' |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
513 |
relocated_info(ctx) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
514 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
515 |
raise |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
516 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
517 |
if details in (None, 'du'): |
401
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
518 |
info['quota storage'] = _format_quota_usage(info['ql_bytes'], |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
519 |
info['uq_bytes'], True) |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
520 |
info['quota messages'] = _format_quota_usage(info['ql_messages'], |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
521 |
info['uq_messages']) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
522 |
_print_info(ctx, info, _(u'Account')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
523 |
else: |
401
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
524 |
info[0]['quota storage'] = _format_quota_usage(info[0]['ql_bytes'], |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
525 |
info['uq_bytes'], True) |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
526 |
info[0]['quota messages'] = _format_quota_usage( |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
527 |
info[0]['ql_messages'], info[0]['uq_messages']) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
528 |
_print_info(ctx, info[0], _(u'Account')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
529 |
_print_list(info[1], _(u'alias addresses')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
530 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
531 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
532 |
def user_name(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
533 |
"""set or update the real name for an address""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
534 |
if ctx.argc < 3: |
341
6709d0faf2f5
VMM/…: Unified messages and removed non-ASCII quotes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
340
diff
changeset
|
535 |
usage(EX_MISSING_ARGS, _(u"Missing e-mail address and user's name."), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
536 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
537 |
if ctx.argc < 4: |
341
6709d0faf2f5
VMM/…: Unified messages and removed non-ASCII quotes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
340
diff
changeset
|
538 |
usage(EX_MISSING_ARGS, _(u"Missing user's name."), ctx.scmd) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
539 |
ctx.hdlr.user_name(ctx.args[2].lower(), ctx.args[3]) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
540 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
541 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
542 |
def user_password(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
543 |
"""update the password for the given address""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
544 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
545 |
usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
546 |
elif ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
547 |
password = None |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
548 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
549 |
password = ctx.args[3] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
550 |
ctx.hdlr.user_password(ctx.args[2].lower(), password) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
551 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
552 |
|
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
553 |
def user_quota(ctx): |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
554 |
"""update the quota limit for the given address""" |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
555 |
if ctx.argc < 3: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
556 |
usage(EX_MISSING_ARGS, _(u'Missing e-mail address and storage value.'), |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
557 |
ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
558 |
elif ctx.argc < 4: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
559 |
usage(EX_MISSING_ARGS, _(u'Missing storage value.'), ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
560 |
try: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
561 |
bytes_ = size_in_bytes(ctx.args[3]) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
562 |
except (ValueError, TypeError): |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
563 |
usage(INVALID_ARGUMENT, _(u"Invalid storage value: '%s'") % |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
564 |
ctx.args[3], ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
565 |
if ctx.argc < 5: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
566 |
messages = 0 |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
567 |
else: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
568 |
try: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
569 |
messages = int(ctx.args[4]) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
570 |
except ValueError: |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
571 |
usage(INVALID_ARGUMENT, |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
572 |
_(u"Not a valid number of messages: '%s'") % ctx.args[4], |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
573 |
ctx.scmd) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
574 |
ctx.hdlr.user_quotalimit(ctx.args[2].lower(), bytes_, messages) |
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
575 |
|
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
576 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
577 |
def user_transport(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
578 |
"""update the transport of the given address""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
579 |
if ctx.argc < 3: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
580 |
usage(EX_MISSING_ARGS, _(u'Missing e-mail address and transport.'), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
581 |
ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
582 |
if ctx.argc < 4: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
583 |
usage(EX_MISSING_ARGS, _(u'Missing transport.'), ctx.scmd) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
584 |
ctx.hdlr.user_transport(ctx.args[2].lower(), ctx.args[3]) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
585 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
586 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
587 |
def usage(errno, errmsg, subcommand=None): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
588 |
"""print usage message for the given command or all commands. |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
589 |
When errno > 0, sys,exit(errno) will interrupt the program. |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
590 |
""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
591 |
if subcommand and subcommand in cmd_map: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
592 |
w_err(errno, _(u"Error: %s") % errmsg, |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
593 |
_(u"usage: ") + cmd_map[subcommand].usage) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
594 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
595 |
# TP: Please adjust translated words like the original text. |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
596 |
# (It's a table header.) Extract from usage text: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
597 |
# usage: vmm subcommand arguments |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
598 |
# short long |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
599 |
# subcommand arguments |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
600 |
# |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
601 |
# da domainadd fqdn [transport] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
602 |
# dd domaindelete fqdn [force] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
603 |
u_head = _(u"""usage: %s subcommand arguments |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
604 |
short long |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
605 |
subcommand arguments\n""") % prog |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
606 |
order = cmd_map.keys() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
607 |
order.sort() |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
608 |
w_err(0, u_head) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
609 |
for key in order: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
610 |
scmd = cmd_map[key] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
611 |
w_err(0, ' %-5s %-19s %s' % (scmd.alias, scmd.name, scmd.args)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
612 |
w_err(errno, '', _(u"Error: %s") % errmsg) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
613 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
614 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
615 |
def version(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
616 |
"""Write version and copyright information to stdout.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
617 |
w_std('%s, %s %s (%s %s)\nPython %s %s %s\n\n%s\n%s %s' % (prog, |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
618 |
# TP: The words 'from', 'version' and 'on' are used in |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
619 |
# the version information, e.g.: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
620 |
# vmm, version 0.5.2 (from 09/09/09) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
621 |
# Python 2.5.4 on FreeBSD |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
622 |
_(u'version'), __version__, _(u'from'), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
623 |
strftime(locale.nl_langinfo(locale.D_FMT), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
624 |
strptime(__date__, '%Y-%m-%d')).decode(ENCODING, 'replace'), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
625 |
os.sys.version.split()[0], _(u'on'), os.uname()[0], |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
626 |
__copyright__, prog, |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
627 |
_(u'is free software and comes with ABSOLUTELY NO WARRANTY.'))) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
628 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
629 |
cmd = Command |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
630 |
cmd_map = { # {{{ |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
631 |
# Account commands |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
632 |
'getuser': cmd('getuser', 'gu', get_user, _(u'uid'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
633 |
_(u'get the address of the user with the given UID')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
634 |
'useradd': cmd('useradd', 'ua', user_add, _(u'address [password]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
635 |
_(u'create a new e-mail user with the given address')), |
418
542a4d23a9f0
VMM/cli/subcommands: The keyword 'force' is no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
417
diff
changeset
|
636 |
'userdelete': cmd('userdelete', 'ud', user_delete, |
542a4d23a9f0
VMM/cli/subcommands: The keyword 'force' is no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
417
diff
changeset
|
637 |
_(u'address') + ' [force]', |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
638 |
_(u'delete the specified user')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
639 |
'userdisable': cmd('userdisable', 'u0', user_disable, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
640 |
_(u'address [service ...]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
641 |
_(u'deactivate all/the given service(s) for a user')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
642 |
'userenable': cmd('userenable', 'u1', user_enable, |
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
643 |
_(u'address [service ...]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
644 |
_(u'activate all or the given service(s) for a user')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
645 |
'userinfo': cmd('userinfo', 'ui', user_info, _(u'address [details]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
646 |
_(u'display information about the given address')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
647 |
'username': cmd('username', 'un', user_name, _(u'address name'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
648 |
_(u'set or update the real name for an address')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
649 |
'userpassword': cmd('userpassword', 'up', user_password, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
650 |
_(u'address [password]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
651 |
_(u'update the password for the given address')), |
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
652 |
'userquota': cmd('userquota', 'uq', user_quota, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
653 |
_(u'address storage [messages]'), |
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
654 |
_(u'update the quota limit for the given address')), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
655 |
'usertransport': cmd('usertransport', 'ut', user_transport, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
656 |
_(u'address transport'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
657 |
_(u'update the transport of the given address')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
658 |
# Alias commands |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
659 |
'aliasadd': cmd('aliasadd', 'aa', alias_add, _(u'address destination ...'), |
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
660 |
_(u'create a new alias e-mail address with one or more ' |
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
661 |
u'destinations')), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
662 |
'aliasdelete': cmd('aliasdelete', 'ad', alias_delete, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
663 |
_(u'address [destination]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
664 |
_(u'delete the specified alias e-mail address or one ' |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
665 |
u'of its destinations')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
666 |
'aliasinfo': cmd('aliasinfo', 'ai', alias_info, _(u'address'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
667 |
_(u'show the destination(s) of the specified alias')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
668 |
# AliasDomain commands |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
669 |
'aliasdomainadd': cmd('aliasdomainadd', 'ada', aliasdomain_add, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
670 |
_(u'fqdn destination'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
671 |
_(u'create a new alias for an existing domain')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
672 |
'aliasdomaindelete': cmd('aliasdomaindelete', 'add', aliasdomain_delete, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
673 |
_(u'fqdn'), |
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
674 |
_(u'delete the specified alias domain')), |
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
675 |
'aliasdomaininfo': cmd('aliasdomaininfo', 'adi', aliasdomain_info, |
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
676 |
_(u'fqdn'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
677 |
_(u'show the destination of the given alias domain')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
678 |
'aliasdomainswitch': cmd('aliasdomainswitch', 'ads', aliasdomain_switch, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
679 |
_(u'fqdn destination'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
680 |
_(u'assign the given alias domain to an other domain')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
681 |
# Domain commands |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
682 |
'domainadd': cmd('domainadd', 'da', domain_add, _(u'fqdn [transport]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
683 |
_(u'create a new domain')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
684 |
'domaindelete': cmd('domaindelete', 'dd', domain_delete, |
418
542a4d23a9f0
VMM/cli/subcommands: The keyword 'force' is no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
417
diff
changeset
|
685 |
_(u'fqdn') + ' [force]', |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
686 |
_(u'delete the given domain and all its alias domains')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
687 |
'domaininfo': cmd('domaininfo', 'di', domain_info, _(u'fqdn [details]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
688 |
_(u'display information about the given domain')), |
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
689 |
'domainquota': cmd('domainquota', 'dq', domain_quota, |
418
542a4d23a9f0
VMM/cli/subcommands: The keyword 'force' is no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
417
diff
changeset
|
690 |
_(u'fqdn storage [messages]') + ' [force]', |
403
a4f5d4cd886d
VMM/cli/subcommands: Implemented subcommands domainquota and userquota.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
401
diff
changeset
|
691 |
_(u'update the quota limit of the specified domain')), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
692 |
'domaintransport': cmd('domaintransport', 'dt', domain_transport, |
418
542a4d23a9f0
VMM/cli/subcommands: The keyword 'force' is no longer translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
417
diff
changeset
|
693 |
_(u'fqdn transport') + ' [force]', |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
694 |
_(u'update the transport of the specified domain')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
695 |
'listdomains': cmd('listdomains', 'ld', list_domains, _(u'[pattern]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
696 |
_(u'list all domains / search domains by pattern')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
697 |
# Relocated commands |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
698 |
'relocatedadd': cmd('relocatedadd', 'ra', relocated_add, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
699 |
_(u'address newaddress'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
700 |
_(u'create a new record for a relocated user')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
701 |
'relocateddelete': cmd('relocateddelete', 'rd', relocated_delete, |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
702 |
_(u'address'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
703 |
_(u'delete the record of the relocated user')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
704 |
'relocatedinfo': cmd('relocatedinfo', 'ri', relocated_info, _('address'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
705 |
_(u'print information about a relocated user')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
706 |
# cli commands |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
707 |
'configget': cmd('configget', 'cg', config_get, _(u'option'), |
345
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
708 |
_('show the actual value of the configuration option')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
709 |
'configset': cmd('configset', 'cs', config_set, _('option value'), |
345
f8d5c8bb8bce
VMM/cli/subcommands: Added subcommands configget and configset.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
341
diff
changeset
|
710 |
_('set a new value for the configuration option')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
711 |
'configure': cmd('configure', 'cf', configure, _(u'[section]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
712 |
_(u'start interactive configuration modus')), |
406
58e23bd7c97f
VMM/cli/subcommands: Made argument names translatable.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
403
diff
changeset
|
713 |
'help': cmd('help', 'h', help_, _(u'[subcommand]'), |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
714 |
_(u'show a help overview or help for the given subcommand')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
715 |
'version': cmd('version', 'v', version, '', |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
716 |
_(u'show version and copyright information')), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
717 |
} # }}} |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
718 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
719 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
720 |
def _get_order(ctx): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
721 |
"""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
|
722 |
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
|
723 |
order = () |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
724 |
if ctx.scmd == 'domaininfo': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
725 |
order = ((u'domainname', 0), (u'gid', 1), (u'transport', 0), |
398
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
726 |
(u'domaindir', 0), (u'quota limit', 0), (u'aliasdomains', 0), |
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
727 |
(u'accounts', 0), (u'aliases', 0), (u'relocated', 0)) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
728 |
elif ctx.scmd == 'userinfo': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
729 |
dc12 = ctx.cget('misc.dovecot_version') >= 0x10200b02 |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
730 |
sieve = (u'managesieve', u'sieve')[dc12] |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
731 |
if ctx.argc == 4 and ctx.args[3] != u'aliases' or \ |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
732 |
ctx.cget('account.disk_usage'): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
733 |
order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1), |
398
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
734 |
(u'home', 0), (u'mail_location', 0), |
401
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
735 |
(u'quota storage', 0), (u'quota messages', 0), |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
736 |
(u'disk usage', 0), (u'transport', 0), (u'smtp', 1), |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
737 |
(u'pop3', 1), (u'imap', 1), (sieve, 1)) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
738 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
739 |
order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1), |
401
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
740 |
(u'home', 0), (u'mail_location', 0), |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
741 |
(u'quota storage', 0), (u'quota messages', 0), |
398
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
742 |
(u'transport', 0), (u'smtp', 1), (u'pop3', 1), |
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
743 |
(u'imap', 1), (sieve, 1)) |
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
744 |
elif ctx.scmd == 'getuser': |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
745 |
order = ((u'uid', 1), (u'gid', 1), (u'address', 0)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
746 |
return order |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
747 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
748 |
|
401
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
749 |
def _format_quota_usage(limit, used, human=False): |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
750 |
"""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
|
751 |
if human: |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
752 |
q_usage = { |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
753 |
'used': human_size(used), |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
754 |
'limit': human_size(limit), |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
755 |
} |
398
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
756 |
else: |
401
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
757 |
q_usage = { |
414
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
758 |
'used': locale.format('%d', used, True), |
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
759 |
'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
|
760 |
} |
00a8c12a3da3
VMM/cli/subcommands: Divided 'quota usage' from userinfo subcommand
Pascal Volk <neverseen@users.sourceforge.net>
parents:
398
diff
changeset
|
761 |
if limit: |
414
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
762 |
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
|
763 |
else: |
414
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
764 |
q_usage['percent'] = locale.format('%6.2f', 0, True) |
ae1a8428298c
VMM: Report quota usage/limit/percentage values formatted
Pascal Volk <neverseen@users.sourceforge.net>
parents:
413
diff
changeset
|
765 |
return _(u'[%(percent)s%%] %(used)s/%(limit)s') % q_usage |
398
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
766 |
|
3e5ed678d535
VMM/cli/subcommands: Added quota limit/usage output to {domain,user}info
Pascal Volk <neverseen@users.sourceforge.net>
parents:
397
diff
changeset
|
767 |
|
340
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
768 |
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
|
769 |
"""Print info dicts.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
770 |
# TP: used in e.g. 'Domain information' or 'Account information' |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
771 |
msg = u'%s %s' % (title, _(u'information')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
772 |
w_std(msg, u'-' * len(msg)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
773 |
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
|
774 |
if upper: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
775 |
w_std(u'\t%s: %s' % (key.upper().ljust(15, u'.'), info[key])) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
776 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
777 |
w_std(u'\t%s: %s' % (key.title().ljust(15, u'.'), info[key])) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
778 |
print |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
779 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
780 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
781 |
def _print_list(alist, title): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
782 |
"""Print a list.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
783 |
# TP: used in e.g. 'Available alias addresses' or 'Available accounts' |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
784 |
msg = u'%s %s' % (_(u'Available'), title) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
785 |
w_std(msg, u'-' * len(msg)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
786 |
if alist: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
787 |
if title != _(u'alias domains'): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
788 |
w_std(*(u'\t%s' % item for item in alist)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
789 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
790 |
for domain in alist: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
791 |
if not domain.startswith('xn--'): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
792 |
w_std(u'\t%s' % domain) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
793 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
794 |
w_std(u'\t%s (%s)' % (domain, domain.decode('idna'))) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
795 |
print |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
796 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
797 |
w_std(_(u'\tNone'), '') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
798 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
799 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
800 |
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
|
801 |
"""Print the alias address and all its destinations""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
802 |
title = _(u'Alias information') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
803 |
w_std(title, u'-' * len(title)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
804 |
w_std(_(u'\tMail for %s will be redirected to:') % alias) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
805 |
w_std(*(u'\t * %s' % dest for dest in destinations)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
806 |
print |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
807 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
808 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
809 |
def _print_relocated_info(**kwargs): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
810 |
"""Print the old and new addresses of a relocated user.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
811 |
title = _(u'Relocated information') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
812 |
w_std(title, u'-' * len(title)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
813 |
w_std(_(u"\tUser '%(addr)s' has moved to '%(dest)s'") % kwargs, '') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
814 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
815 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
816 |
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
|
817 |
"""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
|
818 |
if domain.startswith('xn--'): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
819 |
domain = u'%s (%s)' % (domain, domain.decode('idna')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
820 |
if main: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
821 |
return u'\t[+] %s' % domain |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
822 |
return u'\t[-] %s' % domain |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
823 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
824 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
825 |
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
|
826 |
"""Print a list of (matching) domains/alias domains.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
827 |
if matching: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
828 |
title = _(u'Matching domains') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
829 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
830 |
title = _(u'Available domains') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
831 |
w_std(title, '-' * len(title)) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
832 |
if domains: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
833 |
for did in dids: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
834 |
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
|
835 |
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
|
836 |
if len(domains[did]) > 1: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
837 |
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
|
838 |
else: |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
839 |
w_std(_('\tNone')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
840 |
print |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
841 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
842 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
843 |
def _print_aliasdomain_info(info): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
844 |
"""Print alias domain information.""" |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
845 |
title = _(u'Alias domain information') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
846 |
for key in ('alias', 'domain'): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
847 |
if info[key].startswith('xn--'): |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
848 |
info[key] = u'%s (%s)' % (info[key], info[key].decode('idna')) |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
849 |
w_std(title, '-' * len(title), |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
850 |
_('\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
|
851 |
info, '') |
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
852 |
|
4515afec62e5
vmm: Renamed to VirtualMailManager/cli/main.py. Splitted subcommands
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
853 |
del _ |