async def generate_camera_data(self) -> None: objs = await self.client.api_request_list("cameras") device_id: Optional[str] = None camera_is_online = False for obj_dict in objs: device_id = obj_dict["id"] if is_online(obj_dict): camera_is_online = True break if device_id is None: typer.echo("No camera found. Skipping camera endpoints...") return # json data obj = await self.client.api_request_obj(f"cameras/{device_id}") self.write_json_file("sample_camera", deepcopy(obj)) self.constants["camera_online"] = camera_is_online if not camera_is_online: typer.echo("Camera is not online, skipping snapshot, thumbnail and heatmap generation") # snapshot processd_camera = process_camera(None, self.client._host, deepcopy(obj), False) filename = "sample_camera_snapshot" if self.anonymize: typer.echo(f"Writing {filename}...") placeholder_image( self.output_folder / f"{filename}.png", processd_camera["image_width"], processd_camera["image_height"] ) else: snapshot = await self.client.get_camera_snapshot( obj["id"], processd_camera["image_width"], processd_camera["image_height"] ) self.write_image_file(filename, snapshot)
async def generate_bridge_data(self) -> None: objs = await self.client.api_request_list("bridges") device_id: Optional[str] = None for obj_dict in objs: device_id = obj_dict["id"] if is_online(obj_dict): break if device_id is None: self.log("No bridge found. Skipping bridge endpoints...") return obj = await self.client.api_request_obj(f"bridges/{device_id}") await self.write_json_file("sample_bridge", obj)
async def generate_viewport_data(self) -> None: objs = await self.client.api_request_list("viewers") device_id: Optional[str] = None for obj_dict in objs: device_id = obj_dict["id"] if is_online(obj_dict): break if device_id is None: typer.echo("No viewer found. Skipping viewer endpoints...") return obj = await self.client.api_request_obj(f"viewers/{device_id}") self.write_json_file("sample_viewport", obj)