Better resilience against errors within plugins
This commit is contained in:
parent
1c806eb618
commit
75992ef837
6 changed files with 53 additions and 14 deletions
|
|
@ -314,7 +314,12 @@ class FileManager(object):
|
|||
printer_profile = self._printer_profile_manager.get_current_or_default()
|
||||
|
||||
for hook in self._preprocessor_hooks.values():
|
||||
hook_file_object = hook(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
||||
try:
|
||||
hook_file_object = hook(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
||||
except:
|
||||
self._logger.exception("Error when calling preprocessor hook {}, ignoring".format(hook))
|
||||
continue
|
||||
|
||||
if hook_file_object is not None:
|
||||
file_object = hook_file_object
|
||||
file_path = self._storage(destination).add_file(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
||||
|
|
|
|||
|
|
@ -234,7 +234,10 @@ class Server():
|
|||
|
||||
settingsPlugins = pluginManager.get_implementations(octoprint.plugin.SettingsPlugin)
|
||||
for implementation in settingsPlugins:
|
||||
settings_plugin_config_migration(implementation._identifier, implementation)
|
||||
try:
|
||||
settings_plugin_config_migration(implementation._identifier, implementation)
|
||||
except:
|
||||
self._logger.exception("Error while trying to migrate settings for plugin {}, ignoring it".format(implementation._identifier))
|
||||
|
||||
pluginManager.implementation_post_inits=[settings_plugin_config_migration]
|
||||
|
||||
|
|
@ -638,7 +641,10 @@ class Server():
|
|||
def _register_template_plugins(self):
|
||||
template_plugins = pluginManager.get_implementations(octoprint.plugin.TemplatePlugin)
|
||||
for plugin in template_plugins:
|
||||
self._register_additional_template_plugin(plugin)
|
||||
try:
|
||||
self._register_additional_template_plugin(plugin)
|
||||
except:
|
||||
self._logger.exception("Error while trying to register templates of plugin {}, ignoring it".format(plugin._identifier))
|
||||
|
||||
def _register_additional_template_plugin(self, plugin):
|
||||
folder = plugin.get_template_folder()
|
||||
|
|
@ -673,14 +679,22 @@ class Server():
|
|||
def _register_blueprint_plugins(self):
|
||||
blueprint_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.BlueprintPlugin)
|
||||
for plugin in blueprint_plugins:
|
||||
self._register_blueprint_plugin(plugin)
|
||||
try:
|
||||
self._register_blueprint_plugin(plugin)
|
||||
except:
|
||||
self._logger.exception("Error while registering blueprint of plugin {}, ignoring it".format(plugin._identifier))
|
||||
continue
|
||||
|
||||
def _register_asset_plugins(self):
|
||||
asset_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.AssetPlugin)
|
||||
for plugin in asset_plugins:
|
||||
if isinstance(plugin, octoprint.plugin.BlueprintPlugin):
|
||||
continue
|
||||
self._register_asset_plugin(plugin)
|
||||
try:
|
||||
self._register_asset_plugin(plugin)
|
||||
except:
|
||||
self._logger.exception("Error while registering assets of plugin {}, ignoring it".format(plugin._identifier))
|
||||
continue
|
||||
|
||||
def _register_blueprint_plugin(self, plugin):
|
||||
name = plugin._identifier
|
||||
|
|
|
|||
|
|
@ -630,8 +630,12 @@ def collect_plugin_assets(enable_gcodeviewer=True, enable_timelapse=True, prefer
|
|||
asset_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.AssetPlugin)
|
||||
for implementation in asset_plugins:
|
||||
name = implementation._identifier
|
||||
all_assets = implementation.get_assets()
|
||||
basefolder = implementation.get_asset_folder()
|
||||
try:
|
||||
all_assets = implementation.get_assets()
|
||||
basefolder = implementation.get_asset_folder()
|
||||
except:
|
||||
logger.exception("Got an error while trying to collect assets from {}, ignoring assets from the plugin".format(name))
|
||||
continue
|
||||
|
||||
def asset_exists(category, asset):
|
||||
exists = os.path.exists(os.path.join(basefolder, asset))
|
||||
|
|
|
|||
|
|
@ -172,17 +172,21 @@ def index():
|
|||
name = implementation._identifier
|
||||
plugin_names.add(name)
|
||||
|
||||
vars = implementation.get_template_vars()
|
||||
try:
|
||||
vars = implementation.get_template_vars()
|
||||
configs = implementation.get_template_configs()
|
||||
except:
|
||||
_logger.exception("Error while retrieving template data for plugin {}, ignoring it".format(name))
|
||||
continue
|
||||
|
||||
if not isinstance(vars, dict):
|
||||
vars = dict()
|
||||
if not isinstance(configs, (list, tuple)):
|
||||
configs = []
|
||||
|
||||
for var_name, var_value in vars.items():
|
||||
plugin_vars["plugin_" + name + "_" + var_name] = var_value
|
||||
|
||||
configs = implementation.get_template_configs()
|
||||
if not isinstance(configs, (list, tuple)):
|
||||
configs = []
|
||||
|
||||
includes = _process_template_configs(name, implementation, configs, template_rules)
|
||||
|
||||
for t in template_types:
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import octoprint.plugin
|
|||
import octoprint.events
|
||||
from octoprint.settings import settings
|
||||
|
||||
import logging
|
||||
|
||||
from .exceptions import *
|
||||
|
||||
|
||||
|
|
@ -102,6 +104,8 @@ class SlicingManager(object):
|
|||
"""
|
||||
|
||||
def __init__(self, profile_path, printer_profile_manager):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
self._profile_path = profile_path
|
||||
self._printer_profile_manager = printer_profile_manager
|
||||
|
||||
|
|
@ -123,7 +127,11 @@ class SlicingManager(object):
|
|||
plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SlicerPlugin)
|
||||
slicers = dict()
|
||||
for plugin in plugins:
|
||||
slicers[plugin.get_slicer_properties()["type"]] = plugin
|
||||
try:
|
||||
slicers[plugin.get_slicer_properties()["type"]] = plugin
|
||||
except:
|
||||
self._logger.exception("Error while getting properties from slicer {}, ignoring it".format(plugin._identifier))
|
||||
continue
|
||||
self._slicers = slicers
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -844,7 +844,11 @@ class MachineCom(object):
|
|||
self._callback.on_comm_force_disconnect()
|
||||
else:
|
||||
for hook in self._printer_action_hooks:
|
||||
self._printer_action_hooks[hook](self, line, action_command)
|
||||
try:
|
||||
self._printer_action_hooks[hook](self, line, action_command)
|
||||
except:
|
||||
self._logger.exception("Error while calling hook {} with action command {}".format(self._printer_action_hooks[hook], action_command))
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue