From ad95c90118363c22c1cb2d145d4127f4547e3029 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 30 Jun 2026 15:22:53 +0300 Subject: [PATCH] Mark test-shot photos with is_test flag (not saved as weighing) --- orange_pi/scales.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/orange_pi/scales.py b/orange_pi/scales.py index 15adc59..72e0ab2 100644 --- a/orange_pi/scales.py +++ b/orange_pi/scales.py @@ -209,7 +209,7 @@ def grab_frame(): print(f"[CAPTURE] Ошибка захвата кадра: {e}") return None -def capture_and_send(weight, event_id): +def capture_and_send(weight, event_id, is_test=False): """Кадр + вес → наш VPS. Запускать в отдельном потоке (не блокирует светофор).""" img = grab_frame() if not img: @@ -223,6 +223,7 @@ def capture_and_send(weight, event_id): "captured_at": datetime.datetime.now().isoformat(), "media_type": "image/jpeg", "photo_b64": base64.b64encode(img).decode(), + "is_test": is_test, }).encode() req = urllib.request.Request(SERVER_CAPTURE_URL, data=payload, headers={"Content-Type": "application/json"}) @@ -323,7 +324,7 @@ def handle_cmd(raw): print("[CMD] Перезагрузка по команде сервера...") threading.Thread(target=lambda: (time.sleep(1), subprocess.run(['reboot'])), daemon=True).start() elif cmd == 'test-shot': - threading.Thread(target=capture_and_send, args=(0.0, f"test-{int(time.time()*1000)}"), daemon=True).start() + threading.Thread(target=capture_and_send, args=(0.0, f"test-{int(time.time()*1000)}", True), daemon=True).start() else: print(f"[CMD] Неизвестная команда: {cmd}")