mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-12 19:56:29 +00:00
Bad introspection causes DBus error not KeyError (#3898)
* Bad introspection causes DBus error not KeyError * Fix none error on disconnect race
This commit is contained in:
parent
ff462ae976
commit
48e666e1fc
@ -58,7 +58,7 @@ class DBusInterfaceProxy(DBusInterface):
|
||||
await super().connect(bus)
|
||||
await self.update()
|
||||
|
||||
if self.sync_properties:
|
||||
if self.sync_properties and self.is_connected:
|
||||
self.dbus.sync_property_changes(self.properties_interface, self.update)
|
||||
|
||||
@dbus_connected
|
||||
|
@ -147,8 +147,8 @@ class DBus:
|
||||
|
||||
async def get_properties(self, interface: str) -> dict[str, Any]:
|
||||
"""Read all properties from interface."""
|
||||
return await DBus.call_dbus(
|
||||
self._proxies[DBUS_INTERFACE_PROPERTIES], "call_get_all", interface
|
||||
return await DBusCallWrapper(self, DBUS_INTERFACE_PROPERTIES).call_get_all(
|
||||
interface
|
||||
)
|
||||
|
||||
def sync_property_changes(
|
||||
|
21
tests/fixtures/test_no_properties_interface.xml
vendored
Normal file
21
tests/fixtures/test_no_properties_interface.xml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.freedesktop.DBus.Introspectable">
|
||||
<method name="Introspect">
|
||||
<arg type="s" name="xml_data" direction="out"/>
|
||||
</method>
|
||||
</interface>
|
||||
<interface name="org.freedesktop.DBus.Peer">
|
||||
<method name="Ping"/>
|
||||
<method name="GetMachineId">
|
||||
<arg type="s" name="machine_uuid" direction="out"/>
|
||||
</method>
|
||||
</interface>
|
||||
<interface name="test.no.properties.interface">
|
||||
<method name="Hello">
|
||||
<arg type="s" name="hello" direction="out"/>
|
||||
</method>
|
||||
<property type="s" name="World" access="read"/>
|
||||
</interface>
|
||||
</node>
|
16
tests/utils/test_dbus.py
Normal file
16
tests/utils/test_dbus.py
Normal file
@ -0,0 +1,16 @@
|
||||
"""Test dbus utility."""
|
||||
from dbus_fast.aio.message_bus import MessageBus
|
||||
import pytest
|
||||
|
||||
from supervisor.dbus.const import DBUS_OBJECT_BASE
|
||||
from supervisor.exceptions import DBusInterfaceMethodError
|
||||
from supervisor.utils.dbus import DBus
|
||||
|
||||
|
||||
async def test_missing_properties_interface(dbus_bus: MessageBus, dbus: list[str]):
|
||||
"""Test introspection missing properties interface."""
|
||||
service = await DBus.connect(
|
||||
dbus_bus, "test.no.properties.interface", DBUS_OBJECT_BASE
|
||||
)
|
||||
with pytest.raises(DBusInterfaceMethodError):
|
||||
await service.get_properties("test.no.properties.interface")
|
Loading…
x
Reference in New Issue
Block a user