Fix picamera tuning setting type

This commit is contained in:
Julian Stirling 2025-12-19 10:12:33 +00:00
parent 5df5651fc2
commit afeca2bbed

View file

@ -123,6 +123,9 @@ class StreamingPiCamera2(BaseCamera):
generalisation. generalisation.
""" """
tuning: dict = lt.setting(default_factory=dict, readonly=True)
"""The Raspberry PiCamera Tuning File JSON."""
def __init__( def __init__(
self, self,
thing_server_interface: lt.ThingServerInterface, thing_server_interface: lt.ThingServerInterface,
@ -160,10 +163,12 @@ class StreamingPiCamera2(BaseCamera):
# connected to the server if tuning is saved to disk. # connected to the server if tuning is saved to disk.
try: try:
self.tuning = copy.deepcopy(self.default_tuning) self.tuning = copy.deepcopy(self.default_tuning)
except ServerNotRunningError: except ServerNotRunningError as e:
# This will throw an error after setting as we are not connected to # This will throw an error after setting as we are not connected to
# a server. But we know this, so we ignore the error. # a server. But we know this, so we ignore the error as long as the
pass # tuning data is set.
if "version" not in self.tuning:
raise RuntimeError("Tuning file could not be set.") from e
# Also set the colour gains based on the tuning. Set to _colour_gains to not # Also set the colour gains based on the tuning. Set to _colour_gains to not
# trigger a ServerNotRunningError # trigger a ServerNotRunningError
@ -324,9 +329,6 @@ class StreamingPiCamera2(BaseCamera):
with self._streaming_picamera() as cam: with self._streaming_picamera() as cam:
return cam.sensor_resolution return cam.sensor_resolution
tuning: Optional[dict] = lt.setting(default=None, readonly=True)
"""The Raspberry PiCamera Tuning File JSON."""
def _initialise_picamera(self, check_sensor_model: bool = False) -> None: def _initialise_picamera(self, check_sensor_model: bool = False) -> None:
"""Acquire the picamera device and store it as ``self._picamera``. """Acquire the picamera device and store it as ``self._picamera``.