From 3d43d633d1fc197ef10aae7eab6d830e06644f30 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Tue, 18 Sep 2018 12:07:23 -0700 Subject: [PATCH] auto-t: address Dbus API changes This is a temporary fix to address the recent split of the Device interface. This patch contains a workaround that re-enables the auto-tests while the test framework is being reworked to satisfy the need of the new API and should not be considered as a permanent solution. --- autotests/util/iwd.py | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py index 291fa30b..d49a72c1 100755 --- a/autotests/util/iwd.py +++ b/autotests/util/iwd.py @@ -215,6 +215,7 @@ class Device(IWDDBusAbstract): _iface_name = IWD_DEVICE_INTERFACE _wps_manager_if = None _station_if = None + _station_props = None @property def _wps_manager(self): @@ -228,10 +229,36 @@ class Device(IWDDBusAbstract): @property def _station(self): if self._station_if is None: - _station_if = dbus.Interface(self._bus.get_object(IWD_SERVICE, + self._station_if = dbus.Interface(self._bus.get_object(IWD_SERVICE, self.device_path), IWD_STATION_INTERFACE) - return _station_if + return self._station_if + + def _station_properties(self): + if self._station_props is not None: + return self._station_props + + if self._properties['Mode'] != 'station': + self._prop_proxy.Set(IWD_DEVICE_INTERFACE, 'Mode', 'station') + + self._station_prop_if = \ + dbus.Interface(self._bus.get_object(IWD_SERVICE, + self.device_path), + DBUS_PROPERTIES) + + self._station_props = self._station_prop_if.GetAll(IWD_STATION_INTERFACE) + + self._station_prop_if.connect_to_signal("PropertiesChanged", + self.__station_property_changed_handler, + DBUS_PROPERTIES, path_keyword="path") + + return self._station_props + + def __station_property_changed_handler(self, interface, changed, + invalidated, path): + if interface == IWD_STATION_INTERFACE and path == self._object_path: + for name, value in changed.items(): + self._station_props[name] = value @property def device_path(self): @@ -267,7 +294,8 @@ class Device(IWDDBusAbstract): @rtype: object (State) ''' - return DeviceState.from_str(self._properties['State']) + props = self._station_properties() + return DeviceState.from_str(props['State']) @property def connected_network(self): @@ -278,7 +306,8 @@ class Device(IWDDBusAbstract): @rtype: object (Network) ''' - return self._properties.get('ConnectedNetwork') + props = self._station_properties() + return props.get('ConnectedNetwork') @property def powered(self): @@ -299,7 +328,8 @@ class Device(IWDDBusAbstract): @rtype: boolean ''' - return bool(self._properties['Scanning']) + props = self._station_properties() + return bool(props['Scanning']) def scan(self): '''Schedule a network scan.