[root@tolna.net: Cron <list@melanie> /usr/bin/python /var/lib/mailman/cron/mailpasswds]
This is my monthly remainder. I looket at it several times but no luck.
Sidenote: is there a searchable archive of the lists? I would like to search for the answer instead of possibly asking here again...
----- Forwarded message from Cron Daemon <root@tolna.net> -----
Traceback (innermost last): File "/var/lib/mailman/cron/mailpasswds", line 158, in ? main() File "/var/lib/mailman/cron/mailpasswds", line 154, in main MailAllPasswords(a_public_list, hosts) File "/var/lib/mailman/cron/mailpasswds", line 87, in MailAllPasswords text = Utils.maketext( File "/var/lib/mailman/Mailman/Utils.py", line 610, in maketext return wrap(template % dict) KeyError: one_list
----- End forwarded message -----
On Wed, Sep 01, 1999 at 12:04:20PM +0200, Peter Gervai wrote:
File "/var/lib/mailman/Mailman/Utils.py", line 610, in maketext return wrap(template % dict) KeyError: one_list
It looks like your cronpass.txt template has a "%(one_list)s" in it, which doesn't exist in the data being passed. The only values allowed for substitution in there are hostname, useraddr, exreq, and owner. Did you perhaps modify the cronpass.txt template?
Here's a patch that will fix it in any case. It causes any invalid "%(key)" format strings to remain as they are instead of throwing KeyErrors.
Sean
*** Utils.py.old Wed Sep 1 10:10:40 1999 --- Utils.py Wed Sep 1 10:16:47 1999
*** 33,38 **** --- 33,54 ---- import random import mm_cfg import Errors
import UserDict
class SaferDict(UserDict.UserDict):
'''Dictionary which returns a default value for unknown keys.'''
def __init__(self, dict, default = '<Unknown field "%s">'):
UserDict.UserDict.__init__(self, dict)
self.default = default
def __getitem__(self, key):
try: return(self.data[key])
except KeyError: pass
try: return(self.default % ( key ))
except TypeError: return(self.default)
def list_names(): """Return the names of all lists in default list directory."""
*** 606,613 **** template = fp.read() fp.close() if raw: ! return template % dict ! return wrap(template % dict)
# --- 622,629 ---- template = fp.read() fp.close() if raw: ! return template % SaferDict(dict, '%%(%s)s') ! return wrap(template % SaferDict(dict), '%%(%s)s')
#
-- It is not enough to have a good mind. The main thing is to use it well. -- Rene Descartes Sean Reifschneider, Inimitably Superfluous <jafo@tummy.com> URL: <http://www.tummy.com/xvscan> HP-UX/Linux/FreeBSD/BSDOS scanning software.
"SR" == Sean Reifschneider <jafo@tummy.com> writes:
SR> It looks like your cronpass.txt template has a "%(one_list)s"
SR> in it, which doesn't exist in the data being passed. The only
SR> values allowed for substitution in there are hostname,
SR> useraddr, exreq, and owner. Did you perhaps modify the
SR> cronpass.txt template?
SR> Here's a patch that will fix it in any case. It causes any
SR> invalid "%(key)" format strings to remain as they are instead
SR> of throwing KeyErrors.
I like this, Sean. I'm going to check in a slight modification (attached).
Thanks! -Barry
-------------------- snip snip -------------------- Index: Utils.py
RCS file: /projects/cvsroot/mailman/Mailman/Utils.py,v retrieving revision 1.75 diff -c -r1.75 Utils.py *** Utils.py 1999/09/02 19:39:08 1.75 --- Utils.py 1999/09/02 19:51:38
*** 27,32 **** --- 27,34 ---- import os import string import re
- from UserDict import UserDict
- from types import StringType # XXX: obsolete, should use re module import regsub import random
*** 620,625 **** --- 622,645 ----
- class SafeDict(UserDict):
"""Dictionary which returns a default value for unknown keys.
This is used in maketext so that editing templates is a bit more robust.
"""
def __init__(self, d):
UserDict.__init__(self, d)
def __getitem__(self, key):
try:
return self.data[key]
except KeyError:
if type(key) == StringType:
return '%('+key+')s'
else:
return '<Missing key: %s>' % `key`
- def maketext(templatefile, dict, raw=0): """Make some text from a template file.
*** 631,639 **** fp = open(file) template = fp.read() fp.close() if raw: ! return template % dict ! return wrap(template % dict)
--- 651,660 ---- fp = open(file) template = fp.read() fp.close()
! return text ! return wrap(text)text = template % SafeDict(dict) if raw:
participants (3)
-
Barry A. Warsaw
-
Peter Gervai
-
Sean Reifschneider