second commit

This commit is contained in:
denis
2026-03-10 13:10:32 +01:00
parent b5cc0106c6
commit 3aac7ff9b9
101 changed files with 22046 additions and 1 deletions
+34
View File
@@ -0,0 +1,34 @@
'''
Created on 23 janv. 2026
@author: denis
'''
from celery import shared_task
from django.core.mail import EmailMultiAlternatives
from .process import MqttProcess, mqttc
@shared_task
def async_send_mail(subject, body, from_email, to=[], bcc=[], cc=[], html=None, fail_silently=False, attachments=[], connection=None):
msg = EmailMultiAlternatives(subject, body, from_email, to, bcc=bcc, cc=cc, connection=connection)
if html:
msg.attach_alternative(html, 'text/html')
for f in attachments:
msg.attach_file(f)
msg.send(fail_silently)
@shared_task(bind=True)
def start_mqtt_worker(self):
mqttc.task = MqttProcess()
mqttc.task.start()
return {"status": "success", "message": f"MQTT Worker démarré."}
@shared_task(bind=True)
def stop_mqtt_worker(self):
if mqttc.task:
mqttc.task.stop()
return {"status": "success", "message": f"MQTT Worker arrêté."}