Refactor and enhance timelapse capture system
- Removed obsolete script `script_SANSDEMARRAGE.sh`. - Added new `Camera.py` and `Connexion.py` files for camera handling and socket communication. - Implemented `First_Try.py` for initial camera preview testing. - Created `Humidity.py` for humidity sensor data acquisition. - Developed `Send_data_stocked.py` for managing and sending stored data. - Introduced `Time_Lapse_Connection.py` and `Time_Lapse_NoConnection.py` for connected and offline modes. - Added `get_from_server.py` for retrieving camera status from the server. - Updated `sync_offline_data.py` for synchronizing offline data. - Created `timelapse.service` for managing the timelapse service on Raspberry Pi. - Established package structure with `__init__.py` and `api_client.py` for API interactions. - Enhanced `capture.py` for managing image captures and data storage. - Configured `config.py` for centralized configuration management. - Developed `sensors.py` for handling environmental sensors and camera operations. - Implemented `timelapse_offline.py` and `timelapse_online.py` for capturing images in offline and online modes.
This commit is contained in:
58
timelapse_online.py
Normal file
58
timelapse_online.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Script principal pour la capture d'images en mode connecté.
|
||||
Remplace l'ancien Time_Lapse_Connection.py
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import logging
|
||||
from timelapse.config import config
|
||||
from timelapse.api_client import api_client
|
||||
from timelapse.capture import timelapse_manager
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
Fonction principale pour la capture d'images en mode connecté.
|
||||
"""
|
||||
logging.info("-------------------------------------------------------------------")
|
||||
logging.info("Démarrage de la capture d'images en mode connecté")
|
||||
|
||||
try:
|
||||
# Vérifier le statut de la caméra via l'API
|
||||
status = api_client.get_camera_status()
|
||||
|
||||
if status is None:
|
||||
logging.error("Impossible d'obtenir le statut de la caméra depuis l'API")
|
||||
sys.exit(1)
|
||||
|
||||
# Mise à jour de la configuration
|
||||
api_client.update_camera_config(status)
|
||||
|
||||
# Vérification de l'état de maintenance
|
||||
if status.get("maintenance", False):
|
||||
logging.info("Caméra en mode maintenance, arrêt du script")
|
||||
sys.exit(0)
|
||||
|
||||
# Vérifier si un arrêt est demandé
|
||||
if status.get("stop_flag", False):
|
||||
logging.info("Demande d'arrêt détectée, confirmation au serveur")
|
||||
api_client.confirm_stop()
|
||||
sys.exit(0)
|
||||
|
||||
# Exécuter la séquence de capture
|
||||
timelapse_manager.run_capture_sequence(online=True)
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Erreur lors de la capture en mode connecté: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
logging.info("Capture en mode connecté terminée")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user