author | Pascal Volk <neverseen@users.sourceforge.net> |
Mon, 21 Apr 2008 04:56:01 +0000 | |
changeset 20 | 55146c78b3fb |
parent 19 | bf9a03c476fc |
child 22 | 576a4709a44f |
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 -*- |
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 | 9 |
from VirtualMailManager.constants.VERSION import VERSION |
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 | 12 |
__version__ = VERSION |
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 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
16 |
import os |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
17 |
import sys |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
18 |
from getpass import getpass |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
19 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
20 |
from VirtualMailManager.VirtualMailManager import VirtualMailManager |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
21 |
from VirtualMailManager.Config import VMMConfig |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
22 |
import VirtualMailManager.Exceptions as VMME |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
23 |
import VirtualMailManager.constants.EXIT as EXIT |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
24 |
|
4 | 25 |
__prog__ = os.path.basename(sys.argv[0]) |
26 |
||
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
27 |
def usage(excode=0, errMsg=None): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
28 |
sys.stderr.write("""\ |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
29 |
Usage: %s COMMAND OBJECT ARGS* |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
30 |
short long |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
31 |
command object args (* = optional) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
32 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
33 |
da domainadd domain.tld transport* |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
34 |
di domaininfo domain.tld detailed* |
18
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
35 |
dt domaintransport domain.tld transport force* |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
36 |
dd domaindelete domain.tld delalias*|deluser*|delall* |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
37 |
ua useradd user@domain.tld password* |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
38 |
ui userinfo user@domain.tld du* |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
39 |
un username user@domain.tld 'Users Name' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
40 |
up userpassword user@domain.tld password* |
18
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
41 |
ut usertransport user@domain.tld transport |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
42 |
u0 userdisable user@domain.tld smtp*|pop3*|imap*|managesieve*|all* |
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
43 |
u1 userenable user@domain.tld smtp*|pop3*|imap*|managesieve*|all* |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
44 |
ud userdelete user@domain.tld |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
45 |
aa aliasadd alias@domain.tld user@domain.tld |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
46 |
ai aliasinfo alias@domain.tld |
12
44161dbb1518
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
5
diff
changeset
|
47 |
ad aliasdelete alias@domain.tld user@domain.tld* |
19
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
48 |
gu getuser userid |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
49 |
cf configure section* |
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 |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
52 |
|
5 | 53 |
""" % __prog__) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
54 |
if not errMsg is None: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
55 |
sys.stderr.write('Error: %s\n' % errMsg) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
56 |
sys.exit(excode) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
57 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
58 |
def getVMM(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
59 |
try: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
60 |
vmm = VirtualMailManager() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
61 |
return vmm |
2
9b39f828aa8a
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
1
diff
changeset
|
62 |
except (VMME.VMMException, VMME.VMMNotRootException, VMME.VMMPermException, |
9b39f828aa8a
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
1
diff
changeset
|
63 |
VMME.VMMConfigException), e: |
9b39f828aa8a
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
1
diff
changeset
|
64 |
sys.stderr.write("\aERROR: %s\n" % e[0][0]) |
9b39f828aa8a
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
1
diff
changeset
|
65 |
sys.exit(e[0][1]) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
66 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
67 |
def configure(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
68 |
try: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
69 |
if len(sys.argv) < 3: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
70 |
vmm.configure() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
71 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
72 |
vmm.configure(sys.argv[2]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
73 |
except (EOFError, KeyboardInterrupt): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
74 |
sys.stderr.write('\nOuch!\n') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
75 |
sys.exit(EXIT.USER_INTERRUPT) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
76 |
except VMME.VMMConfigException, e: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
77 |
sys.stderr.write(str(e)) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
78 |
sys.exit(EXIT.CONF_ERROR) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
79 |
sys.exit(0) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
80 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
81 |
def _readpass(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
82 |
clear0 = '' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
83 |
clear1 = '1' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
84 |
while clear0 != clear1: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
85 |
while len(clear0) < 1: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
86 |
clear0 = getpass(prompt='Enter new password: ') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
87 |
if len(clear0) < 1: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
88 |
sys.stderr.write('Sorry, empty passwords are not permitted\n') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
89 |
clear1 = getpass(prompt='Retype new password: ') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
90 |
if clear0 != clear1: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
91 |
clear0 = '' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
92 |
sys.stderr.write('Sorry, passwords do not match\n') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
93 |
return clear0 |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
94 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
95 |
def _printInfo(info, title): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
96 |
msg = title+' information' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
97 |
print '%s\n%s' % (msg, '-'*len(msg)) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
98 |
for k,v in info.items(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
99 |
print '\t%s: %s' % (k.title().ljust(15, '.'), v) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
100 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
101 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
102 |
def _printUsers(users, title): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
103 |
msg = 'Available '+title |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
104 |
print '%s\n%s' % (msg, '-'*len(msg)) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
105 |
if len(users) > 0: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
106 |
for user in users: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
107 |
print '\t%s' % user |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
108 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
109 |
print '\tNone' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
110 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
111 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
112 |
def _printAliases(alias, targets): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
113 |
msg = 'Alias information' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
114 |
print '%s\n%s' % (msg, '-'*len(msg)) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
115 |
print '\tMail for %s goes to:' % alias |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
116 |
if len(targets) > 0: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
117 |
for target in targets: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
118 |
print '\t -> %s' % target |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
119 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
120 |
print '\tNone' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
121 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
122 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
123 |
def domain_add(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
124 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
125 |
if argc < 3: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
126 |
usage(EXIT.MISSING_ARGS, 'Missing domain name.') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
127 |
elif argc < 4: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
128 |
vmm.domain_add(sys.argv[2].lower()) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
129 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
130 |
vmm.domain_add(sys.argv[2].lower(), sys.argv[3]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
131 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
132 |
def domain_delete(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
133 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
134 |
if argc < 3: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
135 |
usage(EXIT.MISSING_ARGS, 'Missing domain name.') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
136 |
elif argc < 4: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
137 |
vmm.domain_delete(sys.argv[2].lower()) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
138 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
139 |
vmm.domain_delete(sys.argv[2].lower(), sys.argv[3]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
140 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
141 |
def domain_info(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
142 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
143 |
if argc < 3: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
144 |
usage(EXIT.MISSING_ARGS, 'Missing domain name.') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
145 |
elif argc < 4: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
146 |
_printInfo(vmm.domain_info(sys.argv[2].lower()), 'Domain') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
147 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
148 |
infos = vmm.domain_info(sys.argv[2].lower(), sys.argv[3]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
149 |
_printInfo(infos[0], 'Domain') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
150 |
_printUsers(infos[1], 'accounts') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
151 |
_printUsers(infos[2], 'aliases') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
152 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
153 |
def domain_transport(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
154 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
155 |
if argc < 3: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
156 |
usage(EXIT.MISSING_ARGS, 'Missing domain name and new transport.') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
157 |
if argc < 4: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
158 |
usage(EXIT.MISSING_ARGS, 'Missing new transport.') |
18
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
159 |
elif argc < 5: |
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
160 |
vmm.domain_transport(sys.argv[2].lower(), sys.argv[3]) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
161 |
else: |
18
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
162 |
vmm.domain_transport(sys.argv[2].lower(), sys.argv[3], sys.argv[4]) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
163 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
164 |
def user_add(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
165 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
166 |
if argc < 3: |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
167 |
usage(EXIT.MISSING_ARGS, 'Missing e-mail address.') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
168 |
elif argc < 4: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
169 |
password = _readpass() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
170 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
171 |
password = sys.argv[3] |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
172 |
vmm.user_add(sys.argv[2].lower(), password) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
173 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
174 |
def user_delete(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
175 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
176 |
if argc < 3: |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
177 |
usage(EXIT.MISSING_ARGS, 'Missing e-mail address.') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
178 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
179 |
vmm.user_delete(sys.argv[2].lower()) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
180 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
181 |
def user_info(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
182 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
183 |
if argc < 3: |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
184 |
usage(EXIT.MISSING_ARGS, 'Missing e-mail address.') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
185 |
elif argc < 4: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
186 |
_printInfo(vmm.user_info(sys.argv[2].lower()), 'Account') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
187 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
188 |
_printInfo(vmm.user_info(sys.argv[2].lower(), True), 'Account') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
189 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
190 |
def user_name(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
191 |
global argc |
2
9b39f828aa8a
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
1
diff
changeset
|
192 |
if argc < 3: |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
193 |
usage(EXIT.MISSING_ARGS, 'Missing e-mail address and users name.') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
194 |
if argc < 4: |
2
9b39f828aa8a
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
1
diff
changeset
|
195 |
usage(EXIT.MISSING_ARGS, 'Missing users name.') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
196 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
197 |
vmm.user_name(sys.argv[2].lower(), sys.argv[3]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
198 |
|
17
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
199 |
def user_transport(): |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
200 |
global argc |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
201 |
if argc < 3: |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
202 |
usage(EXIT.MISSING_ARGS, 'Missing e-mail address and transport.') |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
203 |
if argc <4: |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
204 |
usage(EXIT.MISSING_ARGS, 'Missing transport.') |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
205 |
else: |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
206 |
vmm.user_transport(sys.argv[2].lower(), sys.argv[3]) |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
207 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
208 |
def user_enable(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
209 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
210 |
if argc < 3: |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
211 |
usage(EXIT.MISSING_ARGS, 'Missing e-mail address.') |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
212 |
elif argc < 4: |
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
213 |
vmm.user_enable(sys.argv[2].lower()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
214 |
else: |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
215 |
vmm.user_enable(sys.argv[2].lower(), sys.argv[3].lower()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
216 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
217 |
def user_disable(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
218 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
219 |
if argc < 3: |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
220 |
usage(EXIT.MISSING_ARGS, 'Missing e-mail address.') |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
221 |
elif argc < 4: |
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
222 |
vmm.user_disable(sys.argv[2].lower()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
223 |
else: |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
224 |
vmm.user_disable(sys.argv[2].lower(), sys.argv[3].lower()) |
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 user_password(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
227 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
228 |
if argc < 3: |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
229 |
usage(EXIT.MISSING_ARGS, 'Missing e-mail address.') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
230 |
elif argc < 4: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
231 |
password = _readpass() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
232 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
233 |
password = sys.argv[3] |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
234 |
vmm.user_password(sys.argv[2].lower(), password) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
235 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
236 |
def alias_add(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
237 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
238 |
if argc < 4: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
239 |
usage(EXIT.MISSING_ARGS, 'Missing alias address and destination.') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
240 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
241 |
vmm.alias_add(sys.argv[2].lower(), sys.argv[3]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
242 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
243 |
def alias_info(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
244 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
245 |
if argc < 3: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
246 |
usage(EXIT.MISSING_ARGS, 'Missing alias address') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
247 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
248 |
_printAliases(sys.argv[2], vmm.alias_info(sys.argv[2].lower())) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
249 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
250 |
def alias_delete(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
251 |
global argc |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
252 |
if argc < 3: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
253 |
usage(EXIT.MISSING_ARGS, 'Missing alias address') |
12
44161dbb1518
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
5
diff
changeset
|
254 |
elif argc < 4: |
44161dbb1518
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
5
diff
changeset
|
255 |
vmm.alias_delete(sys.argv[2].lower()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
256 |
else: |
12
44161dbb1518
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
5
diff
changeset
|
257 |
vmm.alias_delete(sys.argv[2].lower(), sys.argv[3].lower()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
258 |
|
19
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
259 |
def user_byID(): |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
260 |
global argc |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
261 |
if argc < 3: |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
262 |
usage(EXIT.MISSING_ARGS, 'Missing userid') |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
263 |
else: |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
264 |
_printInfo(vmm.user_byID(sys.argv[2]), 'Account') |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
265 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
266 |
def showWarnings(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
267 |
if vmm.hasWarnings(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
268 |
print '\nWarnings:' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
269 |
for w in vmm.getWarnings(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
270 |
print " * ",w |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
271 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
272 |
#def main(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
273 |
if __name__ == '__main__': |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
274 |
argc = len(sys.argv) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
275 |
if argc < 2: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
276 |
usage(EXIT.MISSING_ARGS) # -> exit |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
277 |
vmm = getVMM() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
278 |
try: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
279 |
if sys.argv[1] in ['cf', 'configure'] or not vmm.setupIsDone(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
280 |
configure() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
281 |
except VMME.VMMConfigException, e: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
282 |
sys.stderr.write(str(e)) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
283 |
sys.exit(EXIT.CONF_ERROR) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
284 |
except VMME.VMMException, e: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
285 |
sys.stderr.write("\aERROR: %s\n" % e[0][0]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
286 |
sys.exit(e[0][1]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
287 |
try: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
288 |
if sys.argv[1] in ['da', 'domainadd']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
289 |
domain_add() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
290 |
elif sys.argv[1] in ['di', 'domaininfo']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
291 |
domain_info() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
292 |
elif sys.argv[1] in ['dt', 'domaintransport']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
293 |
domain_transport() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
294 |
elif sys.argv[1] in ['dd', 'domaindelete']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
295 |
domain_delete() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
296 |
elif sys.argv[1] in ['ua', 'useradd']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
297 |
user_add() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
298 |
elif sys.argv[1] in ['ui', 'userinfo']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
299 |
user_info() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
300 |
elif sys.argv[1] in ['un', 'username']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
301 |
user_name() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
302 |
elif sys.argv[1] in ['up', 'userpassword']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
303 |
user_password() |
17
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
304 |
elif sys.argv[1] in ['ut', 'usertransport']: |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
305 |
user_transport() |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
306 |
elif sys.argv[1] in ['u0', 'userdisable']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
307 |
user_disable() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
308 |
elif sys.argv[1] in ['u1', 'userenable']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
309 |
user_enable() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
310 |
elif sys.argv[1] in ['ud', 'userdelete']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
311 |
user_delete() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
312 |
elif sys.argv[1] in ['aa', 'aliasadd']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
313 |
alias_add() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
314 |
elif sys.argv[1] in ['ai', 'aliasinfo']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
315 |
alias_info() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
316 |
elif sys.argv[1] in ['ad', 'aliasdelete']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
317 |
alias_delete() |
19
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
318 |
elif sys.argv[1] in ['gu', 'getuser']: |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
319 |
user_byID() |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
320 |
elif sys.argv[1] in ['h', 'help']: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
321 |
usage() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
322 |
elif sys.argv[1] in ['v', 'version']: |
4 | 323 |
print "%s, version %s (%s from %s)\n" % (__prog__, __version__, |
324 |
__revision__, __date__) |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
325 |
else: |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
326 |
usage(EXIT.UNKNOWN_COMMAND, 'Unknown command: »%s«' % sys.argv[1]) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
327 |
showWarnings() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
328 |
except (EOFError, KeyboardInterrupt): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
329 |
sys.stderr.write('\nOuch!\n') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
330 |
sys.exit(EXIT.USER_INTERRUPT) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
331 |
except VMME.VMMException, e: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
332 |
sys.stderr.write("\aERROR: %s\n" % e[0][0]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
333 |
sys.exit(e[0][1]) |