Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions iwlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

cellNumberRe = re.compile(r"^Cell\s+(?P<cellnumber>.+)\s+-\s+Address:\s(?P<mac>.+)$")
regexps = [
re.compile(r"^ESSID:\"(?P<essid>.*)\"$"),
re.compile(r"^ESSID: \"(?P<essid>.*)\"$"),
re.compile(r"^Protocol:(?P<protocol>.+)$"),
re.compile(r"^Mode:(?P<mode>.+)$"),
re.compile(r"^Frequency:(?P<frequency>[\d.]+) (?P<frequency_units>.+) \(Channel (?P<channel>\d+)\)$"),
re.compile(r"^Encryption key:(?P<encryption>.+)$"),
re.compile(r"^Encryption: (?P<encryption>.+)$"),
re.compile(r"^Quality=(?P<signal_quality>\d+)/(?P<signal_total>\d+)\s+Signal level=(?P<signal_level_dBm>.+) d.+$"),
re.compile(r"^Signal level=(?P<signal_quality>\d+)/(?P<signal_total>\d+).*$"),
]
Expand All @@ -20,7 +20,7 @@
# Must run as super user.
# Does not specify a particular device, so will scan all network devices.
def scan(interface='wlan0'):
cmd = ["iwlist", interface, "scan"]
cmd = ["iwinfo", interface, "scan"]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
points = proc.stdout.read().decode('utf-8')
return points
Expand All @@ -44,12 +44,6 @@ def parse(content):
for expression in regexps:
result = expression.search(line)
if result is not None:
if 'encryption' in result.groupdict() :
if result.groupdict()['encryption'] == 'on' :
cells[-1].update({'encryption': 'wep'})
else :
cells[-1].update({'encryption': 'off'})
else :
cells[-1].update(result.groupdict())
cells[-1].update(result.groupdict())
continue
return cells