def getAccessPoints(self, refresh = False): self.APList = [] self.cleanList = [] aps = iWlan.getNetworkList() if aps is not None: print "[WirelessLan.py] got Accespoints!" tmpList = [] compList = [] for ap in aps: a = aps[ap] if a['active']: tmpList.append( (a['essid'], a['bssid']) ) compList.append( (a['essid'], a['bssid'], a['encrypted'], a['iface'], a['maxrate'], a['signal']) ) for entry in tmpList: if entry[0] == "": for compentry in compList: if compentry[1] == entry[1]: compList.remove(compentry) for entry in compList: self.cleanList.append( ( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] ) ) if not self.oldlist.has_key(entry[0]): self.oldlist[entry[0]] = { 'data': entry } else: self.oldlist[entry[0]]['data'] = entry for entry in self.cleanList: self.APList.append(self.buildEntryComponent( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] )) if refresh is False: self['list'].setList(self.APList) self.listLength = len(self.APList) self.setInfo() self.rescanTimer.start(5000) return self.cleanList
def scanApList(self): self.apList = iWlan.getNetworkList() print "GET APLIST %d" % len(self.apList) old_aplist = self.setApList new_bssid_list = self.apList.keys() old_bssid_list = [x[1] for x in old_aplist] remove_bssid_list = [ x for x in old_aplist if x[1] not in new_bssid_list ] add_bssid_list = [x for x in new_bssid_list if x not in old_bssid_list] for x in remove_bssid_list: self.setApList.remove(x) for bssid in add_bssid_list: essid = self.apList[bssid].get("ESSID", None) if essid is None: global SHOW_HIDDEN_NETWORK if SHOW_HIDDEN_NETWORK: essid = "# Hidden Network" else: continue else: essid = essid.strip('\x00').strip('\\x00') if essid == "": continue self.setApList.append((essid, bssid)) self.setApList = sorted( self.setApList, key=lambda x: int(self.apList[x[1]]['Quality'].split('/')[0]), reverse=True) self["aplist"].setList(self.setApList) self["Status"].setText(("%d AP detected" % len(self.setApList))) self.displayApInfo() self.updateAPList()