Changeset 9618 for src/django_gheat/gheat/management
- Timestamp:
- Aug 30, 2011, 2:13:01 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/management/commands/netstumbler.py
r9602 r9618 5 5 # Rick van der Zwet <info@rickvanderzwet.nl> 6 6 # 7 import sys8 7 import datetime 8 from struct import unpack 9 9 10 from struct import * 11 12 def parse_netstumbler(filename): 13 fh = open(filename,'rb') 14 10 def parse_netstumbler(fh): 15 11 def get_int32(size=1): 16 12 v = unpack('<' + 'i'*size,fh.read(4*size)) … … 43 39 return v[0] if size == 1 else v 44 40 41 def get_mac(): 42 return ':'.join(["%02X" % x for x in unpack('BBBBBB',fh.read(6))]) 43 45 44 data = {} 46 45 … … 56 55 ap["SSIDLength"] = SSIDLength 57 56 ap["SSID"] = get_char(SSIDLength) 58 ap["BSSID"] = map(hex,unpack('BBBBBB',fh.read(6)))57 ap["BSSID"] = get_mac() 59 58 ap["MaxSignal"] = get_int32() 60 59 ap["MinNoise"] = get_int32() … … 68 67 DataCount = get_uint32() 69 68 ap["DataCount"] = DataCount 70 ap["measurement "] = []69 ap["measurements"] = [] 71 70 for c in range(0,DataCount): 72 71 ms = {} … … 75 74 ms["Noice"] = get_int32() 76 75 LocationSource = get_int32() 77 ms["Location 76 ms["LocationSource"] = LocationSource 78 77 if LocationSource == 1: 79 78 ms["Latitude"] = get_double() … … 85 84 ms["MagVariation"] = get_double() 86 85 ms["Hdop"] = get_double() 87 ap["measurement "].append(ms)86 ap["measurements"].append(ms) 88 87 NameLength = get_uint8() 89 88 ap["NameLength"] = NameLength … … 104 103 return data 105 104 106 print parse_netstumbler(sys.argv[1]) 105 if __name__ == '__main__': 106 import sys 107 import pprint 108 pp = pprint.PrettyPrinter(indent=2) 109 pp.pprint(parse_netstumbler(open(sys.argv[1],'r')))
Note:
See TracChangeset
for help on using the changeset viewer.