HTTP stack

This module provides an attribute request and response.

class HttpPollRequest

A poll request representing payload of a request to an MCCS web server.

Some MCCS devices monitor and control hardware by issuing HTTP GETs to a HTTP server running on the hardware management board. This object represents the payload of such a GET.

An attribute request specifies

  • attributes whose values are to be read (“queries”)

  • commands to be invoked. These commands allow for multiple arguments. Writing an attribute value is covered by the single- argument case.

__init__()

Initialise a new instance.

add_command(name, *args)

Add a command to be executed as part of this request.

Parameters:
  • name (str) – name of the command to be invoked or attribute to be written.

  • args (Any) – arguments to the command. For an attribute write, there will only be one argument.

Return type:

None

add_getattributes(*attributes)

Add attributes to be queried as part of this request.

Parameters:

attributes (str) – names of the attribute to be queried.

Return type:

None

add_setattribute(name, value)

Add an attribute to be updated as part of this request.

Parameters:
  • name (str) – name of the command to be invoked or attribute to be written.

  • value (Any) – arguments to the command. For an attribute write, there will only be one argument.

Return type:

None

property commands: list[tuple[str, tuple]]

Return the commands to be executed in this request.

Returns:

a list of name-args tuples for commands to be invoked in this request.

property getattributes: list[str]

Return a list of getattributes queried in this request.

Returns:

a list of queried attributes

property setattributes: list[tuple[str, Any]]

Return a list of setattributes to be written in this request.

Returns:

a list of name-value tuples for attributes to be written in this request

class HttpPollResponse

Representation of an attribute response.

An attribute response specifies values of attributes that have been queried in an attribute request.

__init__()

Initialise a new instance.

add_command_response(command, value)

Add a response to an command.

Parameters:
  • command (str) – name of the command.

  • value (Any) – value returned from the command.

Return type:

None

add_query_response(attribute, value)

Add a response to an attribute value query.

Parameters:
  • attribute (str) – name of the queried attribute.

  • value (Any) – value of the queried attribute.

Return type:

None

property command_responses: dict[str, Any]

Return responses to commands.

Returns:

a dictionary of command return values.

property query_responses: dict[str, Any]

Return responses to queries in an attribute request.

Returns:

a dictionary of attribute values.