shellbot.updaters package¶
Submodules¶
Module contents¶
-
class
shellbot.updaters.
ElasticsearchUpdater
(engine=None, **kwargs)[source]¶ Bases:
shellbot.updaters.base.Updater
Writes inbound events to Elasticsearch
An event may be a Message, a Join or Leave notification, or any other Event.
Updaters expose a filtering function that can be connected to the inbound flow of events handled by the Listener.
Example:
updater = ElasticsearchUpdater(host='db.local:9200') listener = Listener(filter=updater.filter)
-
class
shellbot.updaters.
FileUpdater
(engine=None, **kwargs)[source]¶ Bases:
shellbot.updaters.base.Updater
Writes inbound events to a file
This updater serializes events and write JSON records to a flat file.
An event may be a Message, a Join or Leave notification, or any other Event.
Updaters expose a filtering function that can be connected to the inbound flow of events handled by the Listener.
Example:
updater = FileUpdater(path='/var/log/my_app.log') listener = Listener(filter=updater.filter)
-
class
shellbot.updaters.
QueueUpdater
(engine=None, **kwargs)[source]¶ Bases:
shellbot.updaters.base.Updater
Writes inbound events to a queue
This updater serializes events and write them to a queue.
An event may be a Message, a Join or Leave notification, or any other Event.
Updaters expose a filtering function that can be connected to the inbound flow of events handled by the Listener.
Example:
updater = QueueUpdater(queue=Queue()) listener = Listener(filter=updater.filter)
Of course, some process has to grab content from updater.queue afterwards.
-
class
shellbot.updaters.
SpaceUpdater
(engine=None, **kwargs)[source]¶ Bases:
shellbot.updaters.base.Updater
Replicates messages to a secondary space
-
format
(event)[source]¶ Prepares an outbound line
Parameters: event (Event or Message or Join or Leave) – an inbound event Returns: outbound line Return type: str This function adapts inbound events to the appropriate format. It turns an object with multiple attributes to a single string that can be pushed to a Cisco Spark room.
-
-
class
shellbot.updaters.
Updater
(engine=None, **kwargs)[source]¶ Bases:
object
Handles inbound events
Updaters are useful for logging or replication, or side storage, or achiving, of received events.
An event may be a Message, a Join or Leave notification, or any other Event.
Updaters expose a filtering function that can be connected to the inbound flow of events handled by the Listener.
Example:
updater = FileUpdater(path='/var/log/shellbot.log') listener = Listener(filter=updater.filter)
Here events are written down to a flat file, yet multiple updaters are available.
For example, push every event to Elasticsearch:
updater = ElasticsearchUpdater() listener = Listener(filter=updater.filter)
There is also an updater where events are written to a separate Cisco Spark room. This will be useful in cases where safety or control are specifically important.
We are looking for new updaters, so please have a careful look at this file and consider to submit your own module.
-
filter
(event)[source]¶ Filters events handled by listener
Parameters: event (Event or Message or Join or Leave, etc.) – an event received by listener Returns: a filtered event This function implements the actual auditing of incoming events.
-
format
(event)[source]¶ Prepares an outbound line
Parameters: event (Event or Message or Join or Leave) – an inbound event Returns: outbound line Return type: str This function adapts inbound events to the appropriate format. It turns an object with multiple attributes to a single string that can be saved in a log file.
-
on_bond
(bot)[source]¶ Reacts on space bonding
This function should be expanded in sub-class, where necessary.
Example:
def on_bond(self, bot): self.db = Driver.open(bot.id)
-
on_dispose
()[source]¶ Reacts on space disposal
This function should be expanded in sub-class, where necessary.
Example:
def on_disposal(self): self.db = Driver.close()
-