- Timestamp:
- Aug 30, 2011, 6:13:57 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/management/commands/netstumbler.py
r9618 r9623 8 8 from struct import unpack 9 9 10 def parse_netstumbler(fh): 10 from collections import defaultdict 11 import logging 12 13 logger = logging.getLogger(__name__) 14 logger.setLevel(logging.INFO) 15 16 def parse_ns1(fh): 11 17 def get_int32(size=1): 12 18 v = unpack('<' + 'i'*size,fh.read(4*size)) … … 103 109 return data 104 110 111 def process_ns1(fh, counters): 112 data = parse_ns1(fh) 113 114 115 # Temponary holders 116 meting_pool = defaultdict(list) 117 ap_pool = {} 118 119 for ap in data['aps']: 120 # XXX: How is encryption coded? 121 encryption = False 122 ap_pool[ap['BSSID']]= (ap['SSID'], encryption) 123 for point in ap["measurements"]: 124 counters['meting_total'] += 1 125 if point['LocationSource'] == 0: 126 logger.debug("No GPS Coordinates found for BSSID %s @ %s", 127 ap['BSSID'], point['Time']) 128 counters['meting_ignored'] += 1 129 continue 130 # We store all values found, avg or max will be done later on 131 key = (ap['BSSID'], point["Latitude"], point["Longitude"]) 132 133 # Known measurement error 134 if point['Signal'] == -32767: continue 135 136 # XXX: Signal need properly be a relation of signal_dbm and noice_dbm 137 signaal= 100 + point['Signal'] 138 if signaal > 100 or signaal < 0: 139 logger.warning("Signal %s is not valid entry for BSSID %s @ %s", 140 point['Signal'], ap['BSSID'], point['Time']) 141 continue 142 meting_pool[key].append(signaal) 143 144 return (counters, ap_pool, None, meting_pool) 105 145 if __name__ == '__main__': 106 146 import sys 107 147 import pprint 108 148 pp = pprint.PrettyPrinter(indent=2) 109 pp.pprint(parse_n etstumbler(open(sys.argv[1],'r')))149 pp.pprint(parse_ns1(open(sys.argv[1],'r')))
Note:
See TracChangeset
for help on using the changeset viewer.