Description
The current L21 of Camera.py contains the following line:
Picamera2.set_logging(level=Picamera2.ERROR)
This causes an import-time exception in environments where Picamera2.ERROR is not defined. The error is:
ValueError: set logging level not integer or a valid string
This makes it impossible for downstream users to even import picamzero, let alone catch or work around the error.
Analysis
This seems to assume that Picamera2.ERROR is always defined and corresponds to logging.ERROR, but this is not guaranteed across all picamera2 versions.
In some situtation, Picamera2.ERROR is not set, and passing an undefined constant to set_logging() causes an immediate crash.
Since this happens during import time, users cannot patch or monkey-patch the value in advance.
Suggested Fix
Either of the following would resolve the issue:
Option 1: Use the logging module directly
import logging
Picamera2.set_logging(level=logging.ERROR)
Option 2: Add a defensive check
import logging
level = getattr(Picamera2, "ERROR", logging.ERROR)
Picamera2.set_logging(level=level)