Beispiel #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")
Beispiel #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")
Beispiel #3
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 set as 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
    load_logging_config(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)

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

    # SERVICES. Service definitions
    from pyon.service.service import IonServiceRegistry
    global _service_registry
    _service_registry = IonServiceRegistry()
    _service_registry.load_service_mods('interface/services')
    _service_registry.build_service_map()

    # INTERCEPTORS.
    # TODO: Is
    from pyon.net.endpoint import instantiate_interceptors
    instantiate_interceptors(CFG.interceptor)

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

    # Set initialized flag
    pyon_initialized = True
Beispiel #4
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 set as 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
    load_logging_config(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)

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

    # SERVICES. Service definitions
    from pyon.service.service import IonServiceRegistry
    global _service_registry
    _service_registry = IonServiceRegistry()
    _service_registry.load_service_mods('interface/services')
    _service_registry.build_service_map()

    # INTERCEPTORS.
    # TODO: Is
    from pyon.net.endpoint import instantiate_interceptors
    instantiate_interceptors(CFG.interceptor)

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

    # Set initialized flag
    pyon_initialized = True
Beispiel #5
0
import pkgutil
import os
import re
import sys
import string
import yaml
import hashlib
import argparse
import traceback
from collections import OrderedDict

from pyon.core.path import list_files_recursive
from pyon.core.interfaces.interface_util import get_object_definition_from_datastore, get_service_definition_from_datastore
from pyon.service.service import BaseService
from pyon.util import yaml_ordered_dict
yaml_ordered_dict.apply_yaml_patch()

templates = {
    'file': '''#!/usr/bin/env python
#
# File generated on ${when_generated}
#

from zope.interface import Interface, implements

from collections import OrderedDict, defaultdict

import interface.objects
from pyon.core.bootstrap import IonObject
from pyon.service.service import BaseService, BaseClients
from pyon.net.endpoint import RPCClient
import datetime
import fnmatch
import inspect
import pkgutil
import os
import re
import sys
import string
import yaml
import hashlib
import argparse
import traceback
from collections import OrderedDict
from pyon.core.path import list_files_recursive
from pyon.service.service import BaseService
from pyon.util import yaml_ordered_dict; yaml_ordered_dict.apply_yaml_patch()




templates = {
      'file':
'''#!/usr/bin/env python
#
# File generated on ${when_generated}
#

from zope.interface import Interface, implements

from collections import OrderedDict, defaultdict