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