mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-20 01:14:07 +01:00
autotests: utility - added utility functions
This commit is contained in:
parent
67dc10707a
commit
575d928bbb
@ -73,10 +73,10 @@ def unregisterAgent(manager, pathAgent):
|
||||
|
||||
def delayedUnregister(manager, path, mainloop):
|
||||
counter = 1
|
||||
while (utility.getCurrentlyConnectedDevice() == "" and counter < 10):
|
||||
time.sleep(1)
|
||||
counter += 1
|
||||
continue
|
||||
while (not utility.getConnectionStatus() and counter < 10):
|
||||
time.sleep(1)
|
||||
counter += 1
|
||||
continue
|
||||
|
||||
time.sleep(1)
|
||||
unregisterAgent(manager, path)
|
||||
|
@ -74,6 +74,25 @@ def getNetworkToConnectTo(objects):
|
||||
return path
|
||||
return ""
|
||||
|
||||
# return the current connection status
|
||||
# connected, disconnected, connecting, disconnecting
|
||||
def getConnectionStatus():
|
||||
logger.debug(sys._getframe().f_code.co_name)
|
||||
bus = dbus.SystemBus()
|
||||
manager = dbus.Interface(bus.get_object(IWD_SERVICE, "/"),
|
||||
"net.connman.iwd.Manager")
|
||||
objects = getObjectList(bus)
|
||||
for path in objects:
|
||||
if IWD_DEVICE_INTERFACE not in objects[path]:
|
||||
continue
|
||||
device = objects[path][IWD_DEVICE_INTERFACE]
|
||||
for key in device.keys():
|
||||
if key in ["State"]:
|
||||
logger.debug("Device state is %s", device["State"])
|
||||
if device["State"] in "connected":
|
||||
return True
|
||||
return False
|
||||
|
||||
# return the currently connected device by
|
||||
# checking the 'ConnectedNetwork' property
|
||||
def getCurrentlyConnectedDevice():
|
||||
|
Loading…
Reference in New Issue
Block a user