Here is my code:
for line in open(logfile):
if "ESSID" in line:
begin = line.replace(" ", "")
mid = begin.replace("ESSID:", "")
final = mid.replace('"', "")
print final
self.APList.SetStringItem(self.index, 0, final)
line = open(ilogfile).readline()
if begin in line:
connect = "yes"
else:
connect = "no"
self.APList.SetStringItem(self.index, 3, connect)
here is the file it’s scanning (well, one of them.):
wlp2s0 IEEE 802.11bgn ESSID:"MomAndKids"
Mode:Managed Frequency:2.462 GHz Access Point: E0:91:F5:7D:C9:14
Bit Rate=18 Mb/s Tx-Power=20 dBm
Retry long limit:7 RTS thr=2347 B Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=62/70 Signal level=-48 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:603 Missed beacon:0
The main code I’m trying to test:
line = open(ilogfile).readline()
if begin in line:
connect = "yes"
else:
connect = "no"
I’ve tried using “final” instead of “begin” and reading the whole file instead of the first line (using both “final” and “begin” variables.) Neither worked. Why is this not working?
For full source, it is available at:
https://github.com/codywd/WiFiz/blob/master/main.py
Edit: The indentation is only broken in stackoverflow, not in the actual code.
Edit 2: The other file contains this:
wlp2s0 Scan completed :
Cell 01 - Address: E0:91:F5:7D:C9:14
Channel:11
Frequency:2.462 GHz (Channel 11)
Quality=66/70 Signal level=-44 dBm
Encryption key:on
ESSID:"MomAndKids"
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=00000278820a146f
Extra: Last beacon: 80ms ago
IE: Unknown: 000A4D6F6D416E644B696473
IE: Unknown: 010882840B162430486C
IE: Unknown: 03010B
IE: Unknown: 2A0104
IE: Unknown: 2F0104
IE: Unknown: 32040C121860
The relevant portion is at the top of that file.
The following seemed to work fine: