From b6820cf03ac50e6c591536d3cb0aee1e6034e8b9 Mon Sep 17 00:00:00 2001 From: Maciej Kisielewski Date: Tue, 21 Sep 2021 11:22:56 +0200 Subject: Fix: do not lose first res detected in camera test This patch fixes a problem where camera_test.py would create an entry for a detected resolution _width_ but not actually add it. This resulted in the collection of supported resolution to sometimes be empty. --- bin/camera_test.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/camera_test.py b/bin/camera_test.py index 4ef90d7..37e97d9 100755 --- a/bin/camera_test.py +++ b/bin/camera_test.py @@ -244,11 +244,10 @@ class CameraTest: supported_resolutions = {} for i in range(caps.get_size()): key = caps.get_structure(i).get_int('width').value - try: - supported_resolutions[key].add( - caps.get_structure(i).get_int('height').value) - except KeyError: + if key not in supported_resolutions.keys(): supported_resolutions[key] = set() + supported_resolutions[key].add( + caps.get_structure(i).get_int('height').value) width = min(supported_resolutions.keys(), key=lambda x: abs(x - self._width)) height = min(supported_resolutions[width], -- cgit v1.2.3 From 85800b64a184e7bcc93c5a044b74559cee618245 Mon Sep 17 00:00:00 2001 From: Maciej Kisielewski Date: Tue, 21 Sep 2021 11:26:10 +0200 Subject: Fix: graceful exit on no supported camera res This patch makes the test exit with a graceful message instaed of a backtrace when no supported resolution could be found. --- bin/camera_test.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin') diff --git a/bin/camera_test.py b/bin/camera_test.py index 37e97d9..a7740f4 100755 --- a/bin/camera_test.py +++ b/bin/camera_test.py @@ -248,6 +248,8 @@ class CameraTest: supported_resolutions[key] = set() supported_resolutions[key].add( caps.get_structure(i).get_int('height').value) + if not supported_resolutions: + raise SystemExit("No supported resolutions found!") width = min(supported_resolutions.keys(), key=lambda x: abs(x - self._width)) height = min(supported_resolutions[width], -- cgit v1.2.3