Skip to content

Commit

Permalink
Raise PluginError if a plugin cannot be initialized successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritualized committed Apr 21, 2023
1 parent 2b21cb5 commit 0d7e26f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions smarthash.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ def init(self):
unique_params = {}

for x in plugin_filenames:
self.plugins[x] = importlib.import_module("Plugins." + x).SmarthashPlugin()

if self.plugins[x].title in self.config:
self.plugins[x].set_config(self.config[self.plugins[x].title])
try:
self.plugins[x] = importlib.import_module("Plugins." + x).SmarthashPlugin()

if not hasattr(self.plugins[x], 'handle'):
self.init_error("Could not import \"{0}\" plugin".format(x))
if self.plugins[x].title in self.config:
self.plugins[x].set_config(self.config[self.plugins[x].title])
except PluginError as e:
logging.error(f"Could not import '{x}' plugin: {e.error}")
del self.plugins[x]
continue

if self.plugins[x].title not in self.config:
Expand Down

0 comments on commit 0d7e26f

Please sign in to comment.