Skip to content

Commit

Permalink
fix: catch import plugin error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhayujie committed Apr 10, 2023
1 parent 10fad72 commit 81472a4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions plugins/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import importlib.util
from plugins.event import EventAction, EventContext,Event
from plugins.plugin_registry import PluginRegistry
from common import functions
from common import functions, log

@functions.singleton
class PluginManager:
Expand All @@ -15,8 +15,11 @@ def __init__(self, plugins_dir="./plugins/"):
def load_plugins(self):
for plugin_name in self.find_plugin_names():
if os.path.exists(f"./plugins/{plugin_name}/{plugin_name}.py"):
plugin_module = self.load_plugin_module(plugin_name)
self.plugin_registry.register_from_module(plugin_module)
try:
plugin_module = self.load_plugin_module(plugin_name)
self.plugin_registry.register_from_module(plugin_module)
except Exception as e:
log.warn("Failed to import plugin %s" % (plugin_name))

def find_plugin_names(self):
plugin_names = []
Expand Down

0 comments on commit 81472a4

Please sign in to comment.