Mark test-shot photos with is_test flag (not saved as weighing)

This commit is contained in:
Claude
2026-06-30 15:22:53 +03:00
parent a4f8d5074e
commit ad95c90118
+3 -2
View File
@@ -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}")