Switchboard Python provides helpers for writing Switchboard workers and clients in Python.

It’s simplest to install this library from [PyPi](https://pypi.python.org/pypi):

pip install switchboard-python
To build from source:

# Building ./setup.py build

# Running the tests ./setup.py test

# Development install pip install -e .

# Actual install pip install .

The switchboard.Client class is used to interact with both Switchboard workers and clients.

Assuming that the Switchboard application is running, the following example opens a connection to the server over the worker interface, and sends a batch request with a connect command (see the interfaces guide for command documentation).

worker = switchboard.Client("ws://")
worker.send_cmds(("connect", CONN_SPEC))
To handle command responses, send_cmds returns a promise that is fulfilled by the tuple (cmds, resps) when the command’s responses arrive, where cmds is the list of commands given to send_cmds, and resps is the list of responses returned by Switchboard.

def handle_get_mailboxes((cmds, resps)):
    print "For cmds", cmds, ", received resps:", resps

worker.send_cmds(("getMailboxes", {}).then(handle_get_mailboxes)
To add commands on connect, and/or handling of unsolicited messages subclass the base switchboard.Client – an unsolicited message is not sent in response to a command, but when the server has new information, such as a new emails arriving

class TheWorker(switchboard.Client):
    def opened(self):
        print "Connected to Switchboard, issuing watchAll cmd."
        worker.send_cmds(("watchAll", {}))

    def received_unsolicited(resps):
        print "Received unsolicited resps from server:", resps
        for resp in resps:
            if resp[0] == 'newMessage':
                print "New message:", resp[1]

worker = TheWorker("ws://")
All examples are located under /examples. Each exampl