Hi, thanks to those who responded.
On Tue, Apr 20, 2004 at 07:13:35PM +0200, Josselin Mouette wrote: > Well, this file might be imported by mailman and not by the python > interpreter as it is launched. You're correct with this assumption ... > I'd recommend a 'locate string.py' to be sure. ... but 'locate string.py' doesn't help when /var/lib/mailman/pythonlib is a symlink to /usr/lib/python2.1 :-\ I found that problem with the help of a predator of the attached script which I wrote for debugging the python postinst for the next mailman release. Thanks . Siggy
#! /usr/bin/python -O # # Adopted from mailman maintainer scripts # # Copyright (c) 2004, Bernd S. Brentrup <[EMAIL PROTECTED]> # # Licensed under GPL version 2 # # Work in progress, STANDARD NO WARRANTY DISCLAIMER # # $URL: svn+alioth://svn.alioth.debian.org/svn/pkg-mailman/branches/pkg-split/core/debian/snippets/maint_helpers.py $ # $Id: maint_helpers.py 80 2004-04-22 21:04:10Z bsb $ """ """# __version__ = '0.1' __all__ = [ 'SimpleLogger', 'DebuggingLogger', 'CommandRunner', ] # We'll use this copy later in CommandRunner virgin_gbls = globals().copy() for k in ('__doc__', '__version__', '__all__'): del virgin_gbls[k] import sys, os class SimpleLogger: """ """# levels = [ 'no', 'yes', 'all' ] def __init__(self, prefix): self._file = sys.stderr try: level = os.environ['%(prefix)s_LOG' % locals()] self._level = int(level) except KeyError: self._level = 1 except ValueError: self._level = self.levels.index(level.lower()) def set_level(self, lvl): self._level = lvl def set_file(self, fl): self._file = fl def __call__(self, msg, **kw): nl = kw.get('nl', '\n') lvl = kw.get('lvl', 1) if lvl <= self._level: self._file.write('%(msg)s%(nl)s' % locals()) self._file.flush() class DebuggingLogger(SimpleLogger): """ """# def __init__(self, prefix): SimpleLogger.__init__(self, prefix) self._info = [ 'modules', 'path', 'argv', 'version', 'environ' ] try: info = os.environ['%(prefix)s_DEBUG' % locals()] if info not in ('all', 'chatty'): self._info = info.split(',') elif info == 'chatty': self.set_level(999) except: self._info = [] def sys_info(self): if 'modules' in self._info: for n, m in sys.modules.items(): if m is not None: self('%20s: %r' % (n, m), lvl=0) self('', lvl=0) if 'version' in self._info: self('sys.version=%r' % sys.version, lvl=0) self('', lvl=0) if 'path' in self._info: self('sys.path=%r' % sys.path, lvl=0) self('', lvl=0) if 'argv' in self._info: self('sys.argv=%r' % sys.argv, lvl=0) self('', lvl=0) if 'environ' in self._info: self('os.environ:', lvl=0) for n, v in os.environ.items(): self('%20s=%r' % (n, v), lvl=0) self('', lvl=0) class CommandRunner: """ """# def __init__(self, sys_path): self._prepend = sys_path self._sys_path = def run(self, cmd, *args): """ """# gbls = virgin_gbls.copy() sys_argv = sys.argv[:] sys_path = sys.path[:] sys.argv = [cmd] + list(args) sys.path.insert(0, self._prepend) execfile(cmd, gbls) sys.path = sys_path sys.argv = sys_argv # If run as a script, provide debug info for MM commands # implemented in Python. if __name__ == '__main__': MM_ROOT = '/var/lib/mailman' sys.stderr = sys.stdout log = DebuggingLogger('MM_MAINT') try: CommandRunner(os.path.join(MM_ROOT, 'bin') ).run(*sys.argv[1:]) finally: # If things break, show useful information # depending on $MM_MAINT_DEBUG settings log.sys_info()