# Makefile pour le scraper agenda du libre .PHONY: help install test demo monitor clean run setup-cron # Configuration par défaut API_URL ?= https://api.openeventdatabase.org BATCH_SIZE ?= 1 help: ## Afficher l'aide @echo "🔧 Scraper Agenda du Libre - Commandes disponibles" @echo "==================================================" @echo "" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' @echo "" @echo "💡 Variables d'environnement:" @echo " API_URL URL de l'API OEDB (défaut: https://api.openeventdatabase.org)" @echo " BATCH_SIZE Taille des batches (défaut: 1)" @echo "" @echo "📝 Exemples:" @echo " make run BATCH_SIZE=5" @echo " make run API_URL=http://api.example.com:8080" install: ## Installer les dépendances @echo "📦 Installation des dépendances..." sudo apt update sudo apt install -y python3-requests python3-icalendar @echo "✅ Dépendances installées" test: ## Exécuter les tests @echo "🧪 Exécution des tests..." python3 test_agendadulibre.py python3 test_api_connection.py --api-url $(API_URL) demo: ## Exécuter la démonstration @echo "🎭 Exécution de la démonstration..." python3 demo_agendadulibre.py monitor: ## Afficher les statistiques @echo "📊 Affichage des statistiques..." python3 monitor_agendadulibre.py run: ## Exécuter le scraper @echo "🚀 Exécution du scraper..." python3 agendadulibre.py --api-url $(API_URL) --batch-size $(BATCH_SIZE) run-verbose: ## Exécuter le scraper en mode verbeux @echo "🚀 Exécution du scraper en mode verbeux..." python3 agendadulibre.py --api-url $(API_URL) --batch-size $(BATCH_SIZE) --verbose run-force: ## Exécuter le scraper en forçant le rechargement @echo "🚀 Exécution du scraper avec rechargement forcé..." python3 agendadulibre.py --api-url $(API_URL) --batch-size $(BATCH_SIZE) --force-refresh run-cache-test: ## Tester le système de cache @echo "🔄 Test du système de cache..." python3 agendadulibre.py --api-url $(API_URL) --batch-size 1 --verbose @echo " Premier appel terminé, deuxième appel (depuis cache)..." python3 agendadulibre.py --api-url $(API_URL) --batch-size 1 --verbose setup-cron: ## Configurer la planification cron @echo "⏰ Configuration de la planification cron..." ./setup_cron.sh clean: ## Nettoyer les fichiers temporaires @echo "🧹 Nettoyage des fichiers temporaires..." rm -f agendadulibre_events.json rm -f agendadulibre_events.ics rm -f agendadulibre_scraper.log rm -f cron_agendadulibre.log @echo "✅ Nettoyage terminé" status: ## Afficher le statut du système @echo "📊 Statut du système:" @echo "====================" @echo "📁 Fichier de données:" @if [ -f agendadulibre_events.json ]; then \ SIZE=$$(stat -c%s agendadulibre_events.json 2>/dev/null || echo "0"); \ echo " ✅ Présent ($$SIZE octets)"; \ else \ echo " ❌ Absent"; \ fi @echo "📁 Fichier cache iCal:" @if [ -f agendadulibre_events.ics ]; then \ SIZE=$$(stat -c%s agendadulibre_events.ics 2>/dev/null || echo "0"); \ DATE=$$(stat -c%y agendadulibre_events.ics 2>/dev/null || echo "inconnue"); \ echo " ✅ Présent ($$SIZE octets)"; \ echo " 📅 Modifié: $$DATE"; \ else \ echo " ❌ Absent"; \ fi @echo "" @echo "📋 Tâches cron:" @if crontab -l 2>/dev/null | grep -q agendadulibre; then \ echo " ✅ Tâches configurées:"; \ crontab -l | grep agendadulibre | sed 's/^/ /'; \ else \ echo " ❌ Aucune tâche configurée"; \ fi @echo "" @echo "🔗 Connexion API:" @python3 -c "import requests; print(' ✅' if requests.get('$(API_URL)', timeout=5).status_code == 200 else ' ❌')" 2>/dev/null || echo " ❌ API non accessible" logs: ## Afficher les logs récents @echo "📋 Logs récents:" @echo "===============" @if [ -f agendadulibre_scraper.log ]; then \ tail -20 agendadulibre_scraper.log; \ else \ echo "Aucun fichier de log trouvé"; \ fi check-deps: ## Vérifier les dépendances @echo "🔍 Vérification des dépendances..." @python3 -c "import requests, icalendar; print('✅ Toutes les dépendances sont disponibles')" || echo "❌ Dépendances manquantes - exécutez 'make install'"