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