3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-10-04 02:18:49 +02:00

autotests: utility - added utility functions

This commit is contained in:
Rahul Rahul 2016-07-21 16:18:06 -07:00 committed by Denis Kenzior
parent 67dc10707a
commit 575d928bbb
2 changed files with 23 additions and 4 deletions

View File

@ -73,10 +73,10 @@ def unregisterAgent(manager, pathAgent):
def delayedUnregister(manager, path, mainloop): def delayedUnregister(manager, path, mainloop):
counter = 1 counter = 1
while (utility.getCurrentlyConnectedDevice() == "" and counter < 10): while (not utility.getConnectionStatus() and counter < 10):
time.sleep(1) time.sleep(1)
counter += 1 counter += 1
continue continue
time.sleep(1) time.sleep(1)
unregisterAgent(manager, path) unregisterAgent(manager, path)

View File

@ -74,6 +74,25 @@ def getNetworkToConnectTo(objects):
return path return path
return "" 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 # return the currently connected device by
# checking the 'ConnectedNetwork' property # checking the 'ConnectedNetwork' property
def getCurrentlyConnectedDevice(): def getCurrentlyConnectedDevice():