vmm
author Pascal Volk <neverseen@users.sourceforge.net>
Fri, 29 Aug 2008 03:28:25 +0000
changeset 70 a3663ad491bf
parent 66 995d538a6eb5
child 73 11da3d9298b4
permissions -rwxr-xr-x
* 'VirtualMailManager/VirtualMailManager.py' - Fixed DIGEST-MD5 hash generation.
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 -*-
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     3
# Copyright 2007-2008 VEB IT
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
# $Id$
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     6
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     7
"""This is the vmm main script."""
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     8
4
f3c30b7421b9 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 3
diff changeset
     9
from VirtualMailManager.constants.VERSION import VERSION
f3c30b7421b9 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 3
diff changeset
    10
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    11
__author__ = 'Pascal Volk <p.volk@veb-it.de>'
4
f3c30b7421b9 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 3
diff changeset
    12
__version__ = VERSION
f3c30b7421b9 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 3
diff changeset
    13
__revision__ = 'rev '+'$Rev$'.split()[1]
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    14
__date__ = '$Date$'.split()[1]
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    15
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    16
import locale
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    17
import os
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    18
import sys
32
ceb700bc4a80 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 26
diff changeset
    19
import gettext
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    20
from time import strftime, strptime
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    21
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    22
from VirtualMailManager.VirtualMailManager import VirtualMailManager
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    23
import VirtualMailManager.Exceptions as VMME
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    24
import VirtualMailManager.constants.EXIT as EXIT
32
ceb700bc4a80 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 26
diff changeset
    25
import VirtualMailManager.constants.ERROR as ERR
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    26
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    27
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    28
def w_err(code, *args):
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    29
    for arg in args:
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    30
        sys.stderr.write(arg.encode(ENCODING, 'replace'))
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    31
        sys.stderr.write('\n')
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    32
    sys.exit(code)
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    33
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    34
def w_std(*args):
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    35
    for arg in args:
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    36
        sys.stdout.write(arg.encode(ENCODING, 'replace'))
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    37
        sys.stdout.write('\n')
32
ceb700bc4a80 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 26
diff changeset
    38
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    39
def usage(excode=0, errMsg=None):
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    40
    u_head = _("""\
22
576a4709a44f * 'vmm.1'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 20
diff changeset
    41
Usage: %s SUBCOMMAND OBJECT ARGS*
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    42
  short long
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    43
  subcommand               object            args (* = optional)\n""")\
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    44
          % __prog__
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    45
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    46
    u_body = """\
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    47
  da    domainadd          domain.tld        transport*
64
432a037658a8 * 'vmm'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 63
diff changeset
    48
  di    domaininfo         domain.tld        details*
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    49
  dt    domaintransport    domain.tld        transport force*
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    50
  dd    domaindelete       domain.tld        delalias*|deluser*|delall*
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
    51
  ada   aliasdomainadd     aliasdomain.tld   domain.tld
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
    52
  adi   aliasdomaininfo    aliasdomain.tld
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
    53
  add   aliasdomaindelete  aliasdomain.tld
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    54
  ua    useradd            user@domain.tld   password*
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    55
  ui    userinfo           user@domain.tld   du*
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    56
  un    username           user@domain.tld   'Users Name'
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    57
  up    userpassword       user@domain.tld   password*
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    58
  ut    usertransport      user@domain.tld   transport
64
432a037658a8 * 'vmm'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 63
diff changeset
    59
  u0    userdisable        user@domain.tld   service*
432a037658a8 * 'vmm'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 63
diff changeset
    60
  u1    userenable         user@domain.tld   service*
66
995d538a6eb5 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 64
diff changeset
    61
  ud    userdelete         user@domain.tld   delalias*
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    62
  aa    aliasadd           alias@domain.tld  user@domain.tld
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    63
  ai    aliasinfo          alias@domain.tld
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    64
  ad    aliasdelete        alias@domain.tld  user@domain.tld*
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    65
  gu    getuser            userid
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    66
  ld    listdomains                          pattern*
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
    67
  cf    configure                            section*
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    68
  h     help
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    69
  v     version
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    70
"""
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    71
    if excode > 0:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    72
        if errMsg is None:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    73
            w_err(excode, u_head, u_body)
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    74
        else:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    75
            w_err(excode, u_head, u_body, '%s: %s\n' % (_('Error'), errMsg))
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    76
    else:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    77
        w_std(u_head, u_body)
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    78
        sys.exit(excode)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    79
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    80
def get_vmm():
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    81
    try:
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    82
        vmm = VirtualMailManager()
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    83
        return vmm
2
9b39f828aa8a * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 1
diff changeset
    84
    except (VMME.VMMException, VMME.VMMNotRootException, VMME.VMMPermException,
9b39f828aa8a * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 1
diff changeset
    85
            VMME.VMMConfigException), e:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
    86
        w_err(e.code(), "%s: %s\n" % (_('Error'), e.msg()))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    87
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
    88
def _getOrder():
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
    89
    order = ()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    90
    if argv[1] in ['di', 'domaininfo']:
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
    91
        order = (('domainname', 0), ('gid', 1), ('transport', 0),
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
    92
                ('domaindir', 0), ('aliasdomains', 0), ('accounts', 0),
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
    93
                ('aliases', 0))
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
    94
    elif argv[1] in ['ui', 'userinfo']:
40
ab0748a5da9a * 'vmm'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 39
diff changeset
    95
        if argc == 4 or vmm.cfgGetBoolean('maildir', 'diskusage'):
ab0748a5da9a * 'vmm'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 39
diff changeset
    96
            order = (('address', 0), ('name', 0), ('uid', 1), ('gid', 1),
ab0748a5da9a * 'vmm'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 39
diff changeset
    97
                    ('transport', 0), ('maildir', 0), ('disk usage', 0),
ab0748a5da9a * 'vmm'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 39
diff changeset
    98
                    ('smtp', 1), ('pop3', 1), ('imap', 1), ('managesieve', 1))
ab0748a5da9a * 'vmm'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 39
diff changeset
    99
        else:
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   100
            order = (('address', 0), ('name', 0), ('uid', 1), ('gid', 1),
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   101
                    ('transport', 0), ('maildir', 0), ('smtp', 1), ('pop3', 1),
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   102
                    ('imap', 1), ('managesieve', 1))
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   103
    elif argv[1] in ['gu', 'getuser']:
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   104
        order = (('uid', 1), ('gid', 1), ('address', 0))
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   105
    return order
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   106
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   107
def _printInfo(info, title):
32
ceb700bc4a80 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 26
diff changeset
   108
    msg = '%s %s' % (title, _('information'))
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   109
    w_std ('%s\n%s' % (msg, '-'*len(msg)))
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   110
    for k,u in _getOrder():
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   111
        if u:
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   112
            w_std('\t%s: %s' % (k.upper().ljust(15, '.'), info[k]))
26
668951708f2f * 'vmm.cfg.5'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 22
diff changeset
   113
        else:
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   114
            w_std('\t%s: %s' % (k.title().ljust(15, '.'), info[k]))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   115
    print
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   116
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   117
def _printList(alist, title):
32
ceb700bc4a80 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 26
diff changeset
   118
    msg = '%s %s' % (_('Available'), title)
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   119
    w_std('%s\n%s' % (msg, '-'*len(msg)))
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   120
    if len(alist) > 0:
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   121
        if title != _('alias domains'):
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   122
            for val in alist:
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   123
                w_std('\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--'):
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   127
                    w_std('\t%s' % dom)
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   128
                else:
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   129
                    w_std('\t%s (%s)' % (dom, vmm.ace2idna(dom)))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   130
    else:
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   131
        w_std(_('\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):
32
ceb700bc4a80 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 26
diff changeset
   135
    msg = _('Alias information')
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   136
    w_std('%s\n%s' % (msg, '-'*len(msg)))
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   137
    w_std(_('\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:
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   140
            w_std('\t     * %s' % target)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   141
    else:
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   142
        w_std(_('\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
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   145
def _formatDom(domain, main=True):
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   146
    if domain.startswith('xn--'):
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   147
        domain = '%s (%s)' % (domain, vmm.ace2idna(domain))
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   148
    if main:
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   149
        return '\t[+] %s' %  domain
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   150
    else:
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   151
        return '\t[-]     %s' % domain
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   152
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   153
def _printDomList(dids, domains):
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   154
    if argc < 3:
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   155
        msg = _('Available domains')
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   156
    else:
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   157
        msg = _('Matching domains')
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   158
    w_std('%s\n%s' % (msg, '-'*len(msg)))
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   159
    if not len(domains):
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   160
        w_std(_('\tNone'))
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   161
    else:
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   162
        for id in dids:
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   163
            if domains[id][0] is not None:
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   164
                w_std(_formatDom(domains[id][0]))
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   165
            if len(domains[id]) > 1:
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   166
                for alias in domains[id][1:]:
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   167
                    w_std(_formatDom(alias, main=False))
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   168
    print
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   169
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   170
def _printAliasDomInfo(info):
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   171
    msg = _('Alias domain information')
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   172
    for k in ['alias', 'domain']:
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   173
        if info[k].startswith('xn--'):
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   174
            info[k] = "%s (%s)" % (info[k], vmm.ace2idna(info[k]))
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   175
    w_std('%s\n%s' % (msg, '-'*len(msg)))
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   176
    w_std(
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   177
        _('\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
   178
    print
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   179
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   180
def configure():
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   181
    if need_setup or len(argv) < 3:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   182
        vmm.configure()
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   183
    else:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   184
        vmm.configure(argv[2])
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   185
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   186
def domain_add():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   187
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   188
        usage(EXIT.MISSING_ARGS, _(u'Missing domain name.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   189
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   190
        vmm.domainAdd(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   191
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   192
        vmm.domainAdd(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   193
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   194
def domain_delete():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   195
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   196
        usage(EXIT.MISSING_ARGS, _(u'Missing domain name.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   197
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   198
        vmm.domainDelete(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   199
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   200
        vmm.domainDelete(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   201
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   202
def domain_info():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   203
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   204
        usage(EXIT.MISSING_ARGS, _(u'Missing domain name.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   205
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   206
        _printInfo(vmm.domainInfo(argv[2].lower()), _('Domain'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   207
    else:
62
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   208
        details = argv[3].lower()
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   209
        infos = vmm.domainInfo(argv[2].lower(), details)
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   210
        _printInfo(infos[0], _('Domain'))
62
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   211
        if details == 'accounts':
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   212
            _printList(infos[1], _('accounts'))
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   213
        elif details == 'aliasdomains':
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   214
            _printList(infos[1], _('alias domains'))
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   215
        elif details == 'aliases':
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   216
            _printList(infos[1], _('aliases'))
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   217
        else:
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   218
            _printList(infos[1], _('alias domains'))
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   219
            _printList(infos[2], _('accounts'))
869de537a020 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 61
diff changeset
   220
            _printList(infos[3], _('aliases'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   221
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   222
def domain_transport():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   223
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   224
        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
   225
    if argc < 4:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   226
        usage(EXIT.MISSING_ARGS, _(u'Missing new transport.'))
18
c98e08791ee8 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 17
diff changeset
   227
    elif argc < 5:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   228
        vmm.domainTransport(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   229
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   230
        vmm.domainTransport(argv[2].lower(), argv[3], argv[4])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   231
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   232
def alias_domain_add():
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   233
    if argc < 3:
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   234
        usage(EXIT.MISSING_ARGS,
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   235
                _(u'Missing alias domain name and target domain name.'))
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   236
    elif argc < 4:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   237
        usage(EXIT.MISSING_ARGS, _(u'Missing target domain name.'))
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   238
    else:
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   239
        vmm.aliasDomainAdd(argv[2].lower(), argv[3].lower())
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   240
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   241
def alias_domain_info():
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   242
    if argc < 3:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   243
        usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   244
    else:
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   245
        _printAliasDomInfo(vmm.aliasDomainInfo(argv[2].lower()))
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   246
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   247
def alias_domain_delete():
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   248
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   249
        usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   250
    else:
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   251
        vmm.aliasDomainDelete(argv[2].lower())
45
9e66138aad0b * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 44
diff changeset
   252
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   253
def user_add():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   254
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   255
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   256
    elif argc < 4:
38
c44ea4526546 * 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 35
diff changeset
   257
        password = None
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   258
    else:
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   259
        password = argv[3]
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   260
    vmm.userAdd(argv[2].lower(), password)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   261
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   262
def user_delete():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   263
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   264
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
66
995d538a6eb5 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 64
diff changeset
   265
    elif argc < 4:
995d538a6eb5 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 64
diff changeset
   266
        vmm.userDelete(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   267
    else:
66
995d538a6eb5 * 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 64
diff changeset
   268
        vmm.userDelete(argv[2].lower(), argv[3].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   269
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   270
def user_info():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   271
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   272
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   273
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   274
        _printInfo(vmm.userInfo(argv[2].lower()), 'Account')
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   275
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   276
        _printInfo(vmm.userInfo(argv[2].lower(), True), 'Account')
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   277
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   278
def user_name():
2
9b39f828aa8a * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 1
diff changeset
   279
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   280
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address and users name.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   281
    if argc < 4:
32
ceb700bc4a80 * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 26
diff changeset
   282
        usage(EXIT.MISSING_ARGS, _('Missing users name.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   283
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   284
        vmm.userName(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   285
17
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   286
def user_transport():
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   287
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   288
        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
   289
    if argc <4:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   290
        usage(EXIT.MISSING_ARGS, _(u'Missing transport.'))
17
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   291
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   292
        vmm.userTransport(argv[2].lower(), argv[3])
17
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   293
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   294
def user_enable():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   295
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   296
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
20
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 19
diff changeset
   297
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   298
        vmm.userEnable(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   299
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   300
        vmm.userEnable(argv[2].lower(), argv[3].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   301
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   302
def user_disable():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   303
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   304
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
20
55146c78b3fb * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 19
diff changeset
   305
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   306
        vmm.userDisable(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   307
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   308
        vmm.userDisable(argv[2].lower(), argv[3].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   309
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   310
def user_password():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   311
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   312
        usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   313
    elif argc < 4:
38
c44ea4526546 * 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 35
diff changeset
   314
        password = None
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   315
    else:
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   316
        password = argv[3]
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   317
    vmm.userPassword(argv[2].lower(), password)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   318
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   319
def alias_add():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   320
    if argc < 4:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   321
        usage(EXIT.MISSING_ARGS, _(u'Missing alias address and destination.'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   322
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   323
        vmm.aliasAdd(argv[2].lower(), argv[3])
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   324
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   325
def alias_info():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   326
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   327
        usage(EXIT.MISSING_ARGS, _(u'Missing alias address'))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   328
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   329
        _printAliases(argv[2], vmm.aliasInfo(argv[2].lower()))
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   330
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   331
def alias_delete():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   332
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   333
        usage(EXIT.MISSING_ARGS, _(u'Missing alias address'))
12
44161dbb1518 * 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 5
diff changeset
   334
    elif argc < 4:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   335
        vmm.aliasDelete(argv[2].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   336
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   337
        vmm.aliasDelete(argv[2].lower(), argv[3].lower())
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   338
19
bf9a03c476fc * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 18
diff changeset
   339
def user_byID():
bf9a03c476fc * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 18
diff changeset
   340
    if argc < 3:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   341
        usage(EXIT.MISSING_ARGS, _(u'Missing userid'))
19
bf9a03c476fc * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 18
diff changeset
   342
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   343
        _printInfo(vmm.userByID(argv[2]), u'Account')
19
bf9a03c476fc * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 18
diff changeset
   344
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   345
def domain_list():
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   346
    if argc < 3:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   347
        order, doms = vmm.domainList()
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   348
    else:
54
1fc1f82c662f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 53
diff changeset
   349
        order, doms = vmm.domainList(argv[2].lower())
44
c9ab6900ede9 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 40
diff changeset
   350
    _printDomList(order, doms)
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   351
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   352
def show_warnings():
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   353
    if vmm.hasWarnings():
53
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   354
        w_std(_(u'Warnings:'))
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   355
        for warning in vmm.getWarnings():
5b50eb306d37 * 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 49
diff changeset
   356
            w_std( " * %s" % warning)
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   357
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   358
def show_version():
61
d85482575349 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 57
diff changeset
   359
    w_std("%s, %s %s (%s %s %s)\nPython %s %s %s\n" % (__prog__, _('version'),
d85482575349 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 57
diff changeset
   360
        __version__, __revision__, _('from'), strftime(
d85482575349 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 57
diff changeset
   361
            locale.nl_langinfo(locale.D_FMT), strptime(__date__, '%Y-%m-%d')),
63
9b627307f4a8 * 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 62
diff changeset
   362
        sys.version.split()[0], _(u'on'), os.uname()[0]))
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   363
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   364
#def main():
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   365
if __name__ == '__main__':
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   366
    __prog__ = os.path.basename(sys.argv[0])
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   367
    locale.setlocale(locale.LC_ALL, '')
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   368
    ENCODING = locale.nl_langinfo(locale.CODESET)
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   369
    gettext.install(__prog__, '/usr/local/share/locale', unicode=1)
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   370
    argv = [unicode(arg, ENCODING) for arg in sys.argv]
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   371
    argc = len(sys.argv)
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   372
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   373
    if argc < 2:
39
8dcf739fc97e * 'install.sh'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 38
diff changeset
   374
        usage(EXIT.MISSING_ARGS)
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   375
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   376
    vmm = get_vmm()
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   377
    try:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   378
        need_setup = not vmm.setupIsDone()
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   379
        if   argv[1] in ['cf', 'configure'] or need_setup:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   380
            configure()
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   381
        elif argv[1] in ['da', 'domainadd']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   382
            domain_add()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   383
        elif argv[1] in ['di', 'domaininfo']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   384
            domain_info()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   385
        elif argv[1] in ['dt', 'domaintransport']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   386
            domain_transport()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   387
        elif argv[1] in ['dd', 'domaindelete']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   388
            domain_delete()
55
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   389
        elif argv[1] in ['ada', 'aliasdomainadd']:
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   390
            alias_domain_add()
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   391
        elif argv[1] in ['adi', 'aliasdomaininfo']:
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   392
            alias_domain_info()
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   393
        elif argv[1] in ['add', 'aliasdomaindelete']:
15c873f94ba6 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 54
diff changeset
   394
            alias_domain_delete()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   395
        elif argv[1] in ['ua', 'useradd']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   396
            user_add()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   397
        elif argv[1] in ['ui', 'userinfo']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   398
            user_info()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   399
        elif argv[1] in ['un', 'username']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   400
            user_name()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   401
        elif argv[1] in ['up', 'userpassword']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   402
            user_password()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   403
        elif argv[1] in ['ut', 'usertransport']:
17
fe9be0081e5f * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 12
diff changeset
   404
            user_transport()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   405
        elif argv[1] in ['u0', 'userdisable']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   406
            user_disable()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   407
        elif argv[1] in ['u1', 'userenable']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   408
            user_enable()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   409
        elif argv[1] in ['ud', 'userdelete']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   410
            user_delete()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   411
        elif argv[1] in ['aa', 'aliasadd']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   412
            alias_add()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   413
        elif argv[1] in ['ai', 'aliasinfo']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   414
            alias_info()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   415
        elif argv[1] in ['ad', 'aliasdelete']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   416
            alias_delete()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   417
        elif argv[1] in ['gu', 'getuser']:
19
bf9a03c476fc * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 18
diff changeset
   418
            user_byID()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   419
        elif argv[1] in ['ld', 'listdomains']:
35
22cc616aef61 * 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 34
diff changeset
   420
            domain_list()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   421
        elif argv[1] in ['h', 'help']:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   422
            usage()
47
191d5a5adc4a * Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents: 45
diff changeset
   423
        elif argv[1] in ['v', 'version']:
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   424
            show_version()
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   425
        else:
22
576a4709a44f * 'vmm.1'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 20
diff changeset
   426
            usage(EXIT.UNKNOWN_COMMAND,
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   427
                    u"%s: »%s«" % (_('Unknown subcommand'), argv[1]))
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   428
        show_warnings()
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
   429
    except (EOFError, KeyboardInterrupt):
48
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   430
        w_err(EXIT.USER_INTERRUPT, '\n%s!\n' % _(u'Ouch'))
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   431
    except (VMME.VMMConfigException, VMME.VMMException), e:
0d5f58f8b8f5 * 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents: 47
diff changeset
   432
        w_err(e.code(), "%s: %s" % (_(u'Error'), e.msg()))