def scanForZones(self):
print("SCAN!")
global Zones
# Get the list of interfaces on the host.
addressDict = psutil.net_if_addrs()
ipList = []
for key in addressDict:
intf = addressDict[key]
for l in intf:
# Filter out the interfaces that are not of the correct type
# and that are not on the network I care about. Change filter
# as appropriate for your case.
if l.family == socket.AddressFamily.AF_INET and l.address.startswith('192.168.'):
# Add interface address to a list
ipList.append(l.address)
#zones = soco.discover(interface_addr='192.168.1.86')
# Loop through the list of addresses, trying to discover
# devices on a short timeout.
for ip in ipList:
zones = soco.discover(timeout=1, interface_addr=ip)
# If it finds zones then use this interface.
# I also check for the case of a previous scan,
# it has to do with how the rest of my code
# works. You should modify to suit your code.
if zones is not None and len(Zones) != len(zones):
self.zoneStore.clear()
if len(zones) > 0:
self.titleLabel.set_label("Rooms (" + str(len(zones)) + ")")
for zone in zones:
z = Zone(zone, self)
Zones.append(z)
self.zoneStore.append([self.testSymbol, zone.player_name, self.testSymbol2, zone.get_current_transport_info()["current_transport_state"], z])
# print(zone.get_current_transport_info())
self.selected_row_iter = self.zoneStore.get_iter_first()
self.select.select_iter(self.selected_row_iter)
break
elif zones is None:
print("No zones found at " + ip)
else:
print("CACHED!")