Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve error handling
  • Loading branch information
osode authored and m4reko committed Aug 22, 2022
commit 09c971e2ff8f29cb2ad63cdf505d34a038648a65
18 changes: 12 additions & 6 deletions src/g3pylib/recordings/recording.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
from datetime import datetime, timedelta
from typing import List, Optional, cast

Expand All @@ -9,12 +10,17 @@
from g3pylib.websocket import G3WebSocketClientProtocol


class InvalidResponseError(Exception):
"""Raised when an invalid response is received from the Glasses3 unit."""


class Recording(APIComponent):
def __init__(
self, connection: G3WebSocketClientProtocol, api_base_uri: URI, uuid: str
):
self._connection = connection
self._uuid = uuid
self.logger: logging.Logger = logging.getLogger(__name__)
super().__init__(URI(f"{api_base_uri}/{uuid}"))

async def get_created(self) -> datetime:
Expand Down Expand Up @@ -173,10 +179,10 @@ async def get_scenevideo_url(self) -> str:
try:
scenevideo_file_name = data["scenecamera"]["file"]
except KeyError:
print(
"Could not retrieve file name for recording from recording data."
self.logger.warning(
f"Could not retrieve file name for recording from recording data collected from {data_url}."
)
raise
raise InvalidResponseError
return f"{data_url}/{scenevideo_file_name}"

async def get_gazedata_url(self) -> str:
Expand All @@ -189,8 +195,8 @@ async def get_gazedata_url(self) -> str:
try:
gaze_file_name = data["gaze"]["file"]
except KeyError:
print(
"Could not retrieve file name for gaze data from recording data."
self.logger.warning(
f"Could not retrieve file name for gaze data from recording data collected from {data_url}."
)
raise
raise InvalidResponseError
return f"{data_url}/{gaze_file_name}?use-content-encoding=true"