cot – Cot classes

Module author: Sylvain Hellegouarch <sh@defuze.org>

CotManager class

class headstock.lib.cot.CotManager

Represents a set of stanzas loaded from cot scripts.

>>> m = CotManager()
>>> m.add_cot_script(path)
>>> for cot in m.stanzas:
>>>     for (stanza_id, stanza_type) in cot[0]:
>>>         for stanza in cot[0][(stanza_id, stanza_type)]
>>>             # do something with the stanza
>>>             # send the stanza
add_cot_script(cot_script)
Loads a new cot script and adds it to the pool of managed stanza.
match_expected_stanza(stanza, exp_stanza)
stanzas
Generator that will yield each managed stanza one by one.

CotScript class

class headstock.lib.cot.CotScript
static load(path)

Loads a cot script given by path and returns the parsed stanzas as a list of dictionaries.

The dictionnaries have two numeric keys:

  • 0 which represents the stanzas to be sent
  • 1 representing the expected stanzas

The values of the dictionnaries are also dictionaries with keys being tuples (stanza_id, stanza_type). For each key the associated value is a list of bridge.Element instances, each representing a stanza.

Cot class handler

class headstock.lib.cot.Cot(bus, scripts, timeout=5.0)

Handler sending stanzas parsed from a set of cot scripts.

The handler will register to tha main channel of the bus to:

  • send a stanza if not processing one yet
  • check if a stanza has been sent and if the expected

stanzas have been validated otherwise times out that stanza and send the next one.

bus a cherrypy.lib.process.wspbus.Bus instance.

scripts a list of filenames to parse and read from

timeout duration before an expected sranza is considered to have timed out.

hostname
Returns the client domain.
ready(client)

Keeps a reference to the client instance when its session has been created.

Subscribes to the main channel of the bus.

stopping()
Unsubscribes from the main channel of the bus.

Table Of Contents

Previous topic

utils – headstock utils

This Page