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:
parent
8178ea17fd
commit
88f2309796
@ -70,6 +70,9 @@ class Wpas:
|
|||||||
while True:
|
while True:
|
||||||
context.iteration(may_block=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:
|
for e in self._rx_data:
|
||||||
if event in e:
|
if event in e:
|
||||||
GLib.source_remove(timeout)
|
GLib.source_remove(timeout)
|
||||||
@ -78,6 +81,10 @@ class Wpas:
|
|||||||
if self._wait_timed_out:
|
if self._wait_timed_out:
|
||||||
raise TimeoutError('waiting for wpas event 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):
|
def _event_parse(self, line):
|
||||||
# Unescape event parameter values in '', other escaping rules not implemented
|
# Unescape event parameter values in '', other escaping rules not implemented
|
||||||
key = None
|
key = None
|
||||||
|
Loading…
Reference in New Issue
Block a user