Face unlock window steps aside while Apply asks for the password
CI / test (push) Canceled after 3m23s
CI / test (push) Canceled after 3m23s
After Apply the window kept the keyboard and the pointer and its dimmed card covered the screen, so a password dialog that isn't Chandra's own (another polkit agent's window) couldn't be reached. While Apply waits, the window now shows only a note at the top and takes no input. A refused or cancelled password brings it back with the snaps and marks kept (chandra-face camera restarts the camera instead of exiting) and says so. Test: snaps, Enter, the password dialog gets typing (Space no longer snaps underneath) and the Authenticate click, then the root step finishes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hhiJfJNAYqWzQiuKMf
This commit is contained in:
8 files changed
+150
-8
No files matched your search
+6
-2
@@ -669,6 +669,7 @@ def cmd_camera(cfg, user, label, out, cfg_path, no_elevate):
|
||||
about 12 a second; the box is -1s without one face), `snap ID W H LEN` + RGB (a kept snap,
|
||||
cropped to the face), `info` / `error` / `done` lines, `applied CODE` at the end of an apply.
|
||||
In (stdin lines): `snap`, `drop ID`, `apply REMOVE-IDS` (comma-separated, may be empty), `quit`.
|
||||
After a failed apply (no password, say) the camera starts again and the snaps are kept.
|
||||
The pictures stay in this process's memory: nothing is written to disk; only the embeddings
|
||||
of the snaps kept go to the root `apply`, through a pipe."""
|
||||
check_user(user)
|
||||
@@ -733,7 +734,10 @@ def cmd_camera(cfg, user, label, out, cfg_path, no_elevate):
|
||||
"remove": removes}
|
||||
code = run_apply(cfg, user, out, req, cfg_path, no_elevate)
|
||||
out.emit("applied", str(code))
|
||||
return code
|
||||
if code == 0:
|
||||
return 0
|
||||
# The password was refused or cancelled: back to the camera, snaps kept.
|
||||
cam = open_camera(cfg, loop=True)
|
||||
finally:
|
||||
if cam is not None:
|
||||
cam.close()
|
||||
@@ -793,7 +797,7 @@ def run_apply(cfg, user, out, req, cfg_path, no_elevate):
|
||||
sys.stdout.flush()
|
||||
code = p.wait()
|
||||
if not said:
|
||||
out.error("Nothing changed")
|
||||
out.error("Nothing changed: the administrator password wasn't given")
|
||||
return code or 1
|
||||
return code
|
||||
|
||||
|
||||
@@ -337,6 +337,23 @@ class CameraWindowTests(unittest.TestCase):
|
||||
s.finish()
|
||||
self.assertEqual([f["label"] for f in self.vectors()], ["Face 2"])
|
||||
|
||||
def test_a_failed_apply_keeps_the_snaps(self):
|
||||
self.env.camera(["alice"], frame_delay="0.01")
|
||||
s = Session(self.env)
|
||||
s.send("snap")
|
||||
s.next("snap")
|
||||
s.send("apply 99")
|
||||
words, _ = s.next("error")
|
||||
self.assertEqual(" ".join(words[1:]), "no face 99 for %s" % ME)
|
||||
self.assertEqual(s.next("applied")[0][1], "1")
|
||||
s.next("frame") # the camera goes on
|
||||
s.send("snap")
|
||||
s.next("snap")
|
||||
s.send("apply ")
|
||||
self.assertEqual(s.next("applied")[0][1], "0")
|
||||
self.assertEqual(s.finish(), 0)
|
||||
self.assertEqual(len(self.vectors()[0]["vectors"]), 2)
|
||||
|
||||
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"):
|
||||
|
||||
Reference in new issue
Block a user