Beispiel #1
0
def run(manager_path,
        logger_path,
        library_path,
        meta_path,
        plugin_path,
        mode=None,
        margs=[],
        level="WARNING",
        layout_mode="default",
        run_mode="default",
        stop_on_cycle_error=True,
        loop=False,
        threads=True,
        signals=True,
        container="default",
        prefix_paths=[],
        daemon_pid=None,
        daemon_file_path=None):
    """
    Starts the loading of the plugin manager. This should be the
    primary start point of the plugin system when starting it as
    a stand alone process (eg: not using wsgi).

    :type manager_path: String
    :param manager_path: The manager base path for execution.
    :type logger_path: String
    :param logger_path: The manager base path for logger.
    :type library_path: String
    :param library_path: The set of paths to the various library
    locations separated by a semi-column.
    :type meta_path: String
    :param meta_path: The set of paths to the various meta
    locations separated by a semi-column.
    :type plugin_path: String
    :param plugin_path: The set of paths to the various plugin
    locations separated by a semi-column.
    :type mode: String
    :param mode: The mode that is going to be used for non
    standard execution of the plugin manager (eg: testing). This
    value is not set by default (for default execution).
    :type margs: List
    :param margs: The arguments (coming from command line) that
    are going to be provided at execution time to the function
    responsible for the mode execution, these arguments should
    consist on a series of string based values.
    :type level: String
    :param level: The logging level described as a string that is
    going to be used by the underlying colony logging infra-structure.
    :type layout_mode: String
    :param layout_mode: The layout mode to be used by the plugin system.
    :type run_mode: String
    :param run_mode: The run mode to be used by the plugin
    system, this value is critical for the type of execution
    of the colony system (eg: development, runtime, etc.)
    :type stop_on_cycle_error: bool
    :param stop_on_cycle_error: If the plugin system should stop
    on cycle error, a cycle error is an error that occurs during
    the startup process of the colony infra-structure.
    :type loop: bool
    :param loop: If the plugin manager is going to run in a loop.
    :type threads: bool
    :param threads: If the plugin manager is going to allow threads.
    :type signals: bool
    :param signals: If the plugin manager is going to register signals.
    :type container: String
    :param container: The name of the plugin manager container.
    :type prefix_paths: List
    :param prefix_paths: The list of manager path relative paths to be used as reference for sub-projects.
    :type daemon_pid: int
    :param daemon_pid: The pid of the daemon process running the instance of plugin manager.
    :type daemon_file_path: String
    :param daemon_file_path: The file path to the daemon file, for information control.
    :rtype: int
    :return: The return code.
    """

    # sets the plugin manager as a global variable, this value
    # may be used in more situations that the one defined in the
    # the current (local) scope
    global plugin_manager

    # checks if the library path is not valid, by splitting its
    # value around the separator token into a valid list
    if library_path: library_paths = library_path.split(";")
    else: library_paths = []

    # checks if the meta path is not valid, by splitting its
    # value around the separator token into a valid list
    if meta_path: meta_paths = meta_path.split(";")
    else: meta_paths = []

    # checks if the plugin path is not valid, by splitting its
    # value around the separator token into a valid list
    if plugin_path: plugin_paths = plugin_path.split(";")
    else: plugin_paths = []

    # retrieves the current executing platform, so that this
    # value may be passed to the next functions to be called
    # as part of this execution stack
    platform = colony.get_environment()

    # runs the ensure operation for the currently defined manager
    # path making sure that the complete directory structure exists
    colony.ensure_tree(manager_path)

    # creates the plugin manager with the given plugin paths, this
    # is the instance that is going to be used for the current loading
    plugin_manager = colony.PluginManager(
        manager_path=manager_path,
        logger_path=logger_path,
        library_paths=library_paths,
        meta_paths=meta_paths,
        plugin_paths=plugin_paths,
        platform=platform,
        init_complete_handlers=[],
        stop_on_cycle_error=stop_on_cycle_error,
        loop=loop,
        threads=threads,
        signals=signals,
        layout_mode=layout_mode,
        run_mode=run_mode,
        container=container,
        prefix_paths=prefix_paths,
        daemon_pid=daemon_pid,
        daemon_file_path=daemon_file_path)

    # resolves the string based level into the proper integer
    # that describes the logging level and then uses that value
    # to start the logging infra-structure of colony
    level = colony.getLevelName(level)
    plugin_manager.start_logger(level)

    # creates the callback function to be used in the process of
    # printing the branding information text to the standard output
    # informing the end user about the current environment
    callback = lambda: print_information()

    # starts and loads the plugin system, this is a blocking
    # call and the flow control is only returned at the end of
    # the execution of the colony infra-structure, then the
    # returned code is returned to the caller function
    return_code = plugin_manager.load_system(mode=mode,
                                             args=margs,
                                             callback=callback)
    return return_code
Beispiel #2
0
def resolve_manager(path, ensure=True):
    manager_path = colony.resolve_manager(path)
    if ensure: colony.ensure_tree(manager_path)
    return manager_path
Beispiel #3
0
def run(
    manager_path,
    logger_path,
    library_path,
    meta_path,
    plugin_path,
    mode = None,
    margs = [],
    level = "WARNING",
    layout_mode = "default",
    run_mode = "default",
    stop_on_cycle_error = True,
    loop = False,
    threads = True,
    signals = True,
    container = "default",
    prefix_paths = [],
    daemon_pid = None,
    daemon_file_path = None
):
    """
    Starts the loading of the plugin manager. This should be the
    primary start point of the plugin system when starting it as
    a stand alone process (eg: not using wsgi).

    @type manager_path: String
    @param manager_path: The manager base path for execution.
    @type logger_path: String
    @param logger_path: The manager base path for logger.
    @type library_path: String
    @param library_path: The set of paths to the various library
    locations separated by a semi-column.
    @type meta_path: String
    @param meta_path: The set of paths to the various meta
    locations separated by a semi-column.
    @type plugin_path: String
    @param plugin_path: The set of paths to the various plugin
    locations separated by a semi-column.
    @type mode: String
    @param mode: The mode that is going to be used for non
    standard execution of the plugin manager (eg: testing). This
    value is not set by default (for default execution).
    @type margs: List
    @param margs: The arguments (coming from command line) that
    are going to be provided at execution time to the function
    responsible for the mode execution, these arguments should
    consist on a series of string based values.
    @type level: String
    @param level: The logging level described as a string that is
    going to be used by the underlying colony logging infra-structure.
    @type layout_mode: String
    @param layout_mode: The layout mode to be used by the plugin system.
    @type run_mode: String
    @param run_mode: The run mode to be used by the plugin
    system, this value is critical for the type of execution
    of the colony system (eg: development, runtime, etc.)
    @type stop_on_cycle_error: bool
    @param stop_on_cycle_error: If the plugin system should stop
    on cycle error, a cycle error is an error that occurs during
    the startup process of the colony infra-structure.
    @type loop: bool
    @param loop: If the plugin manager is going to run in a loop.
    @type threads: bool
    @param threads: If the plugin manager is going to allow threads.
    @type signals: bool
    @param signals: If the plugin manager is going to register signals.
    @type container: String
    @param container: The name of the plugin manager container.
    @type prefix_paths: List
    @param prefix_paths: The list of manager path relative paths to be used as reference for sub-projects.
    @type daemon_pid: int
    @param daemon_pid: The pid of the daemon process running the instance of plugin manager.
    @type daemon_file_path: String
    @param daemon_file_path: The file path to the daemon file, for information control.
    @rtype: int
    @return: The return code.
    """

    # sets the plugin manager as a global variable, this value
    # may be used in more situations that the one defined in the
    # the current (local) scope
    global plugin_manager

    # checks if the library path is not valid, by splitting its
    # value around the separator token into a valid list
    if library_path: library_paths = library_path.split(";")
    else: library_paths = []

    # checks if the meta path is not valid, by splitting its
    # value around the separator token into a valid list
    if meta_path: meta_paths = meta_path.split(";")
    else: meta_paths = []

    # checks if the plugin path is not valid, by splitting its
    # value around the separator token into a valid list
    if plugin_path: plugin_paths = plugin_path.split(";")
    else: plugin_paths = []

    # retrieves the current executing platform, so that this
    # value may be passed to the next functions to be called
    # as part of this execution stack
    platform = colony.get_environment()

    # runs the ensure operation for the currently defined manager
    # path making sure that the complete directory structure exists
    colony.ensure_tree(manager_path)

    # creates the plugin manager with the given plugin paths, this
    # is the instance that is going to be used for the current loading
    plugin_manager = colony.PluginManager(
        manager_path = manager_path,
        logger_path = logger_path,
        library_paths = library_paths,
        meta_paths = meta_paths,
        plugin_paths = plugin_paths,
        platform = platform,
        init_complete_handlers = [],
        stop_on_cycle_error = stop_on_cycle_error,
        loop = loop,
        threads = threads,
        signals = signals,
        layout_mode = layout_mode,
        run_mode = run_mode,
        container = container,
        prefix_paths = prefix_paths,
        daemon_pid = daemon_pid,
        daemon_file_path = daemon_file_path
    )

    # resolves the string based level into the proper integer
    # that describes the logging level and then uses that value
    # to start the logging infra-structure of colony
    level = colony.getLevelName(level)
    plugin_manager.start_logger(level)

    # creates the callback function to be used in the process of
    # printing the branding information text to the standard output
    # informing the end user about the current environment
    callback = lambda: print_information()

    # starts and loads the plugin system, this is a blocking
    # call and the flow control is only returned at the end of
    # the execution of the colony infra-structure, then the
    # returned code is returned to the caller function
    return_code = plugin_manager.load_system(
        mode = mode,
        args = margs,
        callback = callback
    )
    return return_code
Beispiel #4
0
excluded from the auto parsing of parameters """

# retrieves the base path for the current file and uses
# it to insert it in the current system path in case it's
# not already present (required for module importing)
base_path = os.path.dirname(__file__)
if not base_path in sys.path: sys.path.insert(0, base_path)

import colony

# runs the resolution process in order to be able to retrieve
# the "real" a "best" match for the manager path, this method
# should decide between the personal and the master versions
# then ensures that the proper directory tree is created
manager_path = colony.resolve_manager(base_path)
colony.ensure_tree(manager_path)

# registers the ignore flag in the deprecation warnings so that
# no message with this kind of warning is printed (clean console)
warnings.filterwarnings("ignore", category=DeprecationWarning)

# retrieves the layout mode that is going to be used for the
# resolution of resources in the colony infra-structure
layout_mode = colony.conf("LAYOUT_MODE", "default")

# tries to retrieve the run mode from the currently set
# environment variables, in case of failure defaults to
# the default value (as expected by the specification)
run_mode = colony.conf("RUN_MODE", "development")

# tries to retrieve the prefix to be used to shorten the path
Beispiel #5
0
excluded from the auto parsing of parameters """

# retrieves the base path for the current file and uses
# it to insert it in the current system path in case it's
# not already present (required for module importing)
base_path = os.path.dirname(__file__)
if not base_path in sys.path: sys.path.insert(0, base_path)

import colony

# runs the resolution process in order to be able to retrieve
# the "real" a "best" match for the manager path, this method
# should decide between the personal and the master versions
# then ensures that the proper directory tree is created
manager_path = colony.resolve_manager(base_path)
colony.ensure_tree(manager_path)

# registers the ignore flag in the deprecation warnings so that
# no message with this kind of warning is printed (clean console)
warnings.filterwarnings("ignore", category = DeprecationWarning)

# retrieves the layout mode that is going to be used for the
# resolution of resources in the colony infra-structure
layout_mode = colony.conf("LAYOUT_MODE", "default")

# tries to retrieve the run mode from the currently set
# environment variables, in case of failure defaults to
# the default value (as expected by the specification)
run_mode = colony.conf("RUN_MODE", "development")

# tries to retrieve the prefix to be used to shorten the path