From 6f52e7a008898a91d2f7b1780a333abee74259af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 30 Jan 2015 18:06:52 +0100 Subject: [PATCH] More error resilience when (re)loading plugins --- src/octoprint/plugin/core.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 2f57c437..973cebf3 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -282,18 +282,21 @@ class PluginManager(object): self.plugins, self.disabled_plugins = self._find_plugins() for name, plugin in self.plugins.items(): - # initialize the plugin - plugin.init() + try: + # initialize the plugin + plugin.init() - # evaluate registered hooks - for hook, callback in plugin.hooks.items(): - self.plugin_hooks[hook].append((name, callback)) + # evaluate registered hooks + for hook, callback in plugin.hooks.items(): + self.plugin_hooks[hook].append((name, callback)) - # evaluate registered implementations - for plugin_type in self.plugin_types: - implementations = plugin.get_implementations(plugin_type) - self.plugin_implementations_by_type[plugin_type] += ( (name, implementation) for implementation in implementations ) - self.plugin_implementations[name].update(plugin.get_implementations()) + # evaluate registered implementations + for plugin_type in self.plugin_types: + implementations = plugin.get_implementations(plugin_type) + self.plugin_implementations_by_type[plugin_type] += ( (name, implementation) for implementation in implementations ) + self.plugin_implementations[name].update(plugin.get_implementations()) + except: + self.logger.exception("There was an error loading plugin %s" % name) self.log_registered_plugins()