mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-19 10:02:33 +01:00
auto-t: return None with get_ordered_network(s)
If no networks are found, return None rather than an empty array. This is easier to check by the caller (and was assumed in some cases). Also add an exception to get_ordered_network if no network is found.
This commit is contained in:
parent
6c2b10b118
commit
fc9342f751
@ -376,6 +376,10 @@ class Device(IWDDBusAbstract):
|
||||
for bus_obj in self._station.GetOrderedNetworks():
|
||||
ordered_network = OrderedNetwork(bus_obj)
|
||||
ordered_networks.append(ordered_network)
|
||||
|
||||
if len(ordered_networks) == 0:
|
||||
return None
|
||||
|
||||
return ordered_networks
|
||||
|
||||
def get_ordered_network(self, network):
|
||||
@ -385,6 +389,9 @@ class Device(IWDDBusAbstract):
|
||||
'''
|
||||
ordered_networks = self.get_ordered_networks()
|
||||
|
||||
if not ordered_networks:
|
||||
raise Exception('Network %s not found' % network)
|
||||
|
||||
for n in ordered_networks:
|
||||
if n.name == network:
|
||||
return n
|
||||
|
Loading…
Reference in New Issue
Block a user