[pisa-src] r2939 - trunk/tools/iwlist_parser.py

  • From: Rene Hummen <Rene.Hummen@xxxxxxxxxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 21 Mar 2012 23:17:50 +0100

Author: hummen
Date: Wed Mar 21 23:17:49 2012
New Revision: 2939

Log:
further unify iwlist parser

it now also processes iwlist output on an n900.

Modified:
   trunk/tools/iwlist_parser.py

Modified: trunk/tools/iwlist_parser.py
==============================================================================
--- trunk/tools/iwlist_parser.py        Wed Mar 21 20:56:35 2012        (r2938)
+++ trunk/tools/iwlist_parser.py        Wed Mar 21 23:17:49 2012        (r2939)
@@ -1,3 +1,5 @@
+#!/usr/bin/python
+
 import argparse
 import re
 import os
@@ -20,24 +22,23 @@
     global found_aps
     ap_mac = None
     ap_strength = 0
-    ap_ssid = None
+    found = 0
 
     for line in os.popen("/sbin/iwlist wlan0 scanning"):
         # reset variables to defaults for each AP in the list
         if re.search('(C|c)ell', line):
-            ap_ssid = None
             ap_mac = None
+            found = 0
             if quality == True:
                 ap_strength = 0
             else:
                 ap_strength = 100
-
         if re.search('(A|a)ddress', line):
             elements = line.split()
             ap_mac = elements[4]
         elif quality == False and re.search('(S|s)ignal level', line):
             elements = line.split()
-            tmp_strength = elements[2].split('=-')
+            tmp_strength = elements[2].split('-')
             ap_strength = int(tmp_strength[1])
         elif quality == True and re.search('(Q|q)uality', line):
             elements = line.split()
@@ -46,10 +47,12 @@
             ap_strength = int(tmp_strength[0])
         elif re.search('ESSID', line):
             if pattern == None:
-                found_aps[ap_mac] = ap_strength
+                found = 1
             elif re.search(pattern, line):
-                found_aps[ap_mac] = ap_strength
+                found = 1
 
+        if ap_mac != None and ap_strength != 0 and found == 1:
+            found_aps[ap_mac] = ap_strength
 def find_best_ap_by_signal_level():
     best_ap = None
     best_level = 100
-- 
This is the pisa developer mailing list. Please also subscribe to the main pisa 
list at:
//www.freelists.org/list/pisa

Other related posts: