rockymeza/wifi — pull request #39 by rockymeza (2014-05-03 05:24:10+00:00)
Title: parsing error when missing channel in frequency line

I got the following error when calling Cell.all('wlan0'):
Traceback (most recent call last):
File "a.py", line 2, in
print Cell.all('wlan0')
File "/usr/local/lib/python2.7/dist-packages/wifi/scan.py", line 34, in all
cells = map(Cell.from_string, cells_re.split(iwlist_scan)[1:])
File "/usr/local/lib/python2.7/dist-packages/wifi/scan.py", line 44, in from_string
return normalize(cell_string)
File "/usr/local/lib/python2.7/dist-packages/wifi/scan.py", line 138, in normalize
frequency, channel = frequency_re.search(value).groups()
AttributeError: 'NoneType' object has no attribute 'groups'

Here is the output of iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: 58:6D:8F:2B:DA:8E
Channel:149
Frequency:5.745 GHz
Quality=65/70 Signal level=-45 dBm
Encryption key:on
ESSID:"3408TT"
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Master
Extra:tsf=0000000edea58e3a
Extra: Last beacon: 140ms ago
IE: Unknown: 0006333430385454
IE: Unknown: 01088C129824B048606C
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 2D1AEE081AFFFF000001000000000000000000000000000000000000
IE: Unknown: 3D16950D0000000000000000000000000000000000000000
IE: Unknown: DD090010180200F02C0000
IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
Cell 02 - Address: C8:3A:35:F8:05:C0
Channel:11
Frequency:2.462 GHz (Channel 11)
Quality=38/70 Signal level=-72 dBm
Encryption key:on
ESSID:"ruanruan"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 9 Mb/s
18 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 12 Mb/s; 24 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=000002f32927a101
Extra: Last beacon: 4880ms ago
IE: Unknown: 00087275616E7275616E
IE: Unknown: 010882848B961224486C
IE: Unknown: 03010B
IE: Unknown: 2A0104
IE: Unknown: 32040C183060
IE: Unknown: 2D1A6E1117FF000000010000000000000000000000000C0000000000
IE: Unknown: 3D160B070600000000000000000000000000000000000000
IE: Unknown: 3E0100
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101030003A4000027A4000042435E0062322F00
IE: Unknown: 0B05010012127A
IE: Unknown: 4A0E14000A002C01C800140005001900
IE: Unknown: DD07000C4304000000
IE: Unknown: 0706434E20010D10
Cell 03 - Address: CC:34:29:FB:DB:68
Channel:11
Frequency:2.462 GHz (Channel 11)
Quality=43/70 Signal level=-67 dBm
Encryption key:on
ESSID:"lizzy"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s
Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Master
Extra:tsf=0000000134e62194
Extra: Last beacon: 5108ms ago
IE: Unknown: 00056C697A7A79
IE: Unknown: 010882848B960C121824
IE: Unknown: 03010B
IE: Unknown: 2A0100
IE: Unknown: 32043048606C
IE: Unknown: 2D1A6E1003FF00000000000000000000000000000000000000000000
IE: Unknown: 3D160B071100000000000000000000000000000000000000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00
IE: Unknown: DD05000AEB0100
IE: Unknown: DD960050F204104A0001101044000102103B0001031047001000000000000010000000CC3429FBDB681021000754502D4C494E4B10230009544C2D57523734304E1024000B352E302F362E302F372E3010420007312E312E302E331054000800060050F204000110110018576972656C657373204E20526F757465722057523734304E100800022288103C0001011049000600372A000120
Cell 04 - Address: BC:F6:85:9F:60:51
Channel:11
Frequency:2.462 GHz (Channel 11)
Quality=22/70 Signal level=-88 dBm
Encryption key:on
ESSID:"D-Link_DIR-600M"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=000000010afebff5
Extra: Last beacon: 5284ms ago
IE: Unknown: 000F442D4C696E6B5F4449522D3630304D
IE: Unknown: 010882840B162430486C
IE: Unknown: 03010B
IE: Unknown: 2A0100
IE: Unknown: 2F0100
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
IE: Unknown: 32040C121860
IE: Unknown: 2D1A6C181BFF00000000000000000000000000000000000000000000
IE: Unknown: 3D160B001300000000000000000000000000000000000000
IE: Unknown: DD090010180207F0050000
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
IE: Unknown: DD1E00904C336C181BFF00000000000000000000000000000000000000000000
IE: Unknown: DD1A00904C340B001300000000000000000000000000000000000000
Cell 05 - Address: C8:D3:A3:31:12:8C
Channel:1
Frequency:2.412 GHz (Channel 1)
Quality=33/70 Signal level=-77 dBm
Encryption key:on
ESSID:"dlink"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s
Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Master
Extra:tsf=000000f054ee8f63
Extra: Last beacon: 5756ms ago
IE: Unknown: 0005646C696E6B
IE: Unknown: 010882848B960C121824
IE: Unknown: 030101
IE: Unknown: 2A0100
IE: Unknown: 32043048606C
IE: Unknown: 2D1A6E181EFF00000000000000000000000000000000000000000000
IE: Unknown: 3D1601051100000000000000000000000000000000000000
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : TKIP CCMP
Authentication Suites (1) : PSK
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : TKIP CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
IE: Unknown: DD8A0050F204104A0001101044000102103B0001031047001063041253101920061228C8D3A331128C1021000E442D4C696E6B2053797374656D73102300084449522D3630304C102400084449522D3630304C1042000D32303037303431332D303030311054000800060050F2040001101100084449522D3630304C1008000226881049000600372A000120
IE: Unknown: DD1E00904C336E181EFF00000000000000000000000000000000000000000000
IE: Unknown: DD1A00904C3401051100000000000000000000000000000000000000
IE: Unknown: DD0600E04C020160
Cell 06 - Address: 58:6D:8F:2B:DA:8D
Channel:6
Frequency:2.437 GHz (Channel 6)
Quality=65/70 Signal level=-45 dBm
Encryption key:on
ESSID:"3408DD"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=0000000ede5ae6ce
Extra: Last beacon: 5356ms ago
IE: Unknown: 0006333430384444
IE: Unknown: 010882848B962430486C
IE: Unknown: 030106
IE: Unknown: 2A0100
IE: Unknown: 2F0100
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 32040C121860
IE: Unknown: 2D1AEE181BFFFF000001000000000000000000000000000000000000
IE: Unknown: 3D16060F0400000000000000000000000000000000000000
IE: Unknown: DD090010180204F02C0000
IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
Cell 07 - Address: EC:88:8F:70:4A:D2
Channel:6
Frequency:2.437 GHz (Channel 6)
Quality=21/70 Signal level=-89 dBm
Encryption key:on
ESSID:"TP-LINK_xlfc"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s
Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Master
Extra:tsf=000000020a8359d7
Extra: Last beacon: 5540ms ago
IE: Unknown: 000C54502D4C494E4B5F786C6663
IE: Unknown: 010882848B960C121824
IE: Unknown: 030106
IE: Unknown: 0706555320010D14
IE: Unknown: 2A0100
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 32043048606C
IE: Unknown: 2D1A6E1003FFFF000000000000000000000000000000000000000000
IE: Unknown: 331A6E1003FFFF000000000000000000000000000000000000000000
IE: Unknown: 3D1606051500000000000000000000000000000000000000
IE: Unknown: 341606051500000000000000000000000000000000000000
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101030003A4000027A4000042435E0062322F00
IE: Unknown: DD0900037F01010000FF7F
IE: Unknown: DD800050F204104A0001101044000102103B0001031047001000000000000010000000EC888F704AD21021000754502D4C494E4B10230009544C2D57523834314E10240003312E3010420003312E301054000800060050F204000110110018576972656C657373204E20526F757465722057523834314E100800020086103C000101
Cell 08 - Address: 20:DC:E6:DF:8A:A2
Channel:6
Frequency:2.437 GHz (Channel 6)
Quality=16/70 Signal level=-94 dBm
Encryption key:on
ESSID:"TP-LINK_DF8AA2"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s
Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Master
Extra:tsf=00000314e0c3d3e5
Extra: Last beacon: 5536ms ago
IE: Unknown: 000E54502D4C494E4B5F444638414132
IE: Unknown: 010882848B960C121824
IE: Unknown: 030106
IE: Unknown: 050400010000
IE: Unknown: 0706555320010D14
IE: Unknown: 200100
IE: Unknown: 2A0100
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 32043048606C
IE: Unknown: 2D1A6E1003FFFF000000000000000000000000000000000000000000
IE: Unknown: 3D1606051100000000000000000000000000000000000000
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101030003A4000027A4000042435E0062322F00
IE: Unknown: DD0900037F01010000FF7F
IE: Unknown: DD0E0050F204104A0001101044000102
Cell 09 - Address: C8:3A:35:58:8B:08
Channel:8
Frequency:2.447 GHz (Channel 8)
Quality=18/70 Signal level=-92 dBm
Encryption key:on
ESSID:"Tenda_588B08"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=00000180aeb15183
Extra: Last beacon: 5336ms ago
IE: Unknown: 000C54656E64615F353838423038
IE: Unknown: 010882840B162430486C
IE: Unknown: 030108
IE: Unknown: 050401030000
IE: Unknown: 2A0100
IE: Unknown: 2F0100
IE: Unknown: 32040C121860
IE: Unknown: 2D1AFE181BFFFF000001000000000000000000000000000000000000
IE: Unknown: 3D16080F0000000000000000000000000000000000000000
IE: Unknown: DD090010180200F02C0000
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00

As you can see, there is one line like this:
Frequency:5.745 GHz
So the "frequency_re" doesn't work for it.