platypush.plugins.utils

class platypush.plugins.utils.UtilsPlugin(**kwargs)[source]

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_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"
                }
            }
        ]
    }
}
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
sleep(seconds)[source]

Make the current executor sleep for the specified number of seconds.

Parameters:seconds (float) – Sleep seconds