~barry/mailman/events-and-web

« back to all changes in this revision

Viewing changes to src/mailman/bin/bumpdigests.py

  • Committer: klm
  • Date: 1998-01-07 21:21:35 UTC
  • Revision ID: vcs-imports@canonical.com-19980107212135-sv0y521ps0xye37r
Initial revision

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 1998-2012 by the Free Software Foundation, Inc.
2
 
#
3
 
# This file is part of GNU Mailman.
4
 
#
5
 
# GNU Mailman is free software: you can redistribute it and/or modify it under
6
 
# the terms of the GNU General Public License as published by the Free
7
 
# Software Foundation, either version 3 of the License, or (at your option)
8
 
# any later version.
9
 
#
10
 
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11
 
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13
 
# more details.
14
 
#
15
 
# You should have received a copy of the GNU General Public License along with
16
 
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
17
 
 
18
 
import sys
19
 
import optparse
20
 
 
21
 
from mailman import errors
22
 
from mailman import MailList
23
 
from mailman.configuration import config
24
 
from mailman.core.i18n import _
25
 
from mailman.version import MAILMAN_VERSION
26
 
 
27
 
# Work around known problems with some RedHat cron daemons
28
 
import signal
29
 
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
30
 
 
31
 
 
32
 
 
33
 
def parseargs():
34
 
    parser = optparse.OptionParser(version=MAILMAN_VERSION,
35
 
                                   usage=_("""\
36
 
%prog [options] [listname ...]
37
 
 
38
 
Increment the digest volume number and reset the digest number to one.  All
39
 
the lists named on the command line are bumped.  If no list names are given,
40
 
all lists are bumped."""))
41
 
    parser.add_option('-C', '--config',
42
 
                      help=_('Alternative configuration file to use'))
43
 
    opts, args = parser.parse_args()
44
 
    return opts, args, parser
45
 
 
46
 
 
47
 
 
48
 
def main():
49
 
    opts, args, parser = parseargs()
50
 
    config.load(opts.config)
51
 
 
52
 
    listnames = set(args or config.list_manager.names)
53
 
    if not listnames:
54
 
        print _('Nothing to do.')
55
 
        sys.exit(0)
56
 
 
57
 
    for listname in listnames:
58
 
        try:
59
 
            # Be sure the list is locked
60
 
            mlist = MailList.MailList(listname)
61
 
        except errors.MMListError:
62
 
            parser.print_help()
63
 
            print >> sys.stderr, _('No such list: $listname')
64
 
            sys.exit(1)
65
 
        try:
66
 
            mlist.bump_digest_volume()
67
 
        finally:
68
 
            mlist.Save()
69
 
            mlist.Unlock()
70
 
 
71
 
 
72
 
 
73
 
if __name__ == '__main__':
74
 
    main()