From 6ab4dda5e8290d9270e86608e309ee4dd0725358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Mon, 18 Oct 2021 14:48:47 +0200 Subject: [PATCH] Set agent diagnostics (#3203) * Set agent diagnostics * Add AttributeError to dbus_property wrapper * Use dbus_property instead of dbus_connected * Move sync to core setup --- supervisor/api/supervisor.py | 1 + supervisor/core.py | 6 ++++++ supervisor/dbus/agent/__init__.py | 1 + supervisor/dbus/interface.py | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/supervisor/api/supervisor.py b/supervisor/api/supervisor.py index 1e190c7c8..e39c76dbc 100644 --- a/supervisor/api/supervisor.py +++ b/supervisor/api/supervisor.py @@ -142,6 +142,7 @@ class APISupervisor(CoreSysAttributes): if ATTR_DIAGNOSTICS in body: self.sys_config.diagnostics = body[ATTR_DIAGNOSTICS] + self.sys_dbus.agent.diagnostics = body[ATTR_DIAGNOSTICS] if ATTR_LOGGING in body: self.sys_config.logging = body[ATTR_LOGGING] diff --git a/supervisor/core.py b/supervisor/core.py index 2c81983a0..7edc5711b 100644 --- a/supervisor/core.py +++ b/supervisor/core.py @@ -153,6 +153,12 @@ class Core(CoreSysAttributes): self.sys_resolution.unhealthy = UnhealthyReason.SETUP self.sys_capture_exception(err) + # Set OS Agent diagnostics if needed + if self.sys_config.diagnostics is not None and ( + self.sys_dbus.agent.diagnostics != self.sys_config.diagnostics + ): + self.sys_dbus.agent.diagnostics = self.sys_config.diagnostics + # Evaluate the system await self.sys_resolution.evaluate.evaluate_system() diff --git a/supervisor/dbus/agent/__init__.py b/supervisor/dbus/agent/__init__.py index 497d6a9a6..b5694359f 100644 --- a/supervisor/dbus/agent/__init__.py +++ b/supervisor/dbus/agent/__init__.py @@ -70,6 +70,7 @@ class OSAgent(DBusInterface): return self.properties[DBUS_ATTR_DIAGNOSTICS] @diagnostics.setter + @dbus_property def diagnostics(self, value: bool) -> None: """Enable or disable OS-Agent diagnostics.""" asyncio.create_task( diff --git a/supervisor/dbus/interface.py b/supervisor/dbus/interface.py index 0bb2d311a..2af1dafdb 100644 --- a/supervisor/dbus/interface.py +++ b/supervisor/dbus/interface.py @@ -13,7 +13,7 @@ def dbus_property(func): def wrapper(*args, **kwds): try: return func(*args, **kwds) - except KeyError: + except (KeyError, AttributeError): return None return wrapper