fix: pre-liberation review — frames dir, wigle config GET, debug redis-keys endpoint
CRITICAL: - frames.py: FRAMES_DIR corrected to /tmp/adacam/pics - frames.py: graceful handling when capture not started IMPORTANT: - wigle.py: added GET /api/1/wigle/config endpoint for Varroa - app.py: added GET /api/1/debug/redis-keys endpoint for GPS troubleshooting - install.sh: removed python validation that runs from wrong directory
This commit is contained in:
parent
f2a89badf1
commit
5fa7d8fd11
4 changed files with 57 additions and 8 deletions
|
|
@ -5,18 +5,36 @@ from flask import Blueprint, jsonify
|
|||
|
||||
bp = Blueprint("frames", __name__, url_prefix="/api/1/recording")
|
||||
|
||||
FRAMES_DIR = "/tmp/recording/pics"
|
||||
FRAMES_DIR = "/tmp/adacam/pics"
|
||||
|
||||
|
||||
@bp.route("/frames/latest", methods=["GET"])
|
||||
def latest_frame():
|
||||
"""Get path to most recent frame file."""
|
||||
# Handle case where capture hasn't started yet
|
||||
if not os.path.exists(FRAMES_DIR):
|
||||
return jsonify({'frames': [], 'message': 'capture not started'}), 200
|
||||
|
||||
if not os.path.isdir(FRAMES_DIR):
|
||||
return jsonify({"error": "No frames directory"}), 404
|
||||
return jsonify({"error": "Frames directory invalid"}), 500
|
||||
|
||||
files = glob.glob(os.path.join(FRAMES_DIR, "*"))
|
||||
if not files:
|
||||
return jsonify({"error": "No frames available"}), 404
|
||||
return jsonify({'frames': [], 'message': 'no frames captured yet'}), 200
|
||||
|
||||
latest = max(files, key=os.path.getmtime)
|
||||
return jsonify({"path": latest})
|
||||
|
||||
|
||||
@bp.route("/frames", methods=["GET"])
|
||||
def list_frames():
|
||||
"""List all available frames."""
|
||||
if not os.path.exists(FRAMES_DIR):
|
||||
return jsonify({'frames': [], 'message': 'capture not started'})
|
||||
|
||||
files = glob.glob(os.path.join(FRAMES_DIR, "*"))
|
||||
files.sort(key=os.path.getmtime, reverse=True)
|
||||
return jsonify({
|
||||
'frames': files[:100], # limit to 100 most recent
|
||||
'total': len(files)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue