parlay.utils

parlay.utils.close_protocol(protocol_id)
parlay.utils.discover(force=True)
parlay.utils.get_item_by_id(item_id)
parlay.utils.get_item_by_name(item_name)
parlay.utils.open(protocol_name, **kwargs)
parlay.utils.open_protocol(protocol_name, **kwargs)
parlay.utils.shutdown_broker()
parlay.utils.sleep(time)
parlay.utils.setup(ip='localhost', port=8085, timeout=3)[source]

Connect this script to the broker’s websocket server.

Parameters:
  • ip – ip address of the broker websocket server
  • port – port of the broker websocket server
  • timeout – try for this long to connect to broker before giving up
Returns:

none

parlay.utils.discover(force=True)
parlay.utils.get_item_by_name(item_name)
parlay.utils.get_item_by_id(item_id)
parlay.utils.sleep(time)

parlay.utils.parlay_script

Define a base class for creating a client script

class parlay.utils.parlay_script.ParlayScript(item_id=None, name=None, _reactor=None, adapter=None)[source]

Bases: parlay.items.threaded_item.ThreadedItem

cleanup(*args)[source]

Cleanup after running the script :param args: :return:

kill()[source]

Kill the current script

on_message(msg)[source]
run_script()[source]

This should be overridden by the script class

shutdown_broker()[source]
parlay.utils.parlay_script.start_script(script_class, engine_ip='localhost', engine_port=8085, stop_reactor_on_close=None, skip_checks=False, reactor=None)[source]

Construct a new script from the script class and start it

:param script_class : The ParlayScript class to run (Must be subclass of ParlayScript) :param engine_ip : The ip of the broker that the script will be running on :param engine_port : the port of the broker that the script will be running on :param stop_reactor_on_close: Boolean regarding whether ot not to stop the reactor when the script closes (Defaults to False if the reactor is running, True if the reactor is not currently running) :param skip_checks : if True will not do sanity checks on script (CAREFUL: BETTER KNOW WHAT YOU ARE DOING!)

parlay.utils.scripting_setup

class parlay.utils.scripting_setup.ThreadedParlayScript(item_id=None, name=None, _reactor=None, adapter=None)[source]

Bases: parlay.utils.parlay_script.ParlayScript

ready = False
parlay.utils.scripting_setup.run_in_threaded_reactor(fn)[source]

Decorator to run the decorated function in the threaded reactor.

parlay.utils.scripting_setup.setup(ip='localhost', port=8085, timeout=3)[source]

Connect this script to the broker’s websocket server.

Parameters:
  • ip – ip address of the broker websocket server
  • port – port of the broker websocket server
  • timeout – try for this long to connect to broker before giving up
Returns:

none

parlay.utils.scripting_setup.start_reactor(ip, port)[source]