disable plugins in data dir
This commit is contained in:
parent
1f19ab604e
commit
e8f83590ee
1 changed files with 2 additions and 31 deletions
|
@ -17,7 +17,6 @@ class PluginManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.log = logging.getLogger("PluginManager")
|
self.log = logging.getLogger("PluginManager")
|
||||||
self.path_plugins = os.path.abspath(os.path.dirname(plugins.__file__))
|
self.path_plugins = os.path.abspath(os.path.dirname(plugins.__file__))
|
||||||
self.path_installed_plugins = config.data_dir + "/__plugins__"
|
|
||||||
self.plugins = defaultdict(list) # Registered plugins (key: class name, value: list of plugins for class)
|
self.plugins = defaultdict(list) # Registered plugins (key: class name, value: list of plugins for class)
|
||||||
self.subclass_order = {} # Record the load order of the plugins, to keep it after reload
|
self.subclass_order = {} # Record the load order of the plugins, to keep it after reload
|
||||||
self.pluggable = {}
|
self.pluggable = {}
|
||||||
|
@ -93,34 +92,6 @@ class PluginManager:
|
||||||
plugin["loaded"] = plugin_name in self.plugin_names
|
plugin["loaded"] = plugin_name in self.plugin_names
|
||||||
plugins.append(plugin)
|
plugins.append(plugin)
|
||||||
|
|
||||||
plugins += self.listInstalledPlugins(list_disabled)
|
|
||||||
return plugins
|
|
||||||
|
|
||||||
def listInstalledPlugins(self, list_disabled=False):
|
|
||||||
plugins = []
|
|
||||||
|
|
||||||
for address, site_plugins in sorted(self.config.items()):
|
|
||||||
if address == "builtin":
|
|
||||||
continue
|
|
||||||
for plugin_inner_path, plugin_config in sorted(site_plugins.items()):
|
|
||||||
is_enabled = plugin_config.get("enabled", False)
|
|
||||||
if not is_enabled and not list_disabled:
|
|
||||||
continue
|
|
||||||
plugin_name = os.path.basename(plugin_inner_path)
|
|
||||||
|
|
||||||
dir_path = "%s/%s/%s" % (self.path_installed_plugins, address, plugin_inner_path)
|
|
||||||
|
|
||||||
plugin = {}
|
|
||||||
plugin["source"] = address
|
|
||||||
plugin["name"] = plugin_name
|
|
||||||
plugin["dir_name"] = plugin_name
|
|
||||||
plugin["dir_path"] = dir_path
|
|
||||||
plugin["inner_path"] = plugin_inner_path
|
|
||||||
plugin["enabled"] = is_enabled
|
|
||||||
plugin["rev"] = plugin_config.get("rev", 0)
|
|
||||||
plugin["loaded"] = plugin_name in self.plugin_names
|
|
||||||
plugins.append(plugin)
|
|
||||||
|
|
||||||
return plugins
|
return plugins
|
||||||
|
|
||||||
# Load all plugin
|
# Load all plugin
|
||||||
|
@ -156,10 +127,10 @@ class PluginManager:
|
||||||
for module_name, module in list(sys.modules.items()):
|
for module_name, module in list(sys.modules.items()):
|
||||||
if not module or not getattr(module, "__file__", None):
|
if not module or not getattr(module, "__file__", None):
|
||||||
continue
|
continue
|
||||||
if self.path_plugins not in module.__file__ and self.path_installed_plugins not in module.__file__:
|
if self.path_plugins not in module.__file__:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if "allow_reload" in dir(module) and not module.allow_reload: # Reload disabled
|
if not getattr(module, 'allow_reload', True): # Reload disabled
|
||||||
# Re-add non-reloadable plugins
|
# Re-add non-reloadable plugins
|
||||||
for class_name, classes in self.plugins_before.items():
|
for class_name, classes in self.plugins_before.items():
|
||||||
for c in classes:
|
for c in classes:
|
||||||
|
|
Loading…
Reference in a new issue