TimberBot – commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5abaccf)
raw | patch | inline | side by side (parent: 5abaccf)
author | Julian Fietkau <git@fietkau.software> | |
Tue, 28 Mar 2023 23:27:59 +0000 (01:27 +0200) | ||
committer | Julian Fietkau <git@fietkau.software> | |
Tue, 28 Mar 2023 23:27:59 +0000 (01:27 +0200) |
plugin_manager.py | patch | blob | history |
diff --git a/plugin_manager.py b/plugin_manager.py
index b3f291e9fbc8081027542da3897549f2fdf044df..8fd5fe3be510fafba70fefe95ea3ea43aeef201f 100644 (file)
--- a/plugin_manager.py
+++ b/plugin_manager.py
import codecs
import configparser
import datetime
-import imp
+import importlib.machinery
import inspect
import json
import math
def enable_plugin(self, plugin_name):
plugin_file = os.path.join(self.plugin_path, plugin_name + '.py')
if os.path.isfile(plugin_file):
- fp, pathname, description = imp.find_module(plugin_name, [self.plugin_path])
plugin_classes = []
try:
- plugin_module = imp.load_module(plugin_name, fp, pathname, description)
- plugin_classes = [ c for c in inspect.getmembers(plugin_module, inspect.isclass) if c[1].__module__ == plugin_name]
+ loader = importlib.machinery.SourceFileLoader(plugin_name, plugin_file)
+ spec = importlib.util.spec_from_loader(loader.name, loader)
+ plugin_module = importlib.util.module_from_spec(spec)
+ loader.exec_module(plugin_module)
+ plugin_classes = [c for c in inspect.getmembers(plugin_module, inspect.isclass) if c[1].__module__ == plugin_name]
except Exception as e:
print(e)
traceback.print_exception(type(e), e, e.__traceback__)