Face unlock: say why a camera can't be used, list the cameras, pick one
CI / test (push) Canceled after 21m7s

"no camera at PATH" now says why (not there or a broken link, permission
denied, not a V4L2 device, a metadata node rather than the picture node,
OpenCV couldn't start it or it gives no picture: another app using it) and
lists the cameras found (VIDIOC_QUERYCAP on /dev/v4l/by-id/* and /dev/video*).
New commands: `chandra-face cameras`, `chandra-face set-camera PATH` (root,
edits device in face.conf after checking it is a capture node). The Face
unlock window shows the cameras found with a Use button (one password), then
opens again. just install prints NOT READY with the reason when the
configured camera can't be used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhiJfJNAYqWzQiuKMf
This commit is contained in:
Claude committed 2026-11-26 04:47:06 +00:00
1 parent ff6f733810
commit 516180196f
7 files changed
+251 -9

No files matched your search

+20 -1
View File
@@ -237,7 +237,8 @@ class FaceTests(unittest.TestCase):
self.assertEqual(rc, 0)
self.assertTrue(any(l.startswith("problem ") for l in out), out)
self.env.camera([], device="/dev/no-such-camera")
self.assertIn("problem no camera at /dev/no-such-camera", self.env.run("status")[1])
out = self.env.run("status")[1]
self.assertTrue(any(l.startswith("problem no camera at /dev/no-such-camera (not there") for l in out), out)
class Session:
@@ -354,6 +355,24 @@ class CameraWindowTests(unittest.TestCase):
self.assertEqual(s.finish(), 0)
self.assertEqual(len(self.vectors()[0]["vectors"]), 2)
def test_a_missing_camera_says_why_and_lists_the_cameras(self):
self.env.camera([], device="/dev/v4l/by-id/usb-No-Such-Camera-video-index0", backend="fake")
s = Session(self.env)
words, _ = s.next("error")
text = " ".join(words[1:])
self.assertTrue(text.startswith("no camera at /dev/v4l/by-id/usb-No-Such-Camera-video-index0 (not there"), text)
self.assertIn("chandra-face set-camera PATH", text)
self.assertEqual(s.finish(), 2)
rc, out = self.env.run("status")
self.assertTrue(any(l.startswith("problem no camera at /dev/v4l/by-id/usb-No-Such") for l in out), out)
def test_set_camera_refuses_what_is_not_a_camera(self):
for bad in ("/dev/null", "/dev/v4l/by-id/nothing", "/etc/passwd"):
rc, out = self.env.run("set-camera", bad)
self.assertNotEqual(rc, 0, bad)
self.assertTrue(out[-1].startswith("error"), out)
self.assertNotIn("/dev/null", slurp(self.env.conf))
def test_apply_refuses_bad_data(self):
for bad in (b"[]", b"{\"add\": [{\"vectors\": [[1, 2]]}]}",
b"{\"add\": [{\"vectors\": [[1e999, 0, 0, 0]]}]}", b"{\"remove\": [7]}", b"nonsense"):