~launchpad-pqm/launchpad/devel

8687.15.4 by Karl Fogel
Add the copyright header block to more files; tweak format in a few files.
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
2125 by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings
3
8329.1.6 by Gary Poster
make all the _pythonpath.py files work
4
# NOTE: This is a generated file.  The original is in
5
# buildout-templates/_pythonpath.py.in
6
10303.1.8 by Gary Poster
be more precise about what is going on in _pythonpath, and add more comments
7
# This file works if the Python has been started with -S, or if bin/py
8
# has been used.
9
10713.1.1 by Gary Poster
use new version of z3c.recipe.filetemplate and zc.buildout fork to use relative paths.
10
# Auto-generated code to handle relative paths
11
${python-relative-path-setup}
12
10303.1.8 by Gary Poster
be more precise about what is going on in _pythonpath, and add more comments
13
import os
9641.1.11 by Gary Poster
perform some clean-ups per review by barry
14
import sys
10637.2.4 by Guilherme Salgado
Suppress md5/sha/sets deprecation warnings from Twisted
15
import warnings
16
10637.2.27 by Guilherme Salgado
Mention bug numbers in all XXXs added on this branch
17
# XXX: 2010-04-26, Salgado, bug=570246: Silence python2.6 deprecation
18
# warnings.
10637.2.4 by Guilherme Salgado
Suppress md5/sha/sets deprecation warnings from Twisted
19
warnings.filterwarnings(
20
    'ignore', '.*(md5|sha|sets)', DeprecationWarning,
21
    )
10713.1.1 by Gary Poster
use new version of z3c.recipe.filetemplate and zc.buildout fork to use relative paths.
22
23
site_dir = ${scripts:parts-directory|path-repr}
10303.1.8 by Gary Poster
be more precise about what is going on in _pythonpath, and add more comments
24
25
if ('site' in sys.modules and
26
    not sys.modules['site'].__file__.startswith(
27
        os.path.join(site_dir, 'site.py'))):
28
    # We have the wrong site.py, so our paths are not set up correctly.
29
    # We blow up, with a hopefully helpful error message.
30
    raise RuntimeError(
10713.1.1 by Gary Poster
use new version of z3c.recipe.filetemplate and zc.buildout fork to use relative paths.
31
        'The wrong site.py is imported (%r imported, %r expected). '
32
        'Scripts should usually be '
10303.1.8 by Gary Poster
be more precise about what is going on in _pythonpath, and add more comments
33
        "started with Launchpad's bin/py, or with a Python invoked with "
10713.1.1 by Gary Poster
use new version of z3c.recipe.filetemplate and zc.buildout fork to use relative paths.
34
        'the -S flag.' % (
35
        sys.modules['site'].__file__, os.path.join(site_dir, 'site.py')))
10303.1.8 by Gary Poster
be more precise about what is going on in _pythonpath, and add more comments
36
10303.1.1 by Gary Poster
use newest version of zc.buildout
37
if site_dir not in sys.path:
7675.663.2 by Gary Poster
previous fix was insufficient
38
    sys.path.insert(0, site_dir)
39
elif 'site' not in sys.modules:
7675.663.1 by Gary Poster
work around bug 575206 causing problem in production with new buildout code.
40
    # XXX 2010-05-04 gary bug 575206
7675.663.2 by Gary Poster
previous fix was insufficient
41
    # This one line is to support Mailman 2, which does something unexpected
7675.663.1 by Gary Poster
work around bug 575206 causing problem in production with new buildout code.
42
    # to set up its paths.
43
    sys.path[:] = [p for p in sys.path if 'site-packages' not in p]
10303.1.1 by Gary Poster
use newest version of zc.buildout
44
import site # sets up paths