Revision 903,
1.1 KB
checked in by niltonneto, 15 years ago
(diff) |
Importacao inicial do Expresso do Serpro
|
Line | |
---|
1 | import sys |
---|
2 | import getopt |
---|
3 | |
---|
4 | from Mailman import mm_cfg |
---|
5 | |
---|
6 | def usage(code, msg=''): |
---|
7 | if code: |
---|
8 | fd = sys.stderr |
---|
9 | else: |
---|
10 | fd = sys.stdout |
---|
11 | print >> fd, __doc__ |
---|
12 | if msg: |
---|
13 | print >> fd, msg |
---|
14 | sys.exit(code) |
---|
15 | |
---|
16 | def set_mod(mlist, *args): |
---|
17 | |
---|
18 | try: |
---|
19 | opts, args = getopt.getopt(args, 'su', ['set', 'unset']) |
---|
20 | except getopt.error, msg: |
---|
21 | usage(1, msg) |
---|
22 | |
---|
23 | action = None |
---|
24 | for opt, arg in opts: |
---|
25 | if opt in ('-s', '--set'): |
---|
26 | if action in (0, 1): |
---|
27 | usage(1, 'Exactly one of -s, --set, -u, --unset required') |
---|
28 | action = 1 |
---|
29 | if opt in ('-u', '--unset'): |
---|
30 | if action in (0, 1): |
---|
31 | usage(1, 'Exactly one of -s, --set, -u, --unset required') |
---|
32 | action = 0 |
---|
33 | if action == None: |
---|
34 | usage(1, 'Exactly one of -s, --set, -u, --unset required') |
---|
35 | if not args: |
---|
36 | usage(1, 'Member address is required') |
---|
37 | |
---|
38 | if not mlist.Locked(): |
---|
39 | mlist.Lock() |
---|
40 | for member in args: |
---|
41 | mlist.setMemberOption(member, mm_cfg.Moderate, action) |
---|
42 | mlist.Save() |
---|
43 | mlist.Unlock() |
---|
Note: See
TracBrowser
for help on using the repository browser.