variable

class platypush.plugins.variable.VariablePlugin(**kwargs)[source]

This plugin allows you to manipulate context variables that can be accessed across your tasks. It requires the platypush.plugins.db and platypush.plugins.redis plugins to be enabled, as the variables will be stored either persisted on a local database or on the local Redis instance.

Requires:

  • sqlalchemy (pip install sqlalchemy)

  • redis (pip install redis)

__init__(**kwargs)[source]

The plugin will create a table named variable on the database configured in the platypush.plugins.db plugin. You’ll have to specify a default engine in your db plugin configuration.

expire(name, expire)[source]

Set a variable expiration on Redis

Parameters
  • name (str) – Variable name

  • expire (int) – Expiration time in seconds

get(name, default_value=None)[source]

Get the value of a variable by name from the local db.

Parameters
  • name (str) – Variable name

  • default_value – What will be returned if the variable is not defined (default: None)

Returns

A map in the format {"<name>":"<value>"}

mget(name)[source]

Get the value of a variable by name from Redis.

Parameters

name (str) – Variable name

Returns

A map in the format {"<name>":"<value>"}

mset(**kwargs)[source]

Set a variable or a set of variables on Redis.

Parameters

kwargs – Key-value list of variables to set (e.g. foo='bar', answer=42)

Returns

A map with the set variables

munset(name)[source]

Unset a Redis variable by name if it’s set

Parameters

name (str) – Name of the variable to remove

set(**kwargs)[source]

Set a variable or a set of variables on the local db.

Parameters

kwargs – Key-value list of variables to set (e.g. foo='bar', answer=42)

unset(name)[source]

Unset a variable by name if it’s set on the local db.

Parameters

name (str) – Name of the variable to remove