mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-24 01:26:35 +00:00
Handle unbound introspection (#3247)
This commit is contained in:
parent
f864613ffb
commit
85313f26ea
@ -7,6 +7,7 @@ from typing import Any
|
|||||||
|
|
||||||
from dbus_next import BusType, InvalidIntrospectionError, Message, MessageType
|
from dbus_next import BusType, InvalidIntrospectionError, Message, MessageType
|
||||||
from dbus_next.aio import MessageBus
|
from dbus_next.aio import MessageBus
|
||||||
|
from dbus_next.introspection import Node
|
||||||
from dbus_next.signature import Variant
|
from dbus_next.signature import Variant
|
||||||
|
|
||||||
from ..exceptions import (
|
from ..exceptions import (
|
||||||
@ -85,6 +86,7 @@ class DBus:
|
|||||||
async def _init_proxy(self) -> None:
|
async def _init_proxy(self) -> None:
|
||||||
"""Read interface data."""
|
"""Read interface data."""
|
||||||
# Wait for dbus object to be available after restart
|
# Wait for dbus object to be available after restart
|
||||||
|
introspection: Node | None = None
|
||||||
try:
|
try:
|
||||||
self._bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
|
self._bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
@ -96,8 +98,9 @@ class DBus:
|
|||||||
self.bus_name, self.object_path, timeout=10
|
self.bus_name, self.object_path, timeout=10
|
||||||
)
|
)
|
||||||
except InvalidIntrospectionError as err:
|
except InvalidIntrospectionError as err:
|
||||||
_LOGGER.error("Can't parse introspect data: %s", err)
|
raise DBusParseError(
|
||||||
raise DBusParseError() from err
|
f"Can't parse introspect data: {err}", _LOGGER.error
|
||||||
|
) from err
|
||||||
except EOFError:
|
except EOFError:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Busy system at %s - %s", self.bus_name, self.object_path
|
"Busy system at %s - %s", self.bus_name, self.object_path
|
||||||
@ -107,6 +110,11 @@ class DBus:
|
|||||||
|
|
||||||
await asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
|
|
||||||
|
if introspection is None:
|
||||||
|
raise DBusFatalError(
|
||||||
|
"Could not get introspection data after 3 attempts", _LOGGER.error
|
||||||
|
)
|
||||||
|
|
||||||
self._add_interfaces(introspection)
|
self._add_interfaces(introspection)
|
||||||
|
|
||||||
def _prepare_args(self, *args: list[Any]) -> tuple[str, list[Any]]:
|
def _prepare_args(self, *args: list[Any]) -> tuple[str, list[Any]]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user