예제 #1
0
def bootstrap_pyon(logging_config_override=None, pyon_cfg=None):
    """
    This function initializes the core elements of the Pyon framework in a controlled way.
    It does not initialize the ION container or the ION system.
    @param logging_config_override  A dict to initialize the Python logging subsystem (None loads default files)
    @param pyon_cfg   A DotDict with the fully loaded pyon configuration to merge into CFG (None loads default files)
    """
    log.info("pyon.bootstrap (bootstrap_pyon) executing...")

    # Make sure Pyon is only initialized only once
    global pyon_initialized
    if pyon_initialized:
        log.warn("WARNING -- bootstrap_pyon() called again!")
        return

    # ENVIRONMENT. Check we are called in an expected environment (files, directories, etc)
    assert_environment()

    # LOGGING. Initialize logging from config
    if not logutil.is_logging_configured():
        logutil.configure_logging(
            logutil.DEFAULT_LOGGING_PATHS,
            logging_config_override=logging_config_override)

    # YAML patch: OrderedDicts instead of dicts
    from pyon.util.yaml_ordered_dict import apply_yaml_patch
    apply_yaml_patch()

    # CONFIG. Initialize pyon global configuration from local files
    set_config(pyon_cfg)
    log.debug("CFG set to %s", CFG)

    # OBJECTS. Object and message definitions.
    from pyon.core.registry import IonObjectRegistry
    global _obj_registry
    _obj_registry = IonObjectRegistry()

    # SERVICES. Service definitions
    # TODO: change the following to read service definitions from directory and import selectively
    from pyon.ion.service import IonServiceRegistry
    import interface.services
    global _service_registry
    _service_registry = IonServiceRegistry()
    _service_registry.load_service_mods(interface.services)
    _service_registry.build_service_map()

    # RESOURCES. Load and initialize definitions
    from pyon.ion import resource
    resource.load_definitions()

    # Fix a weird bug on Ubuntu that resets time.sleep to un-monkey patched version on import threading
    from gevent import monkey
    monkey.patch_time()

    # Set initialized flag
    pyon_initialized = True
    log.debug("Pyon initialized OK")
예제 #2
0
def bootstrap_pyon(logging_config_override=None, pyon_cfg=None):
    """
    This function initializes the core elements of the Pyon framework in a controlled way.
    It does not initialize the ION container or the ION system.
    @param logging_config_override  A dict to initialize the Python logging subsystem (None loads default files)
    @param pyon_cfg   A DotDict with the fully loaded pyon configuration to merge into CFG (None loads default files)
    """
    print "pyon: pyon.bootstrap (bootstrap_pyon) executing..."

    # Make sure Pyon is only initialized only once
    global pyon_initialized
    if pyon_initialized:
        print "pyon: WARNING -- bootstrap_pyon() called again!"
        return

    # ENVIRONMENT. Check we are called in an expected environment (files, directories, etc)
    assert_environment()

    # LOGGING. Initialize logging from config
    if not logutil.is_logging_configured():
        logutil.configure_logging(logutil.DEFAULT_LOGGING_PATHS, logging_config_override=logging_config_override)

    # YAML patch: OrderedDicts instead of dicts
    from pyon.util.yaml_ordered_dict import apply_yaml_patch
    apply_yaml_patch()

    # CONFIG. Initialize pyon global configuration from local files
    set_config(pyon_cfg)
    log.debug("pyon: CFG set to %s", CFG)

    # OBJECTS. Object and message definitions.
    from pyon.core.registry import IonObjectRegistry
    global _obj_registry
    _obj_registry = IonObjectRegistry()

    # SERVICES. Service definitions
    # TODO: change the following to read service definitions from directory and import selectively
    from pyon.ion.service import IonServiceRegistry
    import interface.services
    global _service_registry
    _service_registry = IonServiceRegistry()
    _service_registry.load_service_mods(interface.services)
    _service_registry.build_service_map()

    # RESOURCES. Load and initialize definitions
    from pyon.ion import resource
    resource.load_definitions()

    # Fix a weird bug on Ubuntu that resets time.sleep to un-monkey patched version on import threading
    from gevent import monkey; monkey.patch_time()

    # Set initialized flag
    pyon_initialized = True
    log.debug("pyon: initialized OK")
예제 #3
0
#!/usr/bin/env python
"""
@package coverage_model.base_test_classes
@file coverage_model/base_test_classes.py
@author Christopher Mueller
@brief Base classes for Unit and Int testing within the coverage model
"""

from unittest import TestCase
import os, shutil, tempfile

from pyon.core import log as logutil
if not logutil.is_logging_configured():
    logutil.configure_logging(logutil.DEFAULT_LOGGING_PATHS)


class CoverageModelUnitTestCase(TestCase):

    # Prevent test docstring from printing - uses test name instead
    # @see
    # http://www.saltycrane.com/blog/2012/07/how-prevent-nose-unittest-using-docstring-when-verbosity-2/
    def shortDescription(self):
        return None

    # override __str__ and __repr__ behavior to show a copy-pastable nosetest name for ion tests
    #  ion.module:TestClassName.test_function_name
    def __repr__(self):
        name = self.id()
        name = name.split('.')
        if name[0] not in ["coverage_model"]:
            return "%s (%s)" % (name[-1], '.'.join(name[:-1]))
예제 #4
0
#!/usr/bin/env python

"""
@package coverage_model.base_test_classes
@file coverage_model/base_test_classes.py
@author Christopher Mueller
@brief Base classes for Unit and Int testing within the coverage model
"""

from unittest import TestCase
import os, shutil, tempfile

from pyon.core import log as logutil

if not logutil.is_logging_configured():
    logutil.configure_logging(logutil.DEFAULT_LOGGING_PATHS)


class CoverageModelUnitTestCase(TestCase):

    # Prevent test docstring from printing - uses test name instead
    # @see
    # http://www.saltycrane.com/blog/2012/07/how-prevent-nose-unittest-using-docstring-when-verbosity-2/
    def shortDescription(self):
        return None

    # override __str__ and __repr__ behavior to show a copy-pastable nosetest name for ion tests
    #  ion.module:TestClassName.test_function_name
    def __repr__(self):
        name = self.id()
        name = name.split(".")