kopia lustrzana https://github.com/OpenDroneMap/WebODM
Refactor
rodzic
b65aee6d61
commit
445ad0c40c
|
@ -327,34 +327,22 @@ def get_dynamic_script_handler(script_path, callback=None, **kwargs):
|
||||||
def enable_plugin(plugin_name):
|
def enable_plugin(plugin_name):
|
||||||
p = get_plugin_by_name(plugin_name, only_active=False)
|
p = get_plugin_by_name(plugin_name, only_active=False)
|
||||||
p.register()
|
p.register()
|
||||||
# Attempt to call plugin enable method
|
|
||||||
try:
|
try:
|
||||||
# Check existence of enable method
|
|
||||||
if hasattr(p, 'enable'):
|
|
||||||
p.enable()
|
p.enable()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# If enable fails, log warning and raise the exception.
|
logger.warning(f"Plugin: {plugin_name} enable error: {str(e)}")
|
||||||
logger.warning(f"Plugin: {plugin_name} enable unsuccessful: {str(e)}")
|
raise # Propagate error to UI
|
||||||
raise # Propagate error to UI, DB state not changed, unsure if plugin operational
|
|
||||||
# Mark plugin enabled
|
|
||||||
Plugin.objects.get(pk=plugin_name).enable()
|
Plugin.objects.get(pk=plugin_name).enable()
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def disable_plugin(plugin_name):
|
def disable_plugin(plugin_name):
|
||||||
p = get_plugin_by_name(plugin_name, only_active=False)
|
p = get_plugin_by_name(plugin_name, only_active=False)
|
||||||
# Attempt to call plugin disable method
|
|
||||||
try:
|
try:
|
||||||
# Check existence of disable method
|
|
||||||
if hasattr(p, 'disable'):
|
|
||||||
p.disable()
|
p.disable()
|
||||||
except:
|
except Exception as e:
|
||||||
# If enable fails, log warning. Exception not raised up as the
|
logger.warning(f"Plugin: {plugin_name} disable error: {str(e)}")
|
||||||
# plugin is going to be disabled anyhow. DB state not changed.
|
|
||||||
logger.warning("Plugin: "+plugin_name+" disable unsuccessful.")
|
|
||||||
# Disable the plugin even on failure
|
|
||||||
Plugin.objects.get(pk=plugin_name).disable()
|
Plugin.objects.get(pk=plugin_name).disable()
|
||||||
raise # Propagate the error to the UI.
|
raise # Propagate error to UI
|
||||||
# Mark plugin disabled
|
|
||||||
Plugin.objects.get(pk=plugin_name).disable()
|
Plugin.objects.get(pk=plugin_name).disable()
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue