vmm
author Pascal Volk <neverseen@users.sourceforge.net>
Fri, 12 Feb 2010 04:15:18 +0000
branchv0.6.x
changeset 201 dbb0f7ed7858
parent 188 cf1b5f22dbd2
child 232 3c766114d0b9
permissions -rwxr-xr-x
VMM/Config: LazyConfigOption.__init__() cast 'default' to 'cls'. If the default value is not None, make sure it has the proper type.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
#!/usr/bin/env python
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     2
# -*- coding: UTF-8 -*-
162
0ac9ef587769 Updated copyright notices to include the year 2010.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 157
diff changeset
     3
# Copyright 2007 - 2010, Pascal Volk
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     4
# See COPYING for distribution information.
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     5
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     6
"""This is the vmm main script."""
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     7
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
     8
from time import strftime, strptime
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     9
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 137
diff changeset
    10
from VirtualMailManager import *
185
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 183
diff changeset
    11
from VirtualMailManager.cli import w_std, w_err
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 183
diff changeset
    12
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 183
diff changeset
    13
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 183
diff changeset
    14
# TODO: FIXME
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    15
from VirtualMailManager.VirtualMailManager import VirtualMailManager
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    16
import VirtualMailManager.Exceptions as VMME
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    17
import VirtualMailManager.constants.EXIT as EXIT
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    18
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    19
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    20
def usage(excode=0, errMsg=None):
156
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    21
    # TP: Please adjust translated words like the original text.
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    22
    # (It's a table header.) Extract from usage text:
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    23
    # Usage: vmm SUBCOMMAND OBJECT ARGS*
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    24
    #  short long
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    25
    #  subcommand               object             args (* = optional)
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    26
    #
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    27
    #  da    domainadd          domain.tld         transport*
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    28
    #  di    domaininfo         domain.tld         details*
137
fc09f657082d Don't crash if the date format not only consists of ASCII signs.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 136
diff changeset
    29
    u_head = _(u"""\
22
576a4709a44f * 'vmm.1'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 20
diff changeset
    30
Usage: %s SUBCOMMAND OBJECT ARGS*
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    31
  short long
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    32
  subcommand               object             args (* = optional)\n""")\
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    33
          % __prog__
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    34
137
fc09f657082d Don't crash if the date format not only consists of ASCII signs.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 136
diff changeset
    35
    u_body = u"""\
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    36
  da    domainadd          domain.tld         transport*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    37
  di    domaininfo         domain.tld         details*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    38
  dt    domaintransport    domain.tld         transport force*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    39
  dd    domaindelete       domain.tld         delalias*|deluser*|delall*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    40
  ada   aliasdomainadd     aliasdomain.tld    domain.tld
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
    41
  adi   aliasdomaininfo    aliasdomain.tld
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    42
  ads   aliasdomainswitch  aliasdomain.tld    domain.tld
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
    43
  add   aliasdomaindelete  aliasdomain.tld
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    44
  ua    useradd            user@domain.tld    password*
90
1734eb5101c6 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 80
diff changeset
    45
  ui    userinfo           user@domain.tld    details*
155
eb866ebb9f2e Fixed some grammar errors and typos. (Reported by Clytie Siddall)
Pascal Volk <neverseen@users.sourceforge.net>
parents: 149
diff changeset
    46
  un    username           user@domain.tld    "user’s name"
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    47
  up    userpassword       user@domain.tld    password*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    48
  ut    usertransport      user@domain.tld    transport
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    49
  u0    userdisable        user@domain.tld    service*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    50
  u1    userenable         user@domain.tld    service*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    51
  ud    userdelete         user@domain.tld    delalias*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    52
  aa    aliasadd           alias@domain.tld   user@domain.tld
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    53
  ai    aliasinfo          alias@domain.tld
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    54
  ad    aliasdelete        alias@domain.tld   user@domain.tld*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    55
  ra    relocatedadd       exaddr@domain.tld  user@domain.tld
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    56
  ri    relocatedinfo      exaddr@domain.tld
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    57
  rf    relocateddelete    exaddr@domain.tld
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    58
  gu    getuser            userid
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    59
  ld    listdomains                           pattern*
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
    60
  cf    configure                             section*
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    61
  h     help
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    62
  v     version
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    63
"""
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    64
    if excode > 0:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    65
        if errMsg is None:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    66
            w_err(excode, u_head, u_body)
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    67
        else:
156
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    68
            w_err(excode, u_head, u_body, _(u'Error: %s\n') % errMsg)
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    69
    else:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    70
        w_std(u_head, u_body)
136
fb61f64e6351 Reorganized imports, eliminated a potential UnicodeEncodeError.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 133
diff changeset
    71
        os.sys.exit(excode)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    72
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    73
def get_vmm():
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    74
    try:
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    75
        vmm = VirtualMailManager()
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    76
        return vmm
2
9b39f828aa8a * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 1
diff changeset
    77
    except (VMME.VMMException, VMME.VMMNotRootException, VMME.VMMPermException,
9b39f828aa8a * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 1
diff changeset
    78
            VMME.VMMConfigException), e:
156
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
    79
        w_err(e.code(), _(u'Error: %s\n') % e.msg())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    80
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
    81
def _getOrder():
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
    82
    order = ()
174
974bafa59330 VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
    83
    if vmm.cfgDget('misc.dovecot_version') > 11:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    84
        sieve_name = u'sieve'
115
21f264a88ab2 Added sieve/managesieve switching stuff,
Pascal Volk <neverseen@users.sourceforge.net>
parents: 113
diff changeset
    85
    else:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    86
        sieve_name = u'managesieve'
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
    87
    if argv[1] in (u'di', u'domaininfo'):
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    88
        order = ((u'domainname', 0), (u'gid', 1), (u'transport', 0),
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    89
                (u'domaindir', 0), (u'aliasdomains', 0), (u'accounts', 0),
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    90
                (u'aliases', 0), (u'relocated', 0))
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
    91
    elif argv[1] in (u'ui', u'userinfo'):
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
    92
        if argc == 4 and argv[3] != u'aliases'\
174
974bafa59330 VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 168
diff changeset
    93
        or vmm.cfgDget('account.disk_usage'):
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    94
            order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    95
                    (u'transport', 0), (u'maildir', 0), (u'disk usage', 0),
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    96
                    (u'smtp', 1), (u'pop3', 1), (u'imap', 1), (sieve_name, 1))
40
ab0748a5da9a * 'vmm'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 39
diff changeset
    97
        else:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    98
            order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
    99
                    (u'transport', 0), (u'maildir', 0), (u'smtp', 1),
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   100
                    (u'pop3', 1), (u'imap', 1), (sieve_name, 1))
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   101
    elif argv[1] in (u'gu', u'getuser'):
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   102
        order = ((u'uid', 1), (u'gid', 1), (u'address', 0))
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   103
    return order
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   104
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   105
def _printInfo(info, title):
156
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
   106
    # TP: e.g. 'Domain information' or 'Account information'
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   107
    msg = u'%s %s' % (title, _(u'information'))
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   108
    w_std (u'%s\n%s' % (msg, u'-'*len(msg)))
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   109
    for k,u in _getOrder():
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   110
        if u:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   111
            w_std(u'\t%s: %s' % (k.upper().ljust(15, u'.'), info[k]))
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   112
        else:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   113
            w_std(u'\t%s: %s' % (k.title().ljust(15, u'.'), info[k]))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   114
    print
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   115
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   116
def _printList(alist, title):
156
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
   117
    # TP: e.g. 'Available alias addresses' or 'Available accounts'
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   118
    msg = u'%s %s' % (_(u'Available'), title)
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   119
    w_std(u'%s\n%s' % (msg, u'-'*len(msg)))
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   120
    if len(alist) > 0:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   121
        if title != _(u'alias domains'):
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   122
            for val in alist:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   123
                w_std(u'\t%s' % val)
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   124
        else:
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   125
            for dom in alist:
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   126
                if not dom.startswith('xn--'):
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   127
                    w_std(u'\t%s' % dom)
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   128
                else:
185
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 183
diff changeset
   129
                    w_std(u'\t%s (%s)' % (dom, ace2idna(dom)))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   130
    else:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   131
        w_std(_(u'\tNone'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   132
    print
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   133
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   134
def _printAliases(alias, targets):
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   135
    msg = _(u'Alias information')
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   136
    w_std(u'%s\n%s' % (msg, u'-'*len(msg)))
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   137
    w_std(_(u'\tMail for %s will be redirected to:') % alias)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   138
    if len(targets) > 0:
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   139
        for target in targets:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   140
            w_std(u'\t     * %s' % target)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   141
    else:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   142
        w_std(_(u'\tNone'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   143
    print
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   144
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   145
def _printRelocated(addr_dest):
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   146
    msg = _(u'Relocated information')
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   147
    w_std(u'%s\n%s' % (msg, u'-'*len(msg)))
133
2d5c4745efec Replaced angle quotes by quotation marks.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 115
diff changeset
   148
    w_std(_(u'\tUser “%(addr)s” has moved to “%(dest)s”') % addr_dest)
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   149
    print
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   150
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   151
def _formatDom(domain, main=True):
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   152
    if domain.startswith('xn--'):
185
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 183
diff changeset
   153
        domain = u'%s (%s)' % (domain, ace2idna(domain))
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   154
    if main:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   155
        return u'\t[+] %s' %  domain
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   156
    else:
142
28f26f7f3d8f Reduced the mixing/concatenating of str and unicode objects.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 138
diff changeset
   157
        return u'\t[-]     %s' % domain
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   158
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   159
def _printDomList(dids, domains):
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   160
    if argc < 3:
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   161
        msg = _('Available domains')
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   162
    else:
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   163
        msg = _('Matching domains')
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   164
    w_std('%s\n%s' % (msg, '-'*len(msg)))
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   165
    if not len(domains):
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   166
        w_std(_('\tNone'))
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   167
    else:
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   168
        for id in dids:
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   169
            if domains[id][0] is not None:
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   170
                w_std(_formatDom(domains[id][0]))
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   171
            if len(domains[id]) > 1:
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   172
                for alias in domains[id][1:]:
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   173
                    w_std(_formatDom(alias, main=False))
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   174
    print
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   175
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   176
def _printAliasDomInfo(info):
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   177
    msg = _('Alias domain information')
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   178
    for k in ['alias', 'domain']:
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   179
        if info[k].startswith('xn--'):
185
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 183
diff changeset
   180
            info[k] = "%s (%s)" % (info[k], ace2idna(info[k]))
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   181
    w_std('%s\n%s' % (msg, '-'*len(msg)))
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   182
    w_std(
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   183
        _('\tThe alias domain %(alias)s belongs to:\n\t    * %(domain)s')%info)
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   184
    print
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   185
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   186
def configure():
180
f8279c90e99c VMM/Config: dropped option config.done
Pascal Volk <neverseen@users.sourceforge.net>
parents: 175
diff changeset
   187
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   188
        vmm.configure()
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   189
    else:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   190
        vmm.configure(argv[2])
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   191
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   192
def domain_add():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   193
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   194
        usage(EXIT.MISSING_ARGS, _(u'Missing domain name.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   195
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   196
        vmm.domainAdd(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   197
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   198
        vmm.domainAdd(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   199
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   200
def domain_delete():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   201
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   202
        usage(EXIT.MISSING_ARGS, _(u'Missing domain name.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   203
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   204
        vmm.domainDelete(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   205
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   206
        vmm.domainDelete(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   207
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   208
def domain_info():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   209
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   210
        usage(EXIT.MISSING_ARGS, _(u'Missing domain name.'))
149
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   211
    try:
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   212
        if argc < 4:
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   213
            _printInfo(vmm.domainInfo(argv[2].lower()), _(u'Domain'))
62
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   214
        else:
149
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   215
            details = argv[3].lower()
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   216
            infos = vmm.domainInfo(argv[2].lower(), details)
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   217
            _printInfo(infos[0], _(u'Domain'))
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   218
            if details == u'accounts':
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   219
                _printList(infos[1], _(u'accounts'))
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   220
            elif details == u'aliasdomains':
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   221
                _printList(infos[1], _(u'alias domains'))
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   222
            elif details == u'aliases':
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   223
                _printList(infos[1], _(u'aliases'))
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   224
            elif details == u'relocated':
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   225
                _printList(infos[1], _(u'relocated users'))
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   226
            else:
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   227
                _printList(infos[1], _(u'alias domains'))
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   228
                _printList(infos[2], _(u'accounts'))
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   229
                _printList(infos[3], _(u'aliases'))
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   230
                _printList(infos[4], _(u'relocated users'))
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   231
    except VMME.VMMDomainException, e:
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   232
        if e.code() is ERR.DOMAIN_ALIAS_EXISTS:
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   233
            w_std(plan_a_b % {'subcommand': u'aliasdomaininfo',
157
eb3ccf9484b3 vmm: plan_a_b s/address/object/
Pascal Volk <neverseen@users.sourceforge.net>
parents: 156
diff changeset
   234
                'object': argv[2].lower()})
149
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   235
            alias_domain_info()
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   236
        else:
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   237
            raise e
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   238
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   239
def domain_transport():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   240
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   241
        usage(EXIT.MISSING_ARGS, _(u'Missing domain name and new transport.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   242
    if argc < 4:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   243
        usage(EXIT.MISSING_ARGS, _(u'Missing new transport.'))
18
c98e08791ee8 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 17
diff changeset
   244
    elif argc < 5:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   245
        vmm.domainTransport(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   246
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   247
        vmm.domainTransport(argv[2].lower(), argv[3], argv[4])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   248
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   249
def alias_domain_add():
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   250
    if argc < 3:
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   251
        usage(EXIT.MISSING_ARGS,
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   252
                _(u'Missing alias domain name and target domain name.'))
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   253
    elif argc < 4:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   254
        usage(EXIT.MISSING_ARGS, _(u'Missing target domain name.'))
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   255
    else:
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   256
        vmm.aliasDomainAdd(argv[2].lower(), argv[3].lower())
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   257
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   258
def alias_domain_info():
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   259
    if argc < 3:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   260
        usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
149
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   261
    try:
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   262
        _printAliasDomInfo(vmm.aliasDomainInfo(argv[2].lower()))
149
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   263
    except VMME.VMMAliasDomainException, e:
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   264
        if e.code() is ERR.ALIASDOMAIN_ISDOMAIN:
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   265
            w_std(plan_a_b % {'subcommand': u'domaininfo',
157
eb3ccf9484b3 vmm: plan_a_b s/address/object/
Pascal Volk <neverseen@users.sourceforge.net>
parents: 156
diff changeset
   266
                'object': argv[2].lower()})
149
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   267
            argv[1] = u'di' # necessary manipulation to get the order
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   268
            domain_info()
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   269
        else:
581a5680d0ef Improved error handling in vmm's {alias}domaininfo.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 147
diff changeset
   270
            raise e
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   271
78
8f1e501b1bb1 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 76
diff changeset
   272
def alias_domain_switch():
8f1e501b1bb1 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 76
diff changeset
   273
    if argc < 3:
8f1e501b1bb1 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 76
diff changeset
   274
        usage(EXIT.MISSING_ARGS,
8f1e501b1bb1 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 76
diff changeset
   275
                _(u'Missing alias domain name and target domain name.'))
8f1e501b1bb1 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 76
diff changeset
   276
    elif argc < 4:
8f1e501b1bb1 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 76
diff changeset
   277
        usage(EXIT.MISSING_ARGS, _(u'Missing target domain name.'))
8f1e501b1bb1 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 76
diff changeset
   278
    else:
8f1e501b1bb1 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 76
diff changeset
   279
        vmm.aliasDomainSwitch(argv[2].lower(), argv[3].lower())
8f1e501b1bb1 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 76
diff changeset
   280
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   281
def alias_domain_delete():
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   282
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   283
        usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   284
    else:
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   285
        vmm.aliasDomainDelete(argv[2].lower())
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   286
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   287
def user_add():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   288
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   289
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   290
    elif argc < 4:
38
c44ea4526546 * 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 35
diff changeset
   291
        password = None
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   292
    else:
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   293
        password = argv[3]
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   294
    vmm.userAdd(argv[2].lower(), password)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   295
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   296
def user_delete():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   297
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   298
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
66
995d538a6eb5 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 64
diff changeset
   299
    elif argc < 4:
995d538a6eb5 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 64
diff changeset
   300
        vmm.userDelete(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   301
    else:
66
995d538a6eb5 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 64
diff changeset
   302
        vmm.userDelete(argv[2].lower(), argv[3].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   303
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   304
def user_info():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   305
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   306
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   307
    try:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   308
        if argc < 4:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   309
            _printInfo(vmm.userInfo(argv[2].lower()), u'Account')
90
1734eb5101c6 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 80
diff changeset
   310
        else:
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   311
            arg3 = argv[3].lower()
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   312
            info = vmm.userInfo(argv[2].lower(), arg3)
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   313
            if arg3 in ['aliases', 'full']:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   314
                _printInfo(info[0], u'Account')
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   315
                _printList(info[1], _(u'alias addresses'))
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   316
            else:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   317
                _printInfo(info, u'Account')
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   318
    except VMME.VMMAccountException, e:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   319
        if e.code() is ERR.ALIAS_EXISTS:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   320
            w_std(plan_a_b % {'subcommand': u'aliasinfo',
157
eb3ccf9484b3 vmm: plan_a_b s/address/object/
Pascal Volk <neverseen@users.sourceforge.net>
parents: 156
diff changeset
   321
                'object': argv[2].lower()})
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   322
            alias_info()
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   323
        elif e.code() is ERR.RELOCATED_EXISTS:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   324
            w_std(plan_a_b % {'subcommand': u'relocatedinfo',
157
eb3ccf9484b3 vmm: plan_a_b s/address/object/
Pascal Volk <neverseen@users.sourceforge.net>
parents: 156
diff changeset
   325
                'object': argv[2].lower()})
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   326
            relocated_info()
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   327
        else:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   328
            raise e
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   329
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   330
def user_name():
2
9b39f828aa8a * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 1
diff changeset
   331
    if argc < 3:
155
eb866ebb9f2e Fixed some grammar errors and typos. (Reported by Clytie Siddall)
Pascal Volk <neverseen@users.sourceforge.net>
parents: 149
diff changeset
   332
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address and user’s name.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   333
    if argc < 4:
155
eb866ebb9f2e Fixed some grammar errors and typos. (Reported by Clytie Siddall)
Pascal Volk <neverseen@users.sourceforge.net>
parents: 149
diff changeset
   334
        usage(EXIT.MISSING_ARGS, _(u'Missing user’s name.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   335
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   336
        vmm.userName(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   337
17
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   338
def user_transport():
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   339
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   340
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address and transport.'))
17
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   341
    if argc <4:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   342
        usage(EXIT.MISSING_ARGS, _(u'Missing transport.'))
17
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   343
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   344
        vmm.userTransport(argv[2].lower(), argv[3])
17
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   345
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   346
def user_enable():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   347
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   348
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
20
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 19
diff changeset
   349
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   350
        vmm.userEnable(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   351
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   352
        vmm.userEnable(argv[2].lower(), argv[3].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   353
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   354
def user_disable():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   355
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   356
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
20
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 19
diff changeset
   357
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   358
        vmm.userDisable(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   359
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   360
        vmm.userDisable(argv[2].lower(), argv[3].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   361
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   362
def user_password():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   363
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   364
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   365
    elif argc < 4:
38
c44ea4526546 * 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 35
diff changeset
   366
        password = None
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   367
    else:
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   368
        password = argv[3]
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   369
    vmm.userPassword(argv[2].lower(), password)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   370
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   371
def alias_add():
76
14c0a092d7d2 * 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 73
diff changeset
   372
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   373
        usage(EXIT.MISSING_ARGS, _(u'Missing alias address and destination.'))
76
14c0a092d7d2 * 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 73
diff changeset
   374
    elif argc < 4:
14c0a092d7d2 * 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 73
diff changeset
   375
        usage(EXIT.MISSING_ARGS, _(u'Missing destination address.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   376
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   377
        vmm.aliasAdd(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   378
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   379
def alias_info():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   380
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   381
        usage(EXIT.MISSING_ARGS, _(u'Missing alias address'))
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   382
    try:
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   383
        _printAliases(argv[2].lower(), vmm.aliasInfo(argv[2].lower()))
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   384
    except VMME.VMMAliasException, e:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   385
        if e.code() is ERR.ACCOUNT_EXISTS:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   386
            w_std(plan_a_b % {'subcommand': u'userinfo',
157
eb3ccf9484b3 vmm: plan_a_b s/address/object/
Pascal Volk <neverseen@users.sourceforge.net>
parents: 156
diff changeset
   387
                'object': argv[2].lower()})
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   388
            argv[1] = u'ui' # necessary manipulation to get the order
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   389
            user_info()
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   390
        elif e.code() is ERR.RELOCATED_EXISTS:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   391
            w_std(plan_a_b % {'subcommand': u'relocatedinfo',
157
eb3ccf9484b3 vmm: plan_a_b s/address/object/
Pascal Volk <neverseen@users.sourceforge.net>
parents: 156
diff changeset
   392
                'object': argv[2].lower()})
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   393
            relocated_info()
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   394
        else:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   395
            raise e
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   396
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   397
def alias_delete():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   398
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   399
        usage(EXIT.MISSING_ARGS, _(u'Missing alias address'))
12
44161dbb1518 * 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 5
diff changeset
   400
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   401
        vmm.aliasDelete(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   402
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   403
        vmm.aliasDelete(argv[2].lower(), argv[3].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   404
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   405
def relocated_add():
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   406
    if argc < 3:
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   407
        usage(EXIT.MISSING_ARGS,
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   408
                _(u'Missing relocated address and destination.'))
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   409
    elif argc < 4:
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   410
        usage(EXIT.MISSING_ARGS, _(u'Missing destination address.'))
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   411
    else:
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   412
        vmm.relocatedAdd(argv[2].lower(), argv[3])
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   413
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   414
def relocated_info():
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   415
    if argc < 3:
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   416
        usage(EXIT.MISSING_ARGS, _(u'Missing relocated address'))
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   417
    relocated = argv[2].lower()
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   418
    try:
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   419
        _printRelocated({'addr': relocated,
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   420
            'dest': vmm.relocatedInfo(relocated)})
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   421
    except VMME.VMMRelocatedException, e:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   422
        if e.code() is ERR.ACCOUNT_EXISTS:
157
eb3ccf9484b3 vmm: plan_a_b s/address/object/
Pascal Volk <neverseen@users.sourceforge.net>
parents: 156
diff changeset
   423
            w_std(plan_a_b % {'subcommand': u'userinfo', 'object': relocated})
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   424
            argv[1] = u'ui' # necessary manipulation to get the order
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   425
            user_info()
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   426
        elif e.code() is ERR.ALIAS_EXISTS:
157
eb3ccf9484b3 vmm: plan_a_b s/address/object/
Pascal Volk <neverseen@users.sourceforge.net>
parents: 156
diff changeset
   427
            w_std(plan_a_b % {'subcommand': u'aliasinfo', 'object': relocated})
147
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   428
            alias_info()
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   429
        else:
e3fd0b67ae50 Improved error handling in vmm's {user,alias,relocated}info.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 142
diff changeset
   430
            raise e
80
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   431
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   432
def relocated_delete():
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   433
    if argc < 3:
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   434
        usage(EXIT.MISSING_ARGS, _(u'Missing relocated address'))
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   435
    else:
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   436
        vmm.relocatedDelete(argv[2].lower())
5dedc673524e * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 78
diff changeset
   437
19
bf9a03c476fc * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 18
diff changeset
   438
def user_byID():
bf9a03c476fc * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 18
diff changeset
   439
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   440
        usage(EXIT.MISSING_ARGS, _(u'Missing userid'))
19
bf9a03c476fc * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 18
diff changeset
   441
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   442
        _printInfo(vmm.userByID(argv[2]), u'Account')
19
bf9a03c476fc * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 18
diff changeset
   443
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   444
def domain_list():
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   445
    if argc < 3:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   446
        order, doms = vmm.domainList()
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   447
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   448
        order, doms = vmm.domainList(argv[2].lower())
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   449
    _printDomList(order, doms)
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   450
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   451
def show_warnings():
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   452
    if vmm.hasWarnings():
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   453
        w_std(_(u'Warnings:'))
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   454
        for warning in vmm.getWarnings():
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   455
            w_std( " * %s" % warning)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   456
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   457
def show_version():
102
485d3f7d6981 Removed svn keywords, more POSIX compliant shell scripts
Pascal Volk <neverseen@users.sourceforge.net>
parents: 95
diff changeset
   458
    w_std('%s, %s %s (%s %s)\nPython %s %s %s\n\n%s %s' % (__prog__,
156
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
   459
    # TP: The words 'from', 'version' and 'on' are used in the version
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
   460
    # information:
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
   461
    # vmm, version 0.5.2 (from 09/09/09)
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
   462
    # Python 2.5.4 on FreeBSD
137
fc09f657082d Don't crash if the date format not only consists of ASCII signs.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 136
diff changeset
   463
        _(u'version'), __version__, _(u'from'),
fc09f657082d Don't crash if the date format not only consists of ASCII signs.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 136
diff changeset
   464
        strftime(locale.nl_langinfo(locale.D_FMT),
fc09f657082d Don't crash if the date format not only consists of ASCII signs.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 136
diff changeset
   465
            strptime(__date__, '%Y-%m-%d')).decode(ENCODING, 'replace'),
136
fb61f64e6351 Reorganized imports, eliminated a potential UnicodeEncodeError.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 133
diff changeset
   466
        os.sys.version.split()[0], _(u'on'), os.uname()[0], __prog__,
156
a849843115e9 Added comments for the Translation Project. Updated PO template.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 155
diff changeset
   467
        _(u'is free software and comes with ABSOLUTELY NO WARRANTY.')))
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   468
183
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   469
def main():
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   470
    subcommand = os.sys.argv[1]
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   471
    known_subcommand = False
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   472
    try:
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   473
        for s, l, f in subcmd_func.__iter__():
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   474
            if subcommand in (s, l):
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   475
                known_subcommand = True
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   476
                f()
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   477
        if not known_subcommand:
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   478
            usage(EXIT.UNKNOWN_COMMAND, _(u'Unknown subcommand: “%s”')% argv[1])
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   479
        show_warnings()
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   480
    except (EOFError, KeyboardInterrupt):
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   481
        # TP: We have to cry, because root has killed/interrupted vmm
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   482
        # with Ctrl+C or Ctrl+D.
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   483
        w_err(EXIT.USER_INTERRUPT, _(u'\nOuch!\n'))
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   484
    except (VMME.VMMConfigException, VMME.VMMException), e:
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   485
        if e.code() != ERR.DATABASE_ERROR:
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   486
            w_err(e.code(), _(u'Error: %s') % e.msg())
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   487
        else:
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   488
            w_err(e.code(), unicode(e.msg(), ENCODING, 'replace'))
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   489
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   490
if __name__ == '__main__':
136
fb61f64e6351 Reorganized imports, eliminated a potential UnicodeEncodeError.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 133
diff changeset
   491
    __prog__ = os.path.basename(os.sys.argv[0])
fb61f64e6351 Reorganized imports, eliminated a potential UnicodeEncodeError.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 133
diff changeset
   492
    argv = [unicode(arg, ENCODING) for arg in os.sys.argv]
fb61f64e6351 Reorganized imports, eliminated a potential UnicodeEncodeError.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 133
diff changeset
   493
    argc = len(os.sys.argv)
157
eb3ccf9484b3 vmm: plan_a_b s/address/object/
Pascal Volk <neverseen@users.sourceforge.net>
parents: 156
diff changeset
   494
    plan_a_b =_(u'Plan A failed ... trying Plan B: %(subcommand)s %(object)s')
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   495
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   496
    if argc < 2:
39
8dcf739fc97e * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 38
diff changeset
   497
        usage(EXIT.MISSING_ARGS)
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   498
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   499
    vmm = get_vmm()
183
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   500
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   501
    subcmd_func = (
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   502
        #short  long                 function
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   503
        ('da',  'domainadd',         domain_add),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   504
        ('di',  'domaininfo',        domain_info),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   505
        ('dt',  'domaintransport',   domain_transport),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   506
        ('dd',  'domaindelete',      domain_delete),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   507
        ('ada', 'aliasdomainadd',    alias_domain_add),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   508
        ('adi', 'aliasdomaininfo',   alias_domain_info),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   509
        ('ads', 'aliasdomainswitch', alias_domain_switch),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   510
        ('add', 'aliasdomaindelete', alias_domain_delete),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   511
        ('ua',  'useradd',           user_add),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   512
        ('ui',  'userinfo',          user_info),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   513
        ('un',  'username',          user_name),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   514
        ('up',  'userpassword',      user_password),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   515
        ('ut',  'usertransport',     user_transport),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   516
        ('u0',  'userdisable',       user_disable),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   517
        ('u1',  'userenable',        user_enable),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   518
        ('ud',  'userdelete',        user_delete),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   519
        ('aa',  'aliasadd',          alias_add),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   520
        ('ai',  'aliasinfo',         alias_info),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   521
        ('ad',  'aliasdelete',       alias_delete),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   522
        ('ra',  'relocatedadd',      relocated_add),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   523
        ('ri',  'relocatedinfo',     relocated_info),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   524
        ('rd',  'relocateddelete',   relocated_delete),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   525
        ('cf',  'configure',         configure),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   526
        ('gu',  'getuser',           user_byID),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   527
        ('ld',  'listdomains',       domain_list),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   528
        ('h',   'help',              usage),
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   529
        ('v',   'version',           show_version),)
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   530
eb4c73d9d0a4 vmm: reworked subcommand/arguments mapping.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 180
diff changeset
   531
    main()