lewis.utils.replies

Members

conditional_reply

Decorator that executes the command and replies if the device has a member called 'property name' and it is True in a boolean context.

timed_reply

Decorator that inhibits a command and performs an action if call time is less than some minimum time delay between the current and last input.

lewis.utils.replies.conditional_reply(property_name: str, reply: str | None = None) Callable[[P], T][source]

Decorator that executes the command and replies if the device has a member called ‘property name’ and it is True in a boolean context.

Example usage:

@conditional_reply("connected")
def acknowledge_pressure(channel):
    return ACK
Parameters:
  • property_name – The name of the property to look for on the device

  • reply – Desired output reply string when condition is false

Returns:

The function returns as normal if property is true. The command is not executed and there is no reply if property is false

:except AttributeError if the first argument of the decorated function (self) does not contain .device or ._device :except AttributeError if the device does not contain a property called property_name

lewis.utils.replies.timed_reply(action: str, reply: str | None = None, minimum_time_delay: float = 0) Callable[[P], T][source]

Decorator that inhibits a command and performs an action if call time is less than some minimum time delay between the current and last input.

Example usage:

@timed_reply(action="crash_pump", reply="WARNING: Input too quick", minimum_time_delay=150)
def acknowledge_pressure(channel):
    return ACK
Parameters:
  • action – The name of the method to execute for on the device

  • reply – Desired output reply string when input time delay is less than the minimum

  • minimum_time_delay – The minimum time (ms) between commands sent to the device

Returns:

The function returns as normal if minimum delay exceeded. The command is not executed and the action method is called on the device instead

:except AttributeError if the first argument of the decorated function (self)

does not contain .device or ._device

:except AttributeError if the device does not contain a property called action