kopia lustrzana https://github.com/OpenDroneMap/WebODM
Check for active plugin
rodzic
26dee3b023
commit
441782987c
|
@ -273,7 +273,7 @@ def get_plugin_by_name(name, only_active=True, refresh_cache_if_none=False):
|
|||
else:
|
||||
return res
|
||||
|
||||
def get_current_plugin():
|
||||
def get_current_plugin(only_active=False):
|
||||
"""
|
||||
When called from a python module inside a plugin's directory,
|
||||
it returns the plugin that this python module belongs to
|
||||
|
@ -289,7 +289,7 @@ def get_current_plugin():
|
|||
parts = relp.split(os.sep)
|
||||
if len(parts) > 0:
|
||||
plugin_name = parts[0]
|
||||
return get_plugin_by_name(plugin_name, only_active=False)
|
||||
return get_plugin_by_name(plugin_name, only_active=only_active)
|
||||
|
||||
return None
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import logging
|
|||
from django.dispatch import receiver
|
||||
from django.core.mail import send_mail
|
||||
from app.plugins.signals import task_completed, task_failed, task_removed
|
||||
from app.plugins.functions import get_current_plugin
|
||||
from . import email as notification
|
||||
from . import config
|
||||
from app.models import Task, Setting
|
||||
|
@ -10,6 +11,9 @@ logger = logging.getLogger('app.logger')
|
|||
|
||||
@receiver(task_completed)
|
||||
def handle_task_completed(sender, task_id, **kwargs):
|
||||
if get_current_plugin(only_active=True) is None:
|
||||
return
|
||||
|
||||
logger.info("TaskNotification: Task Completed")
|
||||
|
||||
config_data = config.load()
|
||||
|
@ -27,6 +31,9 @@ def handle_task_completed(sender, task_id, **kwargs):
|
|||
|
||||
@receiver(task_removed)
|
||||
def handle_task_removed(sender, task_id, **kwargs):
|
||||
if get_current_plugin(only_active=True) is None:
|
||||
return
|
||||
|
||||
logger.info("TaskNotification: Task Removed")
|
||||
|
||||
config_data = config.load()
|
||||
|
@ -43,6 +50,9 @@ def handle_task_removed(sender, task_id, **kwargs):
|
|||
|
||||
@receiver(task_failed)
|
||||
def handle_task_failed(sender, task_id, **kwargs):
|
||||
if get_current_plugin(only_active=True) is None:
|
||||
return
|
||||
|
||||
logger.info("TaskNotification: Task Failed")
|
||||
|
||||
config_data = config.load()
|
||||
|
|
Ładowanie…
Reference in New Issue