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