From 85313f26ea6e6284ff4f6c8eb75023f4495cd14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Wed, 20 Oct 2021 11:51:10 +0200 Subject: [PATCH] Handle unbound introspection (#3247) --- supervisor/utils/dbus.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/supervisor/utils/dbus.py b/supervisor/utils/dbus.py index 6269282e9..fb38196d4 100644 --- a/supervisor/utils/dbus.py +++ b/supervisor/utils/dbus.py @@ -7,6 +7,7 @@ from typing import Any from dbus_next import BusType, InvalidIntrospectionError, Message, MessageType from dbus_next.aio import MessageBus +from dbus_next.introspection import Node from dbus_next.signature import Variant from ..exceptions import ( @@ -85,6 +86,7 @@ class DBus: async def _init_proxy(self) -> None: """Read interface data.""" # Wait for dbus object to be available after restart + introspection: Node | None = None try: self._bus = await MessageBus(bus_type=BusType.SYSTEM).connect() except Exception as err: @@ -96,8 +98,9 @@ class DBus: self.bus_name, self.object_path, timeout=10 ) except InvalidIntrospectionError as err: - _LOGGER.error("Can't parse introspect data: %s", err) - raise DBusParseError() from err + raise DBusParseError( + f"Can't parse introspect data: {err}", _LOGGER.error + ) from err except EOFError: _LOGGER.warning( "Busy system at %s - %s", self.bus_name, self.object_path @@ -107,6 +110,11 @@ class DBus: await asyncio.sleep(3) + if introspection is None: + raise DBusFatalError( + "Could not get introspection data after 3 attempts", _LOGGER.error + ) + self._add_interfaces(introspection) def _prepare_args(self, *args: list[Any]) -> tuple[str, list[Any]]: