Implement the REST API for <api>/owners.
[mailman.git] / port_me / bumpdigests.py
blobf30772ca81ed49ce35b4b9da15db8da9b21fe373
1 # Copyright (C) 1998-2015 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
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.
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.
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/>.
18 import sys
19 import optparse
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
27 # Work around known problems with some RedHat cron daemons
28 import signal
29 signal.signal(signal.SIGCHLD, signal.SIG_DFL)
33 def parseargs():
34 parser = optparse.OptionParser(version=MAILMAN_VERSION,
35 usage=_("""\
36 %prog [options] [listname ...]
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
48 def main():
49 opts, args, parser = parseargs()
50 config.load(opts.config)
52 listnames = set(args or config.list_manager.names)
53 if not listnames:
54 print(_('Nothing to do.'))
55 sys.exit(0)
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(_('No such list: $listname'), file=sys.stderr)
64 sys.exit(1)
65 try:
66 mlist.bump_digest_volume()
67 finally:
68 mlist.Save()
69 mlist.Unlock()
73 if __name__ == '__main__':
74 main()