utils
#
Description#
A plugin for general-purpose util methods
Configuration#
utils:
# No configuration required
Actions#
Module reference#
- class platypush.plugins.utils.UtilsPlugin(**kwargs)[source]#
Bases:
Plugin
A plugin for general-purpose util methods
- clear_interval(name)[source]#
Clear a running interval procedure
- Parameters:
name (str) – Name of the interval to clear
- clear_timeout(name)[source]#
Clear a pending timeout procedure
- Parameters:
name (str) – Name of the timeout to clear
- get_enabled_plugins() dict [source]#
- Returns:
The list of enabled plugins as a
name -> configuration
map.
- get_interval(name)[source]#
Get info about a running interval
- Parameters:
name (str) – Name of the interval to get
- Returns:
dict. Example:
{ "test_interval": { "seconds": 10.0, "actions": [ { "action": "action_1", "args": { "name_1": "value_1" } } ] } }
If no such interval exist with the specified name then the value of the timeout name will be null.
- get_intervals()[source]#
Get info about the running intervals
- Returns:
dict
Example:
{ "test_interval": { "seconds": 10.0, "actions": [ { "action": "action_1", "args": { "name_1": "value_1" } } ] } }
- get_timeout(name)[source]#
Get info about a pending timeout
- Parameters:
name (str) – Name of the timeout to get
- Returns:
dict
Example:
{ "test_timeout": { "seconds": 10.0, "actions": [ { "action": "action_1", "args": { "name_1": "value_1" } } ] } }
If no such timeout exist with the specified name then the value of the timeout name will be null.
- get_timeouts()[source]#
Get info about the pending timeouts
- Returns:
dict.
Example:
{ "test_timeout": { "seconds": 10.0, "actions": [ { "action": "action_1", "args": { "name_1": "value_1" } } ] } }
- rst_to_html(text: str)[source]#
Utility action to convert RST to HTML.
It is mostly used by the frontend to render the docstring of the available plugins and actions.
- set_interval(seconds, actions, name=None, **args)[source]#
Define a set of actions to run each specified amount of seconds.
- Parameters:
seconds (float) – Number of seconds between two runs of the interval procedure
actions (list[dict]) – List of actions to be executed at each interval
name (str) – Set an optional name for this interval. It is advised to set a name if you are planning to programmatically cancel the interval in your business logic.
args – Optional arguments/context to pass to the interval function
- set_timeout(seconds, actions, name=None, **args)[source]#
Define a set of actions to run after the specified amount of seconds.
- Parameters:
seconds (float) – Number of seconds before running the timeout procedure
actions (list[dict]) – List of actions to be executed after the timeout expires
name (str) – Set an optional name for this timeout. It is advised to set a name if you are planning to programmatically cancel the timeout in your business logic.
args – Optional arguments/context to pass to the timeout function