3
# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
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.
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.
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
17
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
"""Check a list's config database file for integrity.
21
All of the following files are checked:
29
It's okay if any of these are missing. config.pck and config.pck.last are
30
pickled versions of the config database file for 2.1a3 and beyond. config.db
31
and config.db.last are used in all earlier versions, and these are Python
32
marshals. config.safety is a pickle written by 2.1a3 and beyond when the
33
primary config.pck file could not be read.
35
Usage: %(PROGRAM)s [options] [listname [listname ...]]
40
Check the databases for all lists. Otherwise only the lists named on
41
the command line are checked.
44
Verbose output. The state of every tested file is printed.
45
Otherwise only corrupt files are displayed.
48
Print this text and exit.
59
from Mailman import mm_cfg
60
from Mailman import Utils
61
from Mailman.MailList import MailList
62
from Mailman.i18n import _
68
def usage(code, msg=''):
73
print >> fd, _(__doc__)
81
if dbfile.endswith('.db') or dbfile.endswith('.db.last'):
82
loadfunc = marshal.load
83
elif dbfile.endswith('.pck') or dbfile.endswith('.pck.last'):
84
loadfunc = cPickle.load
96
opts, args = getopt.getopt(sys.argv[1:], 'ahv',
97
['all', 'verbose', 'help'])
98
except getopt.error, msg:
104
for opt, arg in opts:
105
if opt in ('-h', '--help'):
107
elif opt in ('-v', '--verbose'):
109
elif opt in ('-a', '--all'):
110
listnames = Utils.list_names()
112
listnames = [n.lower().strip() for n in listnames]
114
print _('Nothing to do.')
117
for listname in listnames:
118
if not Utils.list_exists(listname):
119
print _('No list named:'), listname
121
mlist = MailList(listname, lock=0)
122
pfile = os.path.join(mlist.fullpath(), 'config.pck')
123
plast = pfile + '.last'
124
dfile = os.path.join(mlist.fullpath(), 'config.db')
125
dlast = dfile + '.last'
128
print _('List:'), listname
130
for file in (pfile, plast, dfile, dlast):
135
# Don't report ENOENT unless we're in verbose mode
136
if verbose or e.errno <> errno.ENOENT:
142
if isinstance(status, EnvironmentError):
143
# This already includes the file name
146
print ' %s: %s' % (file, status)
148
print _(' %(file)s: okay')
152
if __name__ == '__main__':