Ignore:
Timestamp:
Aug 28, 2011, 9:01:12 PM (13 years ago)
Author:
rick
Message:

Saves a whole bunch of casting on a later stage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/gheat/management/commands/netstumbler.py

    r9601 r9602  
    1414 
    1515  def get_int32(size=1):
    16     return unpack('<' + 'i'*size,fh.read(4*size))
     16    v = unpack('<' + 'i'*size,fh.read(4*size))
     17    return v[0] if size == 1 else v
    1718 
    1819  def get_uint32(size=1):
    19     return unpack('<' + 'I'*size,fh.read(4*size))
     20    v = unpack('<' + 'I'*size,fh.read(4*size))
     21    return v[0] if size == 1 else v
    2022 
    2123  def get_uint64(size=1):
    22     return unpack('<' + 'Q'*size,fh.read(8*size))
     24    v = unpack('<' + 'Q'*size,fh.read(8*size))
     25    return v[0] if size == 1 else v
    2326 
    2427  def get_uint8(size=1):
    25     return unpack('<' + 'B'*size,fh.read(1*size))
     28    v = unpack('<' + 'B'*size,fh.read(1*size))
     29    return v[0] if size == 1 else v
    2630 
    2731  def get_filetime():
     
    3640 
    3741  def get_double(size=1):
    38     return unpack('<' + 'd'*size,fh.read(8*size))
     42    v = unpack('<' + 'd'*size,fh.read(8*size))
     43    return v[0] if size == 1 else v
    3944 
    4045  data = {}
     
    4247  data["dwSignature"] = get_char(4)
    4348  data["dwFileVerunpack"] = get_uint32()
    44   ApCount = get_uint32()[0]
     49  ApCount = get_uint32()
    4550  data["ApCount"] = ApCount
    4651 
     
    4853  for a in range(0,ApCount):
    4954    ap = {}
    50     SSIDLength = get_uint8()[0]
     55    SSIDLength = get_uint8()
    5156    ap["SSIDLength"] = SSIDLength
    5257    ap["SSID"] = get_char(SSIDLength)
     
    6166    ap["BestLat"] = get_double()
    6267    ap["BestLong"] = get_double()
    63     DataCount = get_uint32()[0]
     68    DataCount = get_uint32()
    6469    ap["DataCount"] = DataCount
    6570    ap["measurement"] = []
     
    6974      ms["Signal"] = get_int32()
    7075      ms["Noice"] = get_int32()
    71       LocationSource = get_int32()[0]
     76      LocationSource = get_int32()
    7277      ms["Location Source"] = LocationSource
    7378      if LocationSource == 1:
     
    8186        ms["Hdop"] = get_double()
    8287      ap["measurement"].append(ms)
    83     NameLength = get_uint8()[0]
     88    NameLength = get_uint8()
    8489    ap["NameLength"] = NameLength
    8590    ap["Name"] = get_char(NameLength)
     
    9398    ap["IPMask"] = get_uint32()
    9499    ap["ApFlags"] = get_uint32()
    95     IELength = get_uint32()[0]
     100    IELength = get_uint32()
    96101    ap["IELength"] = IELength
    97102    ap["InformationElements"] = get_uint8(IELength)
Note: See TracChangeset for help on using the changeset viewer.