1112
by Mark Sapiro
Fixed erroneously 'pre-configured' commands |
1 |
#! @PYTHON@ |
1
by
This commit was manufactured by cvs2svn to create branch |
2 |
#
|
1779
by Mark Sapiro
Bump copyright dates. |
3 |
# Copyright (C) 1998-2018 by the Free Software Foundation, Inc. |
1
by
This commit was manufactured by cvs2svn to create branch |
4 |
#
|
5 |
# This program is free software; you can redistribute it and/or |
|
6 |
# modify it under the terms of the GNU General Public License |
|
7 |
# as published by the Free Software Foundation; either version 2 |
|
8 |
# of the License, or (at your option) any later version. |
|
9 |
# |
|
10 |
# This program is distributed in the hope that it will be useful, |
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
# GNU General Public License for more details. |
|
14 |
# |
|
15 |
# You should have received a copy of the GNU General Public License |
|
16 |
# along with this program; if not, write to the Free Software |
|
978
by msapiro
senddigests - Changed to catch exceptions thrown by mlist.send_digest_now() and |
17 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
18 |
# USA. |
|
1
by
This commit was manufactured by cvs2svn to create branch |
19 |
|
20 |
"""Dispatch digests for lists w/pending messages and digest_send_periodic set.
|
|
21 |
||
22 |
Usage: %(PROGRAM)s [options]
|
|
23 |
||
24 |
Options:
|
|
25 |
-h / --help
|
|
26 |
Print this message and exit.
|
|
27 |
||
28 |
-l listname
|
|
29 |
--listname=listname
|
|
30 |
Send the digest for the given list only, otherwise the digests for all
|
|
1673
by Mark Sapiro
Added -e/--exceptlist to cron/senddigests. |
31 |
lists are sent out. May be repeated to do multiple lists.
|
32 |
||
33 |
-e listname
|
|
34 |
--exceptlist listname
|
|
35 |
Don't send the digest for the given list. May be repeated to skip
|
|
36 |
multiple lists.
|
|
1
by
This commit was manufactured by cvs2svn to create branch |
37 |
"""
|
38 |
||
978
by msapiro
senddigests - Changed to catch exceptions thrown by mlist.send_digest_now() and |
39 |
import os |
1
by
This commit was manufactured by cvs2svn to create branch |
40 |
import sys |
41 |
import getopt |
|
42 |
||
43 |
import paths |
|
44 |
from Mailman import mm_cfg |
|
45 |
from Mailman import Utils |
|
46 |
from Mailman import MailList |
|
47 |
from Mailman.i18n import _ |
|
48 |
||
49 |
# Work around known problems with some RedHat cron daemons |
|
50 |
import signal |
|
51 |
signal.signal(signal.SIGCHLD, signal.SIG_DFL) |
|
52 |
||
53 |
PROGRAM = sys.argv[0] |
|
54 |
||
55 |
||
56 |
||
57 |
def usage(code, msg=''): |
|
58 |
if code: |
|
59 |
fd = sys.stderr |
|
60 |
else: |
|
61 |
fd = sys.stdout |
|
62 |
print >> fd, _(__doc__) |
|
63 |
if msg: |
|
64 |
print >> fd, msg |
|
65 |
sys.exit(code) |
|
66 |
||
67 |
||
68 |
||
69 |
def main(): |
|
70 |
try: |
|
1673
by Mark Sapiro
Added -e/--exceptlist to cron/senddigests. |
71 |
opts, args = getopt.getopt(sys.argv[1:], 'hl:e:', |
72 |
['help', 'listname=', 'exceptlist=']) |
|
1
by
This commit was manufactured by cvs2svn to create branch |
73 |
except getopt.error, msg: |
74 |
usage(1, msg) |
|
75 |
||
76 |
if args: |
|
77 |
usage(1) |
|
78 |
||
1673
by Mark Sapiro
Added -e/--exceptlist to cron/senddigests. |
79 |
exceptlists = [] |
1
by
This commit was manufactured by cvs2svn to create branch |
80 |
listnames = [] |
81 |
for opt, arg in opts: |
|
82 |
if opt in ('-h', '--help'): |
|
83 |
usage(0) |
|
84 |
elif opt in ('-l', '--listname'): |
|
85 |
listnames.append(arg) |
|
1673
by Mark Sapiro
Added -e/--exceptlist to cron/senddigests. |
86 |
elif opt in ('-e', '--exceptlist'): |
87 |
exceptlists.append(arg) |
|
1
by
This commit was manufactured by cvs2svn to create branch |
88 |
|
89 |
if not listnames: |
|
90 |
listnames = Utils.list_names() |
|
1673
by Mark Sapiro
Added -e/--exceptlist to cron/senddigests. |
91 |
for listname in exceptlists: |
92 |
try: |
|
93 |
listnames.remove(listname) |
|
94 |
except ValueError: |
|
95 |
pass |
|
1
by
This commit was manufactured by cvs2svn to create branch |
96 |
|
97 |
for listname in listnames: |
|
98 |
mlist = MailList.MailList(listname, lock=0) |
|
99 |
if mlist.digest_send_periodic: |
|
100 |
mlist.Lock() |
|
101 |
try: |
|
978
by msapiro
senddigests - Changed to catch exceptions thrown by mlist.send_digest_now() and |
102 |
try: |
103 |
mlist.send_digest_now() |
|
104 |
mlist.Save() |
|
105 |
# We are unable to predict what exception may occur in digest |
|
106 |
# processing and we don't want to lose the other digests, so |
|
107 |
# we catch everything.
|
|
108 |
except Exception, errmsg:
|
|
109 |
print >> sys.stderr, \
|
|
110 |
'List: %s: problem processing %s:\n%s' % \ |
|
111 |
(listname,
|
|
112 |
os.path.join(mlist.fullpath(), 'digest.mbox'), |
|
113 |
errmsg)
|
|
1
by
This commit was manufactured by cvs2svn to create branch |
114 |
finally:
|
115 |
mlist.Unlock()
|
|
116 |
||
117 |
||
118 |
||
119 |
if __name__ == '__main__': |
|
120 |
main() |