~mailman-coders/mailman/2.1

1 by
This commit was manufactured by cvs2svn to create branch
1
#! @PYTHON@
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 
749 by tkikuchi
FSF office has moved to 51 Franklin Street.
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1 by
This commit was manufactured by cvs2svn to create branch
18
19
"""Increment the digest volume number and reset the digest number to one.
20
21
Usage: %(PROGRAM)s [options] [listname ...]
22
23
Options:
24
25
    --help/-h
26
        Print this message and exit.
27
28
The lists named on the command line are bumped.  If no list names are given,
29
all lists are bumped.
30
"""
31
32
import sys
33
import getopt
34
35
import paths
36
from Mailman import mm_cfg
37
from Mailman import Utils
38
from Mailman import MailList
39
from Mailman import Errors
40
from Mailman.i18n import _
41
42
# Work around known problems with some RedHat cron daemons
43
import signal
44
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
45
46
PROGRAM = sys.argv[0]
47
48
49

50
def usage(code, msg=''):
51
    if code:
52
        fd = sys.stderr
53
    else:
54
        fd = sys.stdout
55
    print >> fd, _(__doc__)
56
    if msg:
57
        print >> fd, msg
58
    sys.exit(code)
59
60
61

62
def main():
63
    try:
64
        opts, args = getopt.getopt(sys.argv[1:], 'h', ['help'])
65
    except getopt.error, msg:
66
        usage(1, msg)
67
68
    for opt, arg in opts:
69
        if opt in ('-h', '--help'):
70
            usage(0)
71
72
    if args:
73
        listnames = args
74
    else:
75
        listnames = Utils.list_names()
76
77
    if not listnames:
78
        print _('Nothing to do.')
79
        sys.exit(0)
80
81
    for listname in listnames:
82
        try:
83
            # be sure the list is locked
84
            mlist = MailList.MailList(listname)
85
        except Errors.MMListError, e:
86
            usage(1, _('No such list: %(listname)s'))
87
        try:
88
            mlist.bump_digest_volume()
89
        finally:
90
            mlist.Save()
91
            mlist.Unlock()
92
93
94

95
if __name__ == '__main__':
96
    main()