diff --git a/rosys/vision/camera_provider.py b/rosys/vision/camera_provider.py index f8eef893..3105457f 100644 --- a/rosys/vision/camera_provider.py +++ b/rosys/vision/camera_provider.py @@ -72,3 +72,7 @@ def prune_images(self, max_age_seconds: Optional[float] = None): else: while camera.images and camera.images[0].time < rosys.time() - max_age_seconds: del camera.images[0] + + @abc.abstractmethod + async def update_device_list(self) -> None: + pass diff --git a/rosys/vision/multi_camera_provider.py b/rosys/vision/multi_camera_provider.py index b1f74eb3..29712437 100644 --- a/rosys/vision/multi_camera_provider.py +++ b/rosys/vision/multi_camera_provider.py @@ -1,3 +1,5 @@ +import logging + from .camera import Camera from .camera_provider import CameraProvider @@ -11,11 +13,19 @@ class MultiCameraProvider(CameraProvider): def __init__(self, *camera_providers: CameraProvider) -> None: super().__init__() self.providers = camera_providers + self.log = logging.getLogger('rosys.multi_camera_provider') for camera_provider in self.providers: camera_provider.NEW_IMAGE.register(self.NEW_IMAGE.emit) camera_provider.CAMERA_ADDED.register(self.CAMERA_ADDED.emit) camera_provider.CAMERA_REMOVED.register(self.CAMERA_REMOVED.emit) + async def update_device_list(self) -> None: + for provider in self.providers: + try: + await provider.update_device_list() + except Exception as e: + self.log.error('Error while scanning for cameras in "%s": %s', provider.__class__.__name__, e) + def request_backup(self) -> None: for provider in self.providers: provider.request_backup()