fix: prevent user contributed plugins to crash the main process while loading
This commit is contained in:
@ -35,6 +35,7 @@ def load_from_file(filename):
|
|||||||
def load_from_path(path, enabled=()):
|
def load_from_path(path, enabled=()):
|
||||||
global loaded
|
global loaded
|
||||||
for filename in glob.glob(os.path.join(path, "*.py")):
|
for filename in glob.glob(os.path.join(path, "*.py")):
|
||||||
|
try:
|
||||||
name, plugin = load_from_file(filename)
|
name, plugin = load_from_file(filename)
|
||||||
if name in loaded:
|
if name in loaded:
|
||||||
raise Exception("plugin %s already loaded from %s" % (name, plugin.__file__))
|
raise Exception("plugin %s already loaded from %s" % (name, plugin.__file__))
|
||||||
@ -43,6 +44,9 @@ def load_from_path(path, enabled=()):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
loaded[name] = plugin
|
loaded[name] = plugin
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning("error while loading %s: %s" % (filename, e))
|
||||||
|
logging.debug(e, exc_info=True)
|
||||||
|
|
||||||
return loaded
|
return loaded
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user