From f29860027c7fc148839ca4e1f858b1024102d9db Mon Sep 17 00:00:00 2001 From: Sambhav Kothari Date: Sun, 18 Mar 2018 19:08:03 +0530 Subject: [PATCH] PICARD-1221: Handle exception on loading incompatible plugins Picard crashes with an 'Unable to execute tagger script' message due to py2 syntax. This fixes the crash by catching the exception and logging an error message saying that Picard is unable to load a specific plugin. --- picard/plugin.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/picard/plugin.py b/picard/plugin.py index 84cb70d66..76c5517ab 100644 --- a/picard/plugin.py +++ b/picard/plugin.py @@ -281,7 +281,10 @@ class PluginManager(QtCore.QObject): plugindir, len(names)) for name in sorted(names): - self.load_plugin(name, plugindir) + try: + self.load_plugin(name, plugindir) + except Exception as e: + log.error('Unable to load plugin: %s.\nError occured: %s', name, e) def load_plugin(self, name, plugindir): module_file = None @@ -432,7 +435,12 @@ class PluginManager(QtCore.QObject): shutil.rmtree(dst) shutil.copytree(path, dst) if action != PLUGIN_ACTION_UPDATE: - installed_plugin = self.load_plugin(zip_plugin or plugin_name, USER_PLUGIN_DIR) + try: + installed_plugin = self.load_plugin(zip_plugin or plugin_name, USER_PLUGIN_DIR) + except Exception as e: + log.error('Unable to load plugin: %s.\nError occured: %s', name, e) + installed_plugin = None + if installed_plugin is not None: self.plugin_installed.emit(installed_plugin, False) else: