btnexus-node-python.btNode module

Blackout Nexus node. Base class for all personality core parts

class btNode.Node(connectHash=None, packagePath=None, rcPath=None, logger=None, debug=None)[source]

Bases: object

Blackout Nexus node

Constructor sets up the NexusConnector.

Parameters
  • token (String) – AccessToken for the btNexus

  • axonURL (String) – URL for the Axon(InstanceURL)

  • debug (bool) – switch for debug messages

  • logger (Logger) – a logger object to log to

  • personalityId (String) – Id of your Personality

  • integrationId (String) – Id of the integration this Node belongs to

NEXUSINFO = 21

Logging level for nexus messages

connect(**kwargs)[source]

Runs this node and listen forever This is a blocking call Uses the kwargs for the socketio.Client see https://python-socketio.readthedocs.io/en/latest/api.html

disconnect()[source]

Closes the connection to the Axon

linkModule(module, group, topic)[source]

EXPERIMENTAL Link a python module to the messaging service This makes every routine of the module accessable as callbacks over the btNexus the routines are checked with inspect.isroutine()

Parameters
  • module (Object) – the module to be linked

  • group (String) – The group the callbacks should subscribe to

  • topic (String) – The topic on callbacks should subscribe to

classmethod nexusFormat(record)[source]
onConnected()[source]

Is called when this node was connected This needs to be overloaded to subscribe to messages.

onDisconnected()[source]

This will be executed after a the Node is disconnected from the btNexus - here Threads can be closed or other variables can be reset.

onError(error)[source]

Handling of Errors. If not overloaded it just forwards the error to the nexusConnector which just prints and publishes it if possible

publish(group, topic, funcName, params)[source]

publishes a Message with the payload(funcName and params) to a topic.

Parameters
  • group (String) – Name of the group

  • topic (String) – Name of the topic

  • funcName (String) – Name of the function.

  • params (List or keywordDict) – The parameters for the callback

publishDebug(debug)[source]

Publish a Debug message on the btNexus if debug is active

Parameters

debug (String) – A Message to send to the debug topic

publishError(error)[source]

Publish a Error message on the btNexus

Parameters

error (String) – A Message to send to the error topic

publishWarning(warning)[source]

Publish a Warning message on the btNexus

Parameters

warning (String) – A Message to send to the warning topic

run()[source]

DEPRECATED: Will be replaced with connect(). Is here for backwards compatibility.

setUp()[source]

Implement this to handle the things, which should be done before the connection to nexus is established. This will also be called for reconnects.

subscribe(group, topic, callback, funcName=None)[source]

Subscribe to a group & topic with a callback

Parameters
  • group (String) – Name of the group

  • topic (String) – Name of the topic

  • callback (function pointer) – function pointer to the callback

  • funcName (String) – Name of the function. If not set this is the name of the function in the implementation(needed if you want to link a function to a different name)

write(error)[source]

This forwards errors to the publishError function to make them visible in the btNexus

Parameters

error (String) – A Message to send to the error topic