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
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
alias_path = colony.conf("ALIAS_PATH", None) alias_path = alias_path and os.path.expanduser(alias_path) alias_path = alias_path and os.path.normpath(alias_path) # gathers the path to the rewrite file that contains JSON information # about the rewrite meta information to be used at runtime to shorten # the provided URL path values (useful under proxy redirection) rewrite_path = colony.conf("REWRITE_PATH", None) rewrite_path = rewrite_path and os.path.expanduser(rewrite_path) rewrite_path = rewrite_path and os.path.normpath(rewrite_path) # retrieves the (verbosity) level for the debugger using the provided # configuration support, defaulting to the default level in case the # value is not provided through configuration level = colony.conf("LEVEL", logging.INFO) level = colony.getLevelName(level) # retrieves the complete set of configuration variables associated # with the various paths to be used by colony, these are going to # be used as the initial values for the various path lists meta_paths = colony.conf("META_PATH", [], cast=list) plugin_paths = colony.conf("PLUGIN_PATH", [], cast=list) # tries to retrieve the configuration file from the environment # variable associated in case it fails uses the default configuration # file path then joins the "relative" file path to the base path # and resolves it as an absolute path config_file_path = colony.conf(CONFIG_FILE_ENV, None) or DEFAULT_CONFIG_PATH config_file_path = os.path.join(manager_path, config_file_path) config_file_path = os.path.abspath(config_file_path)
alias_path = colony.conf("ALIAS_PATH", None) alias_path = alias_path and os.path.expanduser(alias_path) alias_path = alias_path and os.path.normpath(alias_path) # gathers the path to the rewrite file that contains json information # about the rewrite meta information to be used at runtime to shorten # the provided url path values (useful under proxy redirection) rewrite_path = colony.conf("REWRITE_PATH", None) rewrite_path = rewrite_path and os.path.expanduser(rewrite_path) rewrite_path = rewrite_path and os.path.normpath(rewrite_path) # retrieves the (verbosity) level for the debugger using the provided # configuration support, defaulting to the default level in case the # value is not provided through configuration level = colony.conf("LEVEL", logging.INFO) level = colony.getLevelName(level) # retrieves the complete set of configuration variables associated # with the various paths to be used by colony, these are going to # be used as the initial values for the various path lists meta_paths = colony.conf("META_PATH", [], cast = list) plugin_paths = colony.conf("PLUGIN_PATH", [], cast = list) # tries to retrieve the configuration file from the environment # variable associated in case it fails uses the default configuration # file path then joins the "relative" file path to the base path # and resolves it as an absolute path config_file_path = colony.conf(CONFIG_FILE_ENV, None) or DEFAULT_CONFIG_PATH config_file_path = os.path.join(manager_path, config_file_path) config_file_path = os.path.abspath(config_file_path)