From a6a922e04354c8db0b0c604096534f108e996247 Mon Sep 17 00:00:00 2001 From: Fayvel Victor Date: Fri, 5 Sep 2014 21:04:47 +0200 Subject: [PATCH] Handle missing dependencies of plugins during plugin_load_try Instead of letting m64py crash with an OSError when the loading of a plugin fails, it should better create an error message but continue working with the remaining plugins. An error can for example look like this: Frontend: ERROR: failed to load plugin /usr/lib/x86_64-linux-gnu/mupen64plus/mupen64plus-video-glide64mk2.so: libpng15.so.15: cannot open shared object file: No such file or directory --- src/m64py/core/core.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/m64py/core/core.py b/src/m64py/core/core.py index bcecd20..44d0587 100644 --- a/src/m64py/core/core.py +++ b/src/m64py/core/core.py @@ -219,13 +219,17 @@ class Core: def plugin_load_try(self, plugin_path=None): """Loads plugins and maps them by plugin type.""" - plugin_handle = C.cdll.LoadLibrary(plugin_path) - version = self.plugin_get_version(plugin_handle, plugin_path) - if version: - plugin_type, plugin_version, plugin_api, plugin_desc, plugin_cap = version - plugin_name = os.path.basename(plugin_path) - self.plugin_map[plugin_type][plugin_name] = ( - plugin_handle, plugin_path, PLUGIN_NAME[plugin_type], plugin_desc, plugin_version) + try: + plugin_handle = C.cdll.LoadLibrary(plugin_path) + version = self.plugin_get_version(plugin_handle, plugin_path) + if version: + plugin_type, plugin_version, plugin_api, plugin_desc, plugin_cap = version + plugin_name = os.path.basename(plugin_path) + self.plugin_map[plugin_type][plugin_name] = ( + plugin_handle, plugin_path, PLUGIN_NAME[plugin_type], plugin_desc, plugin_version) + except OSError as e: + log.debug("plugin_load_try()") + log.error("failed to load plugin %s: %s" % (plugin_path, e)) def plugin_startup(self, handle, name, desc): """This function initializes plugin for use by allocating memory,