Skip to content

Utilities

Note

These utilities are only those maintained by the MetWork project.

You can find many others provided by other components.

1. Core layers

Note

These utilities are located in core/minimal layers. So they are nearly always available.

1.1 outside

$ outside --help
usage: outside COMMAND COMMAND_ARG1 COMMAND_ARG2 ...
  => execute the given command outside the metwork environement

1.2 components

$ components --help
usage: components [-h] [--module MODULE] [--layer LAYER] [--name NAME]
                  [--loaded-filter LOADED_FILTER] [--raw] [--json]
                  [--without-versions] [--full]

list installed/loaded components

options:
  -h, --help            show this help message and exit
  --module MODULE       filter output for this module only
  --layer LAYER         filter output for this layer only
  --name NAME           filter output for this component only
  --loaded-filter LOADED_FILTER
                        loaded layer filter (default: no filter, possible
                        values: yes, no)
  --raw                 raw output (can't be used with json option)
  --json                json output (can't be used with raw option)
  --without-versions    remove versions in output (ignored with json or raw
                        options)
  --full                add all informations (bigger, can't be used with raw
                        option)

1.3 layers

$ layers --help
Usage:
  layers [OPTION…] - list installed layers

Help Options:
  -h, --help              Show help options

Application Options:
  -r, --raw               raw output
  -m, --loaded-filter     Loaded layer filter (default: no filter, possible values: yes, no)

1.4 plugin_wrapper

$ plugin_wrapper --help
usage: plugin_wrapper [-h] [--cwd] [--empty] [--bash-cmds]
                      [--plugins-base-dir PLUGINS_BASE_DIR] [--ignore-cache]
                      PLUGIN_NAME_OR_PLUGIN_HOME COMMAND_AND_ARGS

execute a command in a plugin environment

positional arguments:
  PLUGIN_NAME_OR_PLUGIN_HOME
                        plugin name or plugin home (if starting by /)
  COMMAND_AND_ARGS      command (and args) to execute

options:
  -h, --help            show this help message and exit
  --cwd                 change working directory to plugin home
  --empty               unload all layers before
  --bash-cmds           if set don't execute command but output bash cmds to
                        be execute in a fresh empty shell (--empty and
                        COMMAND_AND_ARGS ignored)
  --plugins-base-dir PLUGINS_BASE_DIR
                        can be use to set an alternate plugins-base-dir, if
                        not set the value of MFMODULE_PLUGINS_BASE_DIR env var
                        is used (or a hardcoded standard value).
  --ignore-cache        if set, don't use env cache

1.5 mfext_wrapper

$ mfext_wrapper --help
usage: /opt/metwork-mfext-master/bin/mfext_wrapper COMMAND_TO_WRAP [COMMAND_ARG1] [COMMAND_ARG2] [...]
  => launch the given command within metwork/mfext environnent
  => note: the current environnent is cleared before
  =>       (only MFMODULE_RUNTIME_SUFFIX, MFMODULE_RUNTIME_HOME and some standard env var (HOME, TERM, DISPLAY...) 
            are keeped intact)

1.6 metwork_debug

$ metwork_debug --help
usage: metwork_debug
       print debug informations on stdout

1.7 log

$ log --help
usage: log a message with standard metwork logging system [-h]
                                                          [--application-name APPLICATION_NAME]
                                                          {ERROR,CRITICAL,WARNING,INFO,DEBUG}
                                                          MESSAGE

positional arguments:
  {ERROR,CRITICAL,WARNING,INFO,DEBUG}
                        Log level
  MESSAGE               message to log

options:
  -h, --help            show this help message and exit
  --application-name APPLICATION_NAME, -a APPLICATION_NAME
                        application name

1.8 echo_ok

$ echo_ok --help
Usage:
  echo_ok [OPTION…] [MESSAGE] - write OK (with colors if supported) and a little optional message

Help Options:
  -h, --help       Show help options

1.9 echo_bold

$ echo_bold --help
Usage:
  echo_bold [OPTION…] [MESSAGE] - write MESSAGE in bold

Help Options:
  -h, --help       Show help options

1.10 echo_clean

$ echo_clean --help
Usage:
  echo_clean [OPTION…]  - clean waiting status

Help Options:
  -h, --help       Show help options

1.11 echo_nok

$ echo_nok --help
Usage:
  echo_nok [OPTION…] [MESSAGE] - write ERROR (with colors if supported) and a little optional message

Help Options:
  -h, --help       Show help options

1.12 echo_warning

$ echo_warning --help
Usage:
  echo_warning [OPTION…] [MESSAGE] - write WARNING (with colors if supported) and a little optional message

Help Options:
  -h, --help       Show help options

1.13 echo_running

$ echo_running --help
Usage:
  echo_running [OPTION…] - write RUNNING (with colors if supported)

Help Options:
  -h, --help       Show help options

1.14 is_interactive

$ is_interactive --help
Usage:
  is_interactive [OPTION…] - return status code 0 if we guess this is an interactive execution

Help Options:
  -h, --help       Show help options

1.15 is_layer_installed

$ is_layer_installed --help
Usage:
  is_layer_installed [OPTION…] LAYER LABEL - output 1 is the given layer is installed

Help Options:
  -h, --help       Show help options

1.16 is_layer_loaded

$ is_layer_loaded --help
Usage:
  is_layer_loaded [OPTION…] LAYER LABEL OR LAYER HOME - output 1 is the given layer is already loaded

Help Options:
  -h, --help       Show help options

1.17 layer_wrapper

$ layer_wrapper --help
Usage:
  layer_wrapper [OPTION…] -- COMMAND [COMMAND_ARG1] [COMMAND_ARG2] [...] - wrapper to execute the given command in a process with some specific layers loaded

Help Options:
  -h, --help                 Show help options

Application Options:
  -d, --debug                debug mode
  -e, --empty                unload all layers before
  -c, --cwd                  change working directory to the last layer home
  -x, --extra-env-prefix     if set, add three environnement variables {PREFIX}_NAME, {PREFIX}_LABEL and {PREFIX}_DIR containing the last layer name, label and the last layer home 
  -E, --empty-env            empty environnement (imply --empty)
  -k, --empty-env-keeps      coma separated list of env var to keep with --empty-env
  -l, --layers               coma separated list of layers labels/homes ('-' before the name of the layer means 'optional dependency')
  -p, --prepend-env          ENV_VAR,VALUE string to prepend VALUE in : separated ENV_VAR (like PATH) (can be used multiple times)
  -f, --force-prepend        do not check existing paths in prepend
  --dont-load-optional       don't load optional layers

1.18 log_proxy

$ log_proxy --help
Usage:
  log_proxy [OPTION…] LOGFILE  - log proxy

Help Options:
  -h, --help                Show help options

Application Options:
  -s, --rotation-size       maximum size (in bytes) for a log file before rotation (0 => no maximum, default: content of environment variable LOGPROXY_ROTATION_SIZE or 104857600 = 100MB)
  -t, --rotation-time       maximum lifetime (in seconds) for a log file before rotation (0 => no maximum, default: content of environment variable LOGPROXY_ROTATION_TIME or 86400 = 24 hours)
  -S, --rotation-suffix     strftime based suffix to append to rotated log files (default: content of environment variable LOGPROXY_ROTATION_SUFFIX or .%Y%m%d%H%M%S)
  -d, --log-directory       directory to store log files (default: content of environment variable LOGPROXY_LOG_DIRECTORY or current directory), directory is created if missing
  -n, --rotated-files       maximum number of rotated files to keep including main one (0 => no cleaning, default: content of environment variable LOGPROXY_ROTATED_FILES or 5)
  -T, --timestamps          strftime prefix to prepend to every output line, for example '[%F %T] ' (default: content of environment variable LOGPROXY_TIMESTAMPS or none)
  -c, --chmod               if set, change mode of log files to this octal value, '0600' for example (default: content of environment variable LOGPROXY_CHMOD or don't change mode)
  -o, --chown               if set, try (if you don't have sufficient privileges, it will fail silently) to change the owner of the logfile to the given user value
  -g, --chgrp               if set, try (if you don't have sufficient privileges, it will fail silently) to change the group of the logfile to the given group value
  -m, --use-locks           use locks to append to main log file (useful if several process writes to the same file)
  -f, --fifo                if set, read lines on this fifo instead of stdin
  -r, --rm-fifo-at-exit     if set, drop fifo at then end of the program (you have to use --fifo option of course)

Optional environment variables to override defaults: 
    LOGPROXY_ROTATION_SIZE
    LOGPROXY_ROTATION_TIME
    LOGPROXY_ROTATION_SUFFIX
    LOGPROXY_LOG_DIRECTORY
    LOGPROXY_ROTATED_FILES
    LOGPROXY_TIMESTAMPS

Example for rotation-size option:
- If log_proxy is run with the option --rotation-size on the command line, rotation-size will take the provided value
- If the option --rotation-size is not provided on command line :
  - If the environment variable LOGPROXY_ROTATION_SIZE is set, rotation-size will take this value
  - If the environment variable LOGPROXY_ROTATION_SIZE is not set, rotation-size will take the default value 104857600

1.19 log_proxy_wrapper

$ log_proxy_wrapper --help
Usage:
  log_proxy_wrapper [OPTION…] -- COMMAND [COMMAND_ARG1] [COMMAND_ARG2] [...] - log proxy

Help Options:
  -h, --help                Show help options

Application Options:
  -s, --rotation-size       maximum size (in bytes) for a log file before rotation (0 => no maximum, default: content of environment variable LOGPROXY_ROTATION_SIZE or 104857600 = 100MB)
  -t, --rotation-time       maximum lifetime (in seconds) for a log file before rotation (0 => no maximum, default: content of environment variable LOGPROXY_ROTATION_TIME or 86400 = 24 hours)
  -S, --rotation-suffix     strftime based suffix to append to rotated log files (default: content of environment variable LOGPROXY_ROTATION_SUFFIX or .%Y%m%d%H%M%S)
  -d, --log-directory       directory to store log files (default: content of environment variable LOGPROXY_LOG_DIRECTORY or current directory), directory is created if missing
  -n, --rotated-files       maximum number of rotated files to keep including main one (0 => no cleaning, default: content of environment variable LOGPROXY_ROTATED_FILES or 5)
  -T, --timestamps          strftime prefix to prepend to every output line, for example '[%F %T] ' (default: content of environment variable LOGPROXY_TIMESTAMPS or none)
  -c, --chmod               if set, change mode of log files to this octal value, '0600' for example (default: content of environment variable LOGPROXY_CHMOD or don't change mode)
  -o, --chown               if set, try (if you don't have sufficient privileges, it will fail silently) to change the owner of the logfile to the given user value
  -g, --chgrp               if set, try (if you don't have sufficient privileges, it will fail silently) to change the group of the logfile to the given group value
  -m, --use-locks           use locks to append to main log file (useful if several process writes to the same file)
  -O, --stdout              stdout file path (NULL string (default) can be used to redirect to /dev/null)
  -E, --stderr              stderr file path (STDOUT string (default) can be used to redirect to the same file than stdout)
  -F, --fifo-tmp-dir        directory where to store tmp FIFO for log_proxy (default: content of environment variable TMPDIR if set, /tmp if not)

1.20 unsafe_pip

$ unsafe_pip --help
usage: unsafe_pip PIP_ARGUMENTS
  => this is a simple pip wrapper to use when you are annoyed with
     man-in-the-middle https proxies
  => use it like standard pip cli tool
  => WARNING: it adds some unsafe options

1.21 get_unique_hexa_identifier

$ get_unique_hexa_identifier --help
Usage:
  get_unique_hexa_identifier [OPTION…] - return a unique hexa identifier

Help Options:
  -h, --help       Show help options

1.22 get_layer_home

$ get_layer_home --help
Usage:
  get_layer_home [OPTION…] LAYER LABEL - print corresponding layer home

Help Options:
  -h, --help       Show help options

1.23 get_simple_hostname

$ get_simple_hostname --help
usage: get_simple_hostname [-h]

returns the 'simple' hostname (without network domain)

options:
  -h, --help  show this help message and exit

1.24 get_full_hostname

$ get_full_hostname --help
usage: get_full_hostname [-h]

returns the 'full' hostname (with network domain)

options:
  -h, --help  show this help message and exit

1.25 get_domainname

$ get_domainname --help
usage: get_domainname [-h]

returns the network domain

options:
  -h, --help  show this help message and exit

1.26 get_real_ip

$ get_real_ip --help
usage: get_real_ip [-h]

returns the 'real' ip (not 127.0.0.1)

options:
  -h, --help  show this help message and exit

1.27 get_ip_for_hostname

$ get_ip_for_hostname --help
usage: get_ip_for_hostname [-h] [hostname]

returns the IP address of the given HOSTNAME (current real IP if no hostname
is given)

positional arguments:
  hostname    hostname to resolve as ip (can be empty)

options:
  -h, --help  show this help message and exit

2. Python3 layers

Note

These utilities are only available when "python3" layers are loaded.

2.1 python3_wrapper

$ python3_wrapper --help
usage: python3_wrapper [PYTHON_ARGS]
  => launch a python3 command inside a python3 env

3. Dev layers

Note

These utilities are only available when the "devtools" layers is loaded.

3.1 flake8.sh

3.2 flake8.sh

$ flake8.sh --help
usage: flake8.sh [FLAKE8_ARG1] [FLAGE8_ARG2] [...]
  => execute flake8 command with given args in a python3 env
  => some documentation errors/hints are also ignored here

3.3 pylint.sh

3.4 pylint.sh

$ pylint.sh --help
usage: pylint.sh [PYLINT_ARG1] [PYLINT_ARG2] [...]
  => execute pylint command with given args in a python3 env

3.5 nosetests.sh

3.6 nosetests.sh

$ nosetests.sh --help
usage: nosetests.sh [NOSETESTS_ARG1] [NOSETESTS_ARG2] [...]
  => execute nosetests command with given args in a python3 env

3.7 shellchecks

$ shellchecks --help
execute shellcheck on every shell script files found in the current directory
usage: shellchecks

3.8 test_globals_in_lua.sh

$ test_globals_in_lua.sh --help
usage: test_globals_in_lua.sh LUA_FILE
 => test if there are some global variables in the given lua file
    and exit with an error code if there are some.
 => you can also provide a pattern like *.lua as argument
 => if no global variables are found in lua files, exit with 0 return
    code

3.9 noutf8.sh

$ noutf8.sh --help
usage: noutf8.sh
  => find utf8 (non ascii) characters in the current directory
     (and exit 1 if found some)