What changed, and why it matters
This commit changes how the SeedSigner camera code handles hardware camera failures. Instead of letting a low-level PiCamera error crash the user experience with a technical message, it now catches that error and raises a friendlier 'CameraConnectionError' telling the user to check camera connections. It is a reliability/usability improvement, not a security fix.
No security action required; treat as normal code-quality/reliability improvement.
Security signals we found
No security-relevant signals present in the diff
Exception handling change only
No input parsing, authentication, or cryptographic changes
Evidence from the diff
The patch wraps PiCamera/PiVideoStream initialization in try/except blocks for PiCameraError and re-raises a new CameraConnectionError with a localized, user-facing message. It also moves some imports inside methods and adds a custom exception class. There is no change to access control, input validation, cryptography, or privilege boundaries.
Changed components
src/seedsigner/hardware/camera.pyInspect captured patch +25 / −6
diff --git a/src/seedsigner/hardware/camera.py b/src/seedsigner/hardware/camera.py
index ab4f700..f1c09b2 100644
--- a/src/seedsigner/hardware/camera.py
+++ b/src/seedsigner/hardware/camera.py
@@ -1,12 +1,20 @@
import io
+from gettext import gettext as _
from PIL import Image
-from seedsigner.hardware.pivideostream import PiVideoStream
+
from seedsigner.models.settings import Settings, SettingsConstants
from seedsigner.models.singleton import Singleton
+class CameraConnectionError(Exception):
+ def __init__(self, *args, **kwargs):
+ message = _("Camera error. Check camera connections.")
+ super().__init__(message)
+
+
+
class Camera(Singleton):
_video_stream = None
_picamera = None
@@ -22,12 +30,18 @@ class Camera(Singleton):
def start_video_stream_mode(self, resolution=(512, 384), framerate=12, format="bgr"):
+ from picamera import PiCameraError
from seedsigner.hardware.pivideostream import PiVideoStream
if self._video_stream is not None:
self.stop_video_stream_mode()
- self._video_stream = PiVideoStream(resolution=resolution,framerate=framerate, format=format)
- self._video_stream.start()
+ try:
+ self._video_stream = PiVideoStream(resolution=resolution,framerate=framerate, format=format)
+ self._video_stream.start()
+ except PiCameraError:
+ # This error most often occurs because the camera connection is loose
+ from seedsigner.hardware.camera import CameraConnectionError
+ raise CameraConnectionError()
def read_video_stream(self, as_image=False):
@@ -49,14 +63,19 @@ class Camera(Singleton):
def start_single_frame_mode(self, resolution=(720, 480)):
- from picamera import PiCamera
+ from picamera import PiCamera, PiCameraError
if self._video_stream is not None:
self.stop_video_stream_mode()
if self._picamera is not None:
self._picamera.close()
- self._picamera = PiCamera(resolution=resolution, framerate=24)
- self._picamera.start_preview()
+ try:
+ self._picamera = PiCamera(resolution=resolution, framerate=24)
+ self._picamera.start_preview()
+ except PiCameraError:
+ # This error most often occurs because the camera connection is loose
+ from seedsigner.hardware.camera import CameraConnectionError
+ raise CameraConnectionError()
def capture_frame(self):
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.