CPython

Bootstrap the mauzr agent on cpython systems.

class mauzr.platform.cpython.Core(suit, agent, instance=None, parser=None)

Bases: object

Manage program components on cpython platforms.

The core can either be started directly by calling run() or by using it as a context manager. The first case blocks, the second case spawns a thread that is running the scheduler.

Parameters:
  • suit (str) – Suit this agent belongs to.
  • agent (str) – Name of the agent.
  • instance (str) – Instance of this agent. May be None
  • parser (argparse.ArgumentParser) – Argparse instance to use. If None, a new one will be used.
add_context(context)

Add a context to be managed by this core.

Parameters:context (object) – Unit to be added
static logger(name)

Create a logger instance.

Parameters:name (str) – Name of the caller that wants to receive the logger.
Returns:Logger instance.
Return type:logging.Logger
static on_failure()

Call when an unrecoverable failure happens.

Shuts the program down.

run()

Setup modules and units and run the scheduler.

Block until shutdown is requested.

setup_mqtt(cfgbase='mqtt', **kwargs)

Setup the MQTT manager and client.

See mauzr.platform.mqtt.Manager and mauzr.platform.cpython.mqtt.Client. Keyword arguments given to this function are passed to both constructors.

Parameters:
  • cfgbase (str) – Configuration entry for this unit.
  • kwargs (dict) – Keyword arguments that will be merged into the config.
setup_telegram(*args, **kwargs)

Setup a telegram bot.

See mauzr.platform.cpython.telegram.Bot.

shutdown()

Ask the agent to shut down.