Model Classes

class pupil_labs.realtime_api.models.APIPath(value)[source]

Bases: Enum

An enumeration.

CALIBRATION = '/../calibration.bin'

Type:    str

EVENT = '/event'

Type:    str

RECORDING_CANCEL = '/recording:cancel'

Type:    str

RECORDING_START = '/recording:start'

Type:    str

RECORDING_STOP_AND_SAVE = '/recording:stop_and_save'

Type:    str

STATUS = '/status'

Type:    str

TEMPLATE_DATA = '/template_data'

Type:    str

TEMPLATE_DEFINITION = '/template_def'

Type:    str

full_address(address, port, protocol='http', prefix='/api')[source]
Return type:

str

pupil_labs.realtime_api.models.Component

Type annotation for Status components.

Alias of Union[Phone, Hardware, Sensor, Recording, NetworkDevice]

pupil_labs.realtime_api.models.ComponentRaw

Type annotation for json-parsed responses from the REST and Websocket API.

Alias of Dict[str, Any]

namedtuple pupil_labs.realtime_api.models.DiscoveredDeviceInfo(name, server, port, addresses)[source]

Bases: NamedTuple

DiscoveredDeviceInfo(name, server, port, addresses)

Fields:
  1.  name (str) – Full mDNS service name. Follows 'PI monitor:<phone name>:<hardware id>._http._tcp.local.' naming pattern

  2.  server (str) – e.g. 'pi.local.'

  3.  port (int) – e.g. 8080

  4.  addresses (List[str]) – e.g. ['192.168.0.2']

namedtuple pupil_labs.realtime_api.models.Event(name, recording_id, timestamp)[source]

Bases: NamedTuple

Event(name, recording_id, timestamp)

Fields:
  1.  name (Optional[str]) – Alias for field number 0

  2.  recording_id (Optional[str]) – Alias for field number 1

  3.  timestamp (int) – Alias for field number 2

property datetime
Return type:

datetime

classmethod from_dict(dct)[source]
Return type:

Event

namedtuple pupil_labs.realtime_api.models.Hardware(version='unknown', glasses_serial='unknown', world_camera_serial='unknown', module_serial='unknown')[source]

Bases: NamedTuple

Hardware(version, glasses_serial, world_camera_serial, module_serial)

Fields:
  1.  version (str) – Alias for field number 0

  2.  glasses_serial (str) – Alias for field number 1

  3.  world_camera_serial (str) – Alias for field number 2

  4.  module_serial (str) – Alias for field number 3

exception pupil_labs.realtime_api.models.InvalidTemplateAnswersError(template, answers, errors)[source]

Bases: Exception

namedtuple pupil_labs.realtime_api.models.NetworkDevice(ip, device_id, device_name, connected)[source]

Bases: NamedTuple

Information about devices discovered by the host device, not the client.

Note

This class represents device information made available via the websocket update connection by the host device (exposed via pupil_labs.realtime_api.device.Device.status_updates()). Devices discovered directly by this library are represented as DiscoveredDeviceInfo and returned by pupil_labs.realtime_api.discovery.discover_devices() and pupil_labs.realtime_api.discovery.Network.

Fields:
  1.  ip (str) – Alias for field number 0

  2.  device_id (str) – Alias for field number 1

  3.  device_name (str) – Alias for field number 2

  4.  connected (bool) – Alias for field number 3

namedtuple pupil_labs.realtime_api.models.Phone(battery_level, battery_state, device_id, device_name, ip, memory, memory_state, time_echo_port=None)[source]

Bases: NamedTuple

Phone(battery_level, battery_state, device_id, device_name, ip, memory, memory_state, time_echo_port)

Fields:
  1.  battery_level (int) – Alias for field number 0

  2.  battery_state (Literal['OK', 'LOW', 'CRITICAL']) – Alias for field number 1

  3.  device_id (str) – Alias for field number 2

  4.  device_name (str) – Alias for field number 3

  5.  ip (str) – Alias for field number 4

  6.  memory (int) – Alias for field number 5

  7.  memory_state (Literal['OK', 'LOW', 'CRITICAL']) – Alias for field number 6

  8.  time_echo_port (Optional[int]) – Alias for field number 7

namedtuple pupil_labs.realtime_api.models.Recording(action, id, message, rec_duration_ns)[source]

Bases: NamedTuple

Recording(action, id, message, rec_duration_ns)

Fields:
  1.  action (str) – Alias for field number 0

  2.  id (str) – Alias for field number 1

  3.  message (str) – Alias for field number 2

  4.  rec_duration_ns (int) – Alias for field number 3

property rec_duration_seconds
Return type:

float

namedtuple pupil_labs.realtime_api.models.Sensor(sensor, conn_type, connected=False, ip=None, params=None, port=None, protocol='rtsp')[source]

Bases: NamedTuple

Sensor(sensor, conn_type, connected, ip, params, port, protocol)

Fields:
  1.  sensor (str) – Alias for field number 0

  2.  conn_type (str) – Alias for field number 1

  3.  connected (bool) – Alias for field number 2

  4.  ip (Optional[str]) – Alias for field number 3

  5.  params (Optional[str]) – Alias for field number 4

  6.  port (Optional[int]) – Alias for field number 5

  7.  protocol (str) – Alias for field number 6

class Connection(value)[source]

Bases: Enum

An enumeration.

ANY = None

Type:    None

DIRECT = 'DIRECT'

Type:    str

WEBSOCKET = 'WEBSOCKET'

Type:    str

class Name(value)[source]

Bases: Enum

An enumeration.

ANY = None

Type:    None

EYES = 'eyes'

Type:    str

GAZE = 'gaze'

Type:    str

IMU = 'imu'

Type:    str

WORLD = 'world'

Type:    str

property url
Return type:

Optional[str]

class pupil_labs.realtime_api.models.Status(phone, hardware, sensors, recording)[source]

Bases: object

Represents the Companion’s full status

direct_eyes_sensor()[source]
Return type:

Optional[Sensor]

direct_gaze_sensor()[source]
Return type:

Optional[Sensor]

direct_imu_sensor()[source]
Return type:

Optional[Sensor]

direct_world_sensor()[source]
Return type:

Optional[Sensor]

classmethod from_dict(status_json_result)[source]
Return type:

Status

hardware

Type:    Hardware

matching_sensors(name, connection)[source]
phone

Type:    Phone

recording

Type:    Optional[Recording]

sensors

Type:    List[Sensor]

update(component)[source]
Return type:

None

class pupil_labs.realtime_api.models.Template(*args, **kwargs)[source]

Bases: object

archived_at = None

Type:    Optional[datetime]

convert_from_api_to_simple_format(data)[source]
convert_from_simple_to_api_format(data)[source]
created_at

Type:    datetime

description = None

Type:    Optional[str]

get_question_by_id(question_id)[source]
id

Type:    UUID

is_default_template = True

Type:    bool

items

Type:    List[TemplateItem]

label_ids

Type:    List[UUID]

name

Type:    str

published_at = None

Type:    Optional[datetime]

recording_ids = None

Type:    Optional[List[UUID]]

recording_name_format

Type:    List[str]

updated_at

Type:    datetime

validate_answers(answers, raise_exception=True, format=typing.Literal['api', 'simple'])[source]
class pupil_labs.realtime_api.models.TemplateItem(*args, **kwargs)[source]

Bases: object

choices

Type:    Optional[List[str]]

help_text

Type:    Optional[str]

id

Type:    UUID

input_type

Type:    Literal['any', 'integer', 'float']

required

Type:    bool

title

Type:    str

validate_answer(answer, format='simple', raise_exception=True)[source]
widget_type

Type:    Literal['TEXT', 'PARAGRAPH', 'RADIO_LIST', 'CHECKBOX_LIST', 'SECTION_HEADER', 'PAGE_BREAK']

exception pupil_labs.realtime_api.models.UnknownComponentError[source]

Bases: ValueError

pupil_labs.realtime_api.models.allow_empty(v)[source]
pupil_labs.realtime_api.models.make_template_answer_model_base(template_)[source]
pupil_labs.realtime_api.models.not_empty(v)[source]
pupil_labs.realtime_api.models.option_in_allowed_values(value, allowed)[source]
pupil_labs.realtime_api.models.parse_component(raw)[source]

Initialize an explicitly modelled representation (pupil_labs.realtime_api.models.Component) from the json-parsed dictionary (pupil_labs.realtime_api.models.ComponentRaw) received from the API.

Raises:

UnknownComponentError – if the component name cannot be mapped to an explicitly modelled class or the contained data does not fit the modelled fields.

Return type:

Union[Phone, Hardware, Sensor, Recording, NetworkDevice]