def _parse_ap(self, cell): """Parse a single cell from the python-iwscan list.""" ap = {} try: ap['essid'] = misc.to_unicode(cell['essid']) except UnicodeError: print('Unicode problem with the current network essid, ignoring!!') return None if ap['essid'] in ["", '<hidden>']: ap['essid'] = '<hidden>' ap['hidden'] = True else: ap['hidden'] = False if cell["channel"]: ap["channel"] = cell["channel"] else: ap["channel"] = self._FreqToChannel(cell["frequency"]) ap["bssid"] = cell["bssid"] ap["mode"] = cell["mode"] ap["bitrates"] = cell["bitrate"] if cell["enc"]: ap["encryption"] = True if cell["ie"] and cell["ie"].get('type'): if "WPA2" in cell['ie']['type'].upper(): ap['encryption_method'] = 'WPA2' elif "WPA" in cell['ie']['type'].upper(): ap['encryption_method'] = 'WPA' else: ap['encryption_method'] = 'WEP' else: ap["encryption"] = False # Link Quality ap['qual_found'] = True ap['quality'] = self._get_link_quality(cell['stats']) if ap['quality'] is None: ap['qual_found'] = False ap['quality'] = -1 # Signal Strength (only used if user doesn't want link # quality displayed or it isn't found) if misc.RunRegex(signaldbm_pattern, cell["stats"]): ap['strength'] = misc.RunRegex(signaldbm_pattern, cell["stats"]) # This is already set for ralink elif self.wpa_driver != RALINK_DRIVER: ap['strength'] = -1 return ap
def test_run_invalid_regex(self): import re regex = re.compile('.*(ABC.EFG).*') found = misc.RunRegex(regex, '01234ABCEDFG56789') self.assertEqual(found, None)