eiwd

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

commit 5c7f34d66bcbaa4d29add6ecdad27adbd39fbcfd
parent 31b5275c1f2816f728a3db256750a3a5c6ceaa7a
Author: James Prestwood <prestwoj@gmail.com>
Date:   Thu, 31 Mar 2022 16:16:40 -0700

auto-t: iwd.py: use IO watch for station debug events

Similarly to hostapd.wait_for_event, IWD's variant needed to act on
an IO watch because events were being received prior to even calling
wait_for_event.

Diffstat:
Mautotests/util/iwd.py | 27++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py @@ -232,16 +232,14 @@ class StationDebug(IWDDBusAbstract): _iface_name = IWD_STATION_DEBUG_INTERFACE def __init__(self, *args, **kwargs): - self._last_event = None - self._last_event_data = [] + self._events = [] 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 + self._events.insert(0, (event, data)) @property def autoconnect(self): @@ -257,19 +255,18 @@ 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 + def _poll_event(self, event): + for idx, e in enumerate(self._events): + if event == e[0]: + # Consume any older events + self._events = self._events[:idx] + return True - ctx.non_block_wait(lambda s, e : s._last_event == e, timeout, self, event, - exception=TimeoutError("waiting for StationDebug.Event")) + return False - return self._last_event_data - finally: - # Consume the event - self._last_event_data = None - self._last_event = None + def wait_for_event(self, event, timeout=10): + return ctx.non_block_wait(self._poll_event, timeout, event, + exception=TimeoutError("waiting for event")) class DeviceProvisioning(IWDDBusAbstract): '''