10303.1.1
by Gary Poster
use newest version of zc.buildout |
1 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
3 |
||
4 |
# This file is imported by parts/scripts/sitecustomize.py, as set up in our
|
|
5 |
# buildout.cfg (see the "initialization" key in the "[scripts]" section).
|
|
6 |
||
7 |
import os |
|
10981.1.1
by Maris Fogels
Silence DeprecationWarnings from pycrypto 2.0.1 using a new warnings hook in lp_sitecustomize. |
8 |
import warnings |
11136.3.1
by Diogo Matsubara
silence the root logger across the entire Launchpad project |
9 |
import logging |
10981.1.1
by Maris Fogels
Silence DeprecationWarnings from pycrypto 2.0.1 using a new warnings hook in lp_sitecustomize. |
10 |
|
11 |
from bzrlib.branch import Branch |
|
11136.3.3
by Diogo Matsubara
move NullHandler to a more central location where it can be imported from lp_sitecustomize.py and test_layers.py test. |
12 |
from lp.services.log.nullhandler import NullHandler |
10303.1.1
by Gary Poster
use newest version of zc.buildout |
13 |
from lp.services.mime import customizeMimetypes |
9590.1.94
by Michael Hudson
test passes, some zope security horror though |
14 |
from zope.security import checker |
10981.1.1
by Maris Fogels
Silence DeprecationWarnings from pycrypto 2.0.1 using a new warnings hook in lp_sitecustomize. |
15 |
|
9590.1.95
by Michael Hudson
more comprehensive zope horror |
16 |
|
11136.3.7
by Diogo Matsubara
change the function name to reflect what it's doing |
17 |
def silence_bzr_logger(): |
11136.3.6
by Diogo Matsubara
fix docstring |
18 |
"""Install the NullHandler on the bzr logger to silence logs."""
|
11136.3.5
by Diogo Matsubara
review comment: silence the bzr logger only |
19 |
logging.getLogger('bzr').addHandler(NullHandler()) |
11136.3.1
by Diogo Matsubara
silence the root logger across the entire Launchpad project |
20 |
|
9590.1.95
by Michael Hudson
more comprehensive zope horror |
21 |
def dont_wrap_class_and_subclasses(cls): |
22 |
checker.BasicTypes.update({cls: checker.NoProxy}) |
|
23 |
for subcls in cls.__subclasses__(): |
|
24 |
dont_wrap_class_and_subclasses(subcls) |
|
10303.1.1
by Gary Poster
use newest version of zc.buildout |
25 |
|
10981.1.1
by Maris Fogels
Silence DeprecationWarnings from pycrypto 2.0.1 using a new warnings hook in lp_sitecustomize. |
26 |
def silence_warnings(): |
27 |
"""Silence warnings across the entire Launchpad project."""
|
|
28 |
# pycrypto-2.0.1 on Python2.6:
|
|
29 |
# DeprecationWarning: the sha module is deprecated; use the hashlib
|
|
30 |
# module instead
|
|
31 |
warnings.filterwarnings( |
|
32 |
"ignore", |
|
33 |
category=DeprecationWarning, |
|
34 |
module="Crypto") |
|
35 |
||
10303.1.1
by Gary Poster
use newest version of zc.buildout |
36 |
def main(): |
10303.1.5
by Gary Poster
try to clarify comment in lp_sitecustomize.py |
37 |
# Note that we configure the LPCONFIG environmental variable in the
|
38 |
# custom buildout-generated sitecustomize.py in
|
|
39 |
# parts/scripts/sitecustomize.py rather than here. This is because
|
|
40 |
# the instance name, ${configuration:instance_name}, is dynamic,
|
|
41 |
# sent to buildout from the Makefile. See buildout.cfg in the
|
|
42 |
# initialization value of the [scripts] section for the code that
|
|
43 |
# goes into this custom sitecustomize.py. We do as much other
|
|
44 |
# initialization as possible here, in a more visible place.
|
|
10303.1.1
by Gary Poster
use newest version of zc.buildout |
45 |
os.environ['STORM_CEXTENSIONS'] = '1' |
46 |
customizeMimetypes() |
|
9590.1.95
by Michael Hudson
more comprehensive zope horror |
47 |
dont_wrap_class_and_subclasses(Branch) |
10981.1.1
by Maris Fogels
Silence DeprecationWarnings from pycrypto 2.0.1 using a new warnings hook in lp_sitecustomize. |
48 |
silence_warnings() |
11136.3.7
by Diogo Matsubara
change the function name to reflect what it's doing |
49 |
silence_bzr_logger() |
10303.1.1
by Gary Poster
use newest version of zc.buildout |
50 |
|
51 |
main() |