Sanity check disabled plugin list just in case
See https://github.com/foosel/OctoPrint/issues/2687#issuecomment-399797596
This commit is contained in:
1 parent
887304fe18
commit
a97b8c2fd9
2 files changed
+21
-12
No files matched your search
@@ -672,7 +672,9 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._console_logger.debug(u"{prefix} {line}".format(**locals()))
|
||||
|
||||
def _mark_plugin_enabled(self, plugin, needs_restart=False):
|
||||
disabled_list = list(self._settings.global_get(["plugins", "_disabled"]))
|
||||
disabled_list = list(self._settings.global_get(["plugins", "_disabled"],
|
||||
validator=lambda x: isinstance(x, list),
|
||||
fallback=[]))
|
||||
if plugin.key in disabled_list:
|
||||
disabled_list.remove(plugin.key)
|
||||
self._settings.global_set(["plugins", "_disabled"], disabled_list)
|
||||
@@ -687,7 +689,9 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._pending_enable.add(plugin.key)
|
||||
|
||||
def _mark_plugin_disabled(self, plugin, needs_restart=False):
|
||||
disabled_list = list(self._settings.global_get(["plugins", "_disabled"]))
|
||||
disabled_list = list(self._settings.global_get(["plugins", "_disabled"],
|
||||
validator=lambda x: isinstance(x, list),
|
||||
fallback=[]))
|
||||
if not plugin.key in disabled_list:
|
||||
disabled_list.append(plugin.key)
|
||||
self._settings.global_set(["plugins", "_disabled"], disabled_list)
|
||||
|
||||
+15
-10
@@ -1424,17 +1424,22 @@ class Settings(object):
|
||||
#~~ getter
|
||||
|
||||
def get(self, path, **kwargs):
|
||||
error_on_path = kwargs.get("error_on_path", False)
|
||||
new_kwargs = dict(kwargs)
|
||||
if "error_on_path" in new_kwargs:
|
||||
del new_kwargs["error_on_path"]
|
||||
error_on_path = kwargs.pop("error_on_path", False)
|
||||
validator = kwargs.pop("validator", None)
|
||||
fallback = kwargs.pop("fallback", None)
|
||||
|
||||
try:
|
||||
return self._get_value(path, **new_kwargs)
|
||||
except NoSuchSettingsPath:
|
||||
if error_on_path:
|
||||
raise
|
||||
return None
|
||||
def process():
|
||||
try:
|
||||
return self._get_value(path, **kwargs)
|
||||
except NoSuchSettingsPath:
|
||||
if error_on_path:
|
||||
raise
|
||||
return None
|
||||
|
||||
result = process()
|
||||
if callable(validator) and not validator(result):
|
||||
result = fallback
|
||||
return result
|
||||
|
||||
def getInt(self, path, **kwargs):
|
||||
minimum = kwargs.pop("min", None)
|
||||
|
||||
Reference in new issue
Block a user