Skip to content

Commit 5ba1e04

Browse files
committed
Merge pull request #13 from fayvel/failure_plugin
Handle missing dependencies of plugins during plugin_load_try
2 parents 4c9b82d + a6a922e commit 5ba1e04

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/m64py/core/core.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,17 @@ def get_api_versions(self):
219219

220220
def plugin_load_try(self, plugin_path=None):
221221
"""Loads plugins and maps them by plugin type."""
222-
plugin_handle = C.cdll.LoadLibrary(plugin_path)
223-
version = self.plugin_get_version(plugin_handle, plugin_path)
224-
if version:
225-
plugin_type, plugin_version, plugin_api, plugin_desc, plugin_cap = version
226-
plugin_name = os.path.basename(plugin_path)
227-
self.plugin_map[plugin_type][plugin_name] = (
228-
plugin_handle, plugin_path, PLUGIN_NAME[plugin_type], plugin_desc, plugin_version)
222+
try:
223+
plugin_handle = C.cdll.LoadLibrary(plugin_path)
224+
version = self.plugin_get_version(plugin_handle, plugin_path)
225+
if version:
226+
plugin_type, plugin_version, plugin_api, plugin_desc, plugin_cap = version
227+
plugin_name = os.path.basename(plugin_path)
228+
self.plugin_map[plugin_type][plugin_name] = (
229+
plugin_handle, plugin_path, PLUGIN_NAME[plugin_type], plugin_desc, plugin_version)
230+
except OSError as e:
231+
log.debug("plugin_load_try()")
232+
log.error("failed to load plugin %s: %s" % (plugin_path, e))
229233

230234
def plugin_startup(self, handle, name, desc):
231235
"""This function initializes plugin for use by allocating memory,

0 commit comments

Comments
 (0)