5. MFUTIL API

which are note in current modules, during documentation build.

mfutil

Generic utility classes and functions.

mfutil.net

Utility functions around network.

mfutil.plugins

Utility classes and functions for managing Metwork plugins.

mfutil.cli

Utility functions to build CLI.

mfutil.jinja2_extensions

mfutil.layerapi2

Utility functions around layerapi2.

5.1. mfutil Package

Generic utility classes and functions.

5.1.1. Functions

add_inotify_watch(inotify, directory[, ignores])

Register recursively directories to watch.

create_tmp_dirpath([tmp_dir, prefix])

Create and return a temporary directory inside a father tempory directory.

get_ipv4_for_hostname(hostname[, …])

Translate a host name to IPv4 address format.

get_recursive_mtime(directory[, ignores])

Get the latest mtime recursivly on a directory.

get_tmp_filepath([tmp_dir, prefix])

Return a tmp (complete) filepath.

get_unique_hexa_identifier()

Return an unique hexa identifier on 32 bytes.

get_utc_unix_timestamp()

Return the current unix UTC timestamp on all platforms.

hash_generator(*args)

Generate a hash from a variable number of arguments as a safe string.

kill_process_and_children(pid)

Kill recursively a complete tree of processes.

mkdir_p(path[, nodebug, nowarning])

Make a directory recursively (clone of mkdir -p).

mkdir_p_or_die(path[, nodebug, exit_code])

Make a directory recursively (clone of mkdir -p).

5.1.2. Classes

BashWrapper(bash_cmd)

Bash command/output wrapper.

BashWrapperException(message[, bash_wrapper])

Specific exception class for BashWrapper objects.

BashWrapperOrRaise(bash_cmd[, …])

BashWrapper subclass which raise an exception if status_code != 0.

MFUtilException

Just a custom exception object dedicated for mfutil package.

5.1.3. Class Inheritance Diagram

Inheritance diagram of mfutil.BashWrapper, mfutil.BashWrapperException, mfutil.BashWrapperOrRaise, mfutil.MFUtilException

5.2. mfutil.net Module

Utility functions around network.

5.2.1. Functions

get_domainname([use_resolv_conf, …])

Get the domain name of the server.

get_full_hostname([use_resolv_conf, …])

Return the “full” hostname of the server.

get_ip_for_hostname(hostname[, …])

Get the IP of a given hostname.

get_real_ip()

Try to find and return the real IP of the server.

get_simple_hostname()

Return the “simple” hostname of the server.

ping_tcp_port(host, port[, timeout])

Ping a TCP host/port with a configurable timeout.

5.3. mfutil.plugins Module

Utility classes and functions for managing Metwork plugins.

5.3.1. Functions

build_plugin(plugin_path[, plugins_base_dir])

Build a plugin.

develop_plugin(plugin_path, name[, …])

Install a plugin as dev build.

get_installed_plugins([plugins_base_dir])

Get a detailed list (formatted text) of installed plugins.

get_layer_home_from_plugin_name(plugin_name)

Get the home layer of a plugin.

get_plugin_hash(name_or_filepath[, mode, …])

Get detailed information about a plugin.

get_plugin_info(name_or_filepath[, mode, …])

Get detailed information about a plugin.

get_plugin_lock_path()

get_plugins_base_dir()

Return the default plugins base directory path.

init_plugins_base([plugins_base_dir])

Initialize the plugins base.

inside_a_plugin_env()

Return True if we are inside a plugin_env.

install_plugin(plugin_filepath[, …])

Install a plugin from a .plugin file.

is_dangerous_plugin(name[, plugins_base_dir])

Display is_dangerous_plugin command.

is_plugins_base_initialized([plugins_base_dir])

Return True is the plugins base is already initialized for the module.

layerapi2_label_file_to_plugin_name(llf_path)

Get the plugin name from the layerapi2 label file.

layerapi2_label_to_plugin_name(label)

Get the plugin name from the layerapi2 label.

plugin_name_to_layerapi2_label(plugin_name)

Get a layerapi2 label from a plugin name.

uninstall_plugin(name[, plugins_base_dir, …])

Uninstall a plugin.

validate_plugin_name(plugin_name)

Validate a plugin name.

5.3.2. Classes

MFUtilPluginAlreadyInstalled

Exception class raised when a plugin is already installed.

MFUtilPluginBaseNotInitialized

Exception class raised when the plugin base is not initialized.

MFUtilPluginCantBuild(message[, bash_wrapper])

Exception class raised when we can’t build a plugin.

MFUtilPluginCantInit(message[, bash_wrapper])

Exception class raised when we can’t init the plugin base.

MFUtilPluginCantInstall(message[, bash_wrapper])

Exception class raised when we can’t install a plugin.

MFUtilPluginCantUninstall(message[, …])

Exception class raised when we can’t uninstall a plugin.

MFUtilPluginFileNotFound

Exception class raised when we can’t find the plugin file.

MFUtilPluginInvalid

Exception class raised when the plugin is invalid.

MFUtilPluginNotInstalled

Exception class raised when a plugin is not installed.

PluginsBaseDir([plugins_base_dir])

5.3.3. Variables

MFEXT_HOME

str(object=’‘) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

MODULE

str(object=’‘) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

MODULE_LOWERCASE

str(object=’‘) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

PLUGIN_NAME_REGEXP

str(object=’‘) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

RUNTIME_HOME

str(object=’‘) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

SPEC_TEMPLATE

str(object=’‘) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

5.3.4. Class Inheritance Diagram

Inheritance diagram of mfutil.plugins.MFUtilPluginAlreadyInstalled, mfutil.plugins.MFUtilPluginBaseNotInitialized, mfutil.plugins.MFUtilPluginCantBuild, mfutil.plugins.MFUtilPluginCantInit, mfutil.plugins.MFUtilPluginCantInstall, mfutil.plugins.MFUtilPluginCantUninstall, mfutil.plugins.MFUtilPluginFileNotFound, mfutil.plugins.MFUtilPluginInvalid, mfutil.plugins.MFUtilPluginNotInstalled, mfutil.plugins.PluginsBaseDir

5.4. mfutil.cli Module

Utility functions to build CLI.

5.4.1. Functions

echo_bold(message)

Write a message in bold (if supported).

echo_clean()

Clean waiting status.

echo_nok([message])

Write [ERROR] with colors if supported a little optional message.

echo_ok([message])

Write [OK] with colors if supported a little optional message.

echo_running([message])

Write [RUNNING] with colors if supported.

echo_warning([message])

Write [WARNING] with colors if supported a little optional message.

5.5. mfutil.layerapi2 Module

Utility functions around layerapi2.

5.5.1. Classes

LayerApi2Wrapper

5.5.2. Variables

cdll

5.5.3. Class Inheritance Diagram

Inheritance diagram of mfutil.layerapi2.LayerApi2Wrapper