Files
pedidosClientes/gestion_pedidos/management/commands/start_file_watcher.py
2025-12-05 11:27:16 -03:00

29 lines
873 B
Python

"""
Comando para iniciar el file watcher que monitorea carpetas
"""
from django.core.management.base import BaseCommand
from gestion_pedidos.services.file_watcher import FileWatcherService
import time
import logging
logger = logging.getLogger(__name__)
class Command(BaseCommand):
help = 'Inicia el servicio de monitoreo de carpetas para procesar PDFs y albaranes automáticamente'
def handle(self, *args, **options):
self.stdout.write(self.style.SUCCESS('Iniciando file watcher...'))
watcher = FileWatcherService()
watcher.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
self.stdout.write(self.style.WARNING('\nDeteniendo file watcher...'))
watcher.stop()
self.stdout.write(self.style.SUCCESS('File watcher detenido.'))