3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-20 04:19:25 +01:00

auto-t: wpas.py: add wait_for_result

Some wpa_cli utilities return some result which isn't possible to
get with wait_for_event unless you know what the result will be.
This adds wait_for_result which just returns the first event that
comes in.
This commit is contained in:
James Prestwood 2022-01-04 10:18:54 -08:00 committed by Denis Kenzior
parent 8178ea17fd
commit 88f2309796

View File

@ -70,6 +70,9 @@ class Wpas:
while True:
context.iteration(may_block=True)
if not event and len(self._rx_data) >= 1:
return self._rx_data[0]
for e in self._rx_data:
if event in e:
GLib.source_remove(timeout)
@ -78,6 +81,10 @@ class Wpas:
if self._wait_timed_out:
raise TimeoutError('waiting for wpas event timed out')
def wait_for_result(self, timeout=10):
self._rx_data = []
return self.wait_for_event(None, timeout=timeout)
def _event_parse(self, line):
# Unescape event parameter values in '', other escaping rules not implemented
key = None