feat(web): scale param + de-duped, hardened screenshot/status API#475
Draft
mrosseel wants to merge 1 commit into
Draft
feat(web): scale param + de-duped, hardened screenshot/status API#475mrosseel wants to merge 1 commit into
mrosseel wants to merge 1 commit into
Conversation
- /api/screen accepts an optional ?scale=N (integer, clamped 1..8) that nearest-neighbor upscales the PNG for crisp docs/PR captures; scale=1 (default) is unchanged. - Consolidate the duplicated screen-PNG logic into a shared get_screen_png() helper in api_extensions; /image now delegates to it, keeping the web-remote live-view contract (200 image/png). - Harden /api/status: wrap each shared_state read so a dead/broken multiprocessing manager degrades to partial data plus a clear `error` field instead of a blanket 500. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
|
Those tests sound useful to have in the codebase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves the web-server screenshot/status API in
python/PiFinder/api_extensions.pyandpython/PiFinder/server.py:?scale=Non/api/screen— optional integer query param (clamped 1..8) that nearest-neighbor upscales the returned PNG, so docs/PR captures of the 128×128 screen stay crisp.scale=1(default) is byte-for-byte the old behavior./image(server.py) and/api/screenboth servedshared_state.screen()as a PNG with slightly different fallbacks. Both now go through a singleget_screen_png()helper./imagekeeps its contract (200image/png) so the web-remote live view is unaffected./api/status— eachshared_state.*read is now wrapped individually. A dead/broken multiprocessing manager degrades gracefully: readable fields are still returned, with a clearerrormap of which reads failed, instead of a blanket 500. The happy path is unchanged (noerrorkey when everything reads).Testing
tests/test_api_extensions.pypasses (6/6).None/BrokenPipeErrorscreen fallbacks, and a Flask test-client run of/api/statusagainst a partly-broken shared state (returns 200 + partial data +errorfield) and/api/screen?scale=5(640×640).ruff checkandruff format --checkclean on both changed files.🤖 Generated with Claude Code