fix: prevent user contributed plugins to crash the main process while loading
This commit is contained in:
parent
30e3898f3c
commit
61b957ac77
@ -35,14 +35,18 @@ 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")):
|
||||||
name, plugin = load_from_file(filename)
|
try:
|
||||||
if name in loaded:
|
name, plugin = load_from_file(filename)
|
||||||
raise Exception("plugin %s already loaded from %s" % (name, plugin.__file__))
|
if name in loaded:
|
||||||
elif name not in enabled:
|
raise Exception("plugin %s already loaded from %s" % (name, plugin.__file__))
|
||||||
# print("plugin %s is not enabled" % name)
|
elif name not in enabled:
|
||||||
pass
|
# print("plugin %s is not enabled" % name)
|
||||||
else:
|
pass
|
||||||
loaded[name] = plugin
|
else:
|
||||||
|
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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user