eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 36777d1e688d345d37a6da3bb2065ce49509357c
parent cd2dd4e2dc47f5058d75a6d14fd41eaee3ad2628
Author: James Prestwood <prestwoj@gmail.com>
Date:   Fri, 13 Aug 2021 12:47:09 -0700

auto-t: iwd.py: add StationDebug.Event support

Adds a new wait_for_event API which waits for a StationDebug.Event.

Diffstat:
Mautotests/util/iwd.py | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py @@ -233,9 +233,17 @@ class StationDebug(IWDDBusAbstract): def __init__(self, *args, **kwargs): self._debug_props = None self._debug_iface = None + self._last_event = None + self._last_event_data = [] IWDDBusAbstract.__init__(self, *args, **kwargs) + self._iface.connect_to_signal("Event", self._event_handler) + + def _event_handler(self, event, data): + self._last_event = event + self._last_event_data = data + @property def autoconnect(self): return self._properties['AutoConnect'] @@ -244,6 +252,21 @@ class StationDebug(IWDDBusAbstract): frequencies = dbus.Array([dbus.UInt16(f) for f in frequencies]) self._iface.Scan(frequencies) + def wait_for_event(self, event, timeout=10): + try: + if self._last_event is not None: + return self._last_event_data + + ctx.non_block_wait(lambda s, e : s._last_event == e, timeout, self, event, + exception=TimeoutError("waiting for StationDebug.Event")) + + return self._last_event_data + finally: + # Consume the event + self._last_event_data = None + self._last_event = None + + class Device(IWDDBusAbstract): ''' Class represents a network device object: net.connman.iwd.Device @@ -596,6 +619,12 @@ class Device(IWDDBusAbstract): self._station_debug.scan(frequencies) + def wait_for_event(self, event, timeout=10): + if not self._station_debug: + self._station_debug = StationDebug(self._object_path) + + self._station_debug.wait_for_event(event, timeout) + def __str__(self, prefix = ''): return prefix + 'Device: ' + self.device_path + '\n'\ + prefix + '\tName:\t\t' + self.name + '\n'\