Module mfplugin.utils

Functions

def cerberus_errors_to_human_string(v_errors)
def get_app_class(app_class_arg, default)
def get_class_from_fqn(class_fqn)
def get_configuration_class(configuration_class_arg, default)
def get_configuration_path(plugin_home)
def get_configuration_paths(plugin_name, plugin_home)
def get_current_envs(plugin_name, plugin_home)
def get_default_plugins_base_dir()

Return the default plugins base directory path.

This value correspond to the content of MFMODULE_PLUGINS_BASE_DIR env var or ${RUNTIME_HOME}/var/plugins (if not set).

Returns

(string): the default plugins base directory path.

def get_extra_daemon_class(extra_daemon_class_arg, default)
def get_nice_dump(val)
def get_plugin_lock_path()
def inside_a_plugin_env()

Return True if we are inside a plugin_env.

Returns

(boolean): True if we are inside a plugin_env, False else

def is_jsonable(x)
def layerapi2_label_file_to_plugin_name(llf_path)

Get the plugin name from the layerapi2 label file.

Args

llf_path : string
the layerapi2 label file path from which we extract the label.

Returns

(string): the plugin name.

def layerapi2_label_to_plugin_home(plugins_base_dir, label)

Find the plugin home corresponding to the given layerapi2 label.

We search in plugins_base_dir for a directory (not recursively) with the corresponding label value.

If we found nothing, None is returned.

Args

plugins_base_dir : string
plugins base dir to search.
label : string
the label to search.

Returns

(string): plugin home (absolute directory path) or None.

def layerapi2_label_to_plugin_name(label)

Get the plugin name from the layerapi2 label.

Args

label : string
the label from which we extract the plugin name.

Returns

(string): the plugin name.

def null_to_empty(value)
def plugin_name_to_layerapi2_label(plugin_name)

Get a layerapi2 label from a plugin name.

Args

plugin_name : string
the plugin name from which we create the label.

Returns: (string): the layerapi2 label.

def resolve(val)
def to_bool(strng)
def to_int(strng)
def validate_configparser(v, cpobj, schema, public=False)
def validate_plugin_name(plugin_name)

Validate a plugin name.

Args

plugin_name : string
the plugin name to validate.

Raises

BadPluginName exception if the plugin_name is incorrect.

Classes

class AlreadyInstalledPlugin (msg=None, validation_errors=None, original_exception=None, **kwargs)

Exception raised when a plugin is already installed.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class AlreadyInstalledPlugin(MFPluginException):
    """Exception raised when a plugin is already installed."""

    pass

Ancestors

  • MFPluginException
  • mfutil.bash_wrapper.BashWrapperException
  • builtins.Exception
  • builtins.BaseException
class BadPlugin (msg=None, validation_errors=None, **kwargs)

Exception raised when a plugin is badly constructed.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class BadPlugin(MFPluginException):
    """Exception raised when a plugin is badly constructed."""

    def __init__(self, msg=None, validation_errors=None, **kwargs):
        if msg is not None:
            self.message = msg
        else:
            self.message = "bad plugin!"
        MFPluginException.__init__(self, self.message, **kwargs)
        self.validation_errors = validation_errors

    def __repr__(self):
        if self.validation_errors is None:
            return MFPluginException.__repr__(self)
        return "%s exception with message: %s and validation errors: %s" % \
            (self.__class__.__name__, self.message, self.validation_errors)

    def __str__(self):
        return self.__repr__()

Ancestors

  • MFPluginException
  • mfutil.bash_wrapper.BashWrapperException
  • builtins.Exception
  • builtins.BaseException

Subclasses

class BadPluginConfiguration (msg=None, validation_errors=None, **kwargs)

Exception raised when a plugin has a bad configuration.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class BadPluginConfiguration(BadPlugin):
    """Exception raised when a plugin has a bad configuration."""

    pass

Ancestors

class BadPluginFile (msg=None, validation_errors=None, original_exception=None, **kwargs)

Exception raised when a plugin file is bad.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class BadPluginFile(MFPluginException):
    """Exception raised when a plugin file is bad."""

    pass

Ancestors

  • MFPluginException
  • mfutil.bash_wrapper.BashWrapperException
  • builtins.Exception
  • builtins.BaseException
class BadPluginName (msg=None, validation_errors=None, **kwargs)

Exception raised when a plugin has an invalid name.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class BadPluginName(BadPlugin):
    """Exception raised when a plugin has an invalid name."""

    pass

Ancestors

class CantBuildPlugin (msg=None, validation_errors=None, original_exception=None, **kwargs)

Exception raised when we can't build a plugin.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class CantBuildPlugin(MFPluginException):
    """Exception raised when we can't build a plugin."""

    pass

Ancestors

  • MFPluginException
  • mfutil.bash_wrapper.BashWrapperException
  • builtins.Exception
  • builtins.BaseException
class CantInstallPlugin (msg=None, validation_errors=None, original_exception=None, **kwargs)

Exception raised when we can't install a plugin.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class CantInstallPlugin(MFPluginException):
    """Exception raised when we can't install a plugin."""

    pass

Ancestors

  • MFPluginException
  • mfutil.bash_wrapper.BashWrapperException
  • builtins.Exception
  • builtins.BaseException
class CantUninstallPlugin (msg=None, validation_errors=None, original_exception=None, **kwargs)

Exception raised when we can't uninstall a plugin.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class CantUninstallPlugin(MFPluginException):
    """Exception raised when we can't uninstall a plugin."""

    pass

Ancestors

  • MFPluginException
  • mfutil.bash_wrapper.BashWrapperException
  • builtins.Exception
  • builtins.BaseException
class MFPluginException (msg=None, validation_errors=None, original_exception=None, **kwargs)

Base mfplugin Exception class.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class MFPluginException(BashWrapperException):
    """Base mfplugin Exception class."""

    def __init__(self, msg=None, validation_errors=None,
                 original_exception=None, **kwargs):
        if msg is not None:
            self.message = msg
        else:
            self.message = "mfplugin exception!"
        if original_exception is not None:
            BashWrapperException.__init__(
                self,
                self.message + (": %s" % original_exception),
                **kwargs)
        else:
            BashWrapperException.__init__(self, self.message, **kwargs)
        self.original_exception = original_exception

Ancestors

  • mfutil.bash_wrapper.BashWrapperException
  • builtins.Exception
  • builtins.BaseException

Subclasses

class NotInstalledPlugin (msg=None, validation_errors=None, original_exception=None, **kwargs)

Exception raised when a plugin is not installed.

Constructor.

Args

message : string
exception message
bash_wrapper : BashWrapper
bash wrapper object
Expand source code
class NotInstalledPlugin(MFPluginException):
    """Exception raised when a plugin is not installed."""

    pass

Ancestors

  • MFPluginException
  • mfutil.bash_wrapper.BashWrapperException
  • builtins.Exception
  • builtins.BaseException