def main(instance_name):
    # This is called by our custom buildout-generated sitecustomize.py
    # in parts/scripts/sitecustomize.py. The instance name is sent to
    # buildout from the Makefile, and then inserted into
    # sitecustomize.py.  See buildout.cfg in the "initialization" value
    # of the [scripts] section for the code that goes into this custom
    # sitecustomize.py.  We do all actual initialization here, in a more
    # visible place.
    if instance_name and instance_name != 'development':
        # See bug 656213 for why we do this carefully.
        os.environ.setdefault('LPCONFIG', instance_name)
    os.environ['STORM_CEXTENSIONS'] = '1'
    add_custom_loglevels()
    customizeMimetypes()
    silence_warnings()
    customize_logger()
    dont_wrap_bzr_branch_classes()
    checker.BasicTypes.update({defaultdict: checker.NoProxy})
    checker.BasicTypes.update({Deferred: checker.NoProxy})
    checker.BasicTypes.update({DeferredList: checker.NoProxy})
    checker.BasicTypes[itertools.groupby] = checker._iteratorChecker
    # The itertools._grouper type is not exposed by name, so we must get it
    # through actually using itertools.groupby.
    grouper = type(list(itertools.groupby([0]))[0][1])
    checker.BasicTypes[grouper] = checker._iteratorChecker
    customize_get_converter()
Example #2
0
def main(instance_name=None):
    # This is called by _pythonpath.py and by the standard Launchpad script
    # preamble (see LPScriptWriter in setup.py).  The instance name is sent
    # to setup.py from the Makefile, and then written to env/instance_name.
    # We do all actual initialization here, in a more visible place.
    if instance_name is None:
        instance_name_path = os.path.join(sys.prefix, 'instance_name')
        with open(instance_name_path) as instance_name_file:
            instance_name = instance_name_file.read().rstrip('\n')
    if instance_name and instance_name != 'development':
        # See bug 656213 for why we do this carefully.
        os.environ.setdefault('LPCONFIG', instance_name)
    os.environ['STORM_CEXTENSIONS'] = '1'
    add_custom_loglevels()
    customizeMimetypes()
    silence_warnings()
    customize_logger()
    checker.BasicTypes.update({defaultdict: checker.NoProxy})
    checker.BasicTypes.update({Deferred: checker.NoProxy})
    checker.BasicTypes.update({DeferredList: checker.NoProxy})
    checker.BasicTypes[itertools.groupby] = checker._iteratorChecker
    # The itertools._grouper type is not exposed by name, so we must get it
    # through actually using itertools.groupby.
    grouper = type(list(itertools.groupby([0]))[0][1])
    checker.BasicTypes[grouper] = checker._iteratorChecker
Example #3
0
def main(instance_name):
    # This is called by our custom buildout-generated sitecustomize.py
    # in parts/scripts/sitecustomize.py. The instance name is sent to
    # buildout from the Makefile, and then inserted into
    # sitecustomize.py.  See buildout.cfg in the "initialization" value
    # of the [scripts] section for the code that goes into this custom
    # sitecustomize.py.  We do all actual initialization here, in a more
    # visible place.
    if instance_name and instance_name != 'development':
        # See bug 656213 for why we do this carefully.
        os.environ.setdefault('LPCONFIG', instance_name)
    os.environ['STORM_CEXTENSIONS'] = '1'
    add_custom_loglevels()
    customizeMimetypes()
    silence_warnings()
    customize_logger()
    dont_wrap_bzr_branch_classes()
    checker.BasicTypes.update({defaultdict: checker.NoProxy})
    checker.BasicTypes.update({Deferred: checker.NoProxy})
    checker.BasicTypes.update({DeferredList: checker.NoProxy})
    checker.BasicTypes[itertools.groupby] = checker._iteratorChecker
    # The itertools._grouper type is not exposed by name, so we must get it
    # through actually using itertools.groupby.
    grouper = type(list(itertools.groupby([0]))[0][1])
    checker.BasicTypes[grouper] = checker._iteratorChecker
    customize_get_converter()
Example #4
0
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

"""Tests for mime module."""

__metaclass__ = type

import mimetypes

from lp.services.mime import customizeMimetypes
from lp.testing import TestCase

# In our run-time environment this call is made via the initialization section
# of buildout.cfg but that initialization is not done for tests so it must be
# done manually here.
customizeMimetypes()


class TestBzip(TestCase):
    """Tests for iter_split."""

    def test_bzip2(self):
        # Test for '.tar.bzip2' support.
        filename = "foo.tar.bzip2"
        (application, encoding) = mimetypes.guess_type(filename)
        self.assertEqual('application/x-tar', application)
        self.assertEqual('bzip2', encoding)

    def test_tbz2(self):
        # Test for '.tb2' support.
        filename = "foo.tbz2"