source: src/django_gheat/gheat/management/commands/droidstumbler.py@ 9628

Last change on this file since 9628 was 9623, checked in by rick, 14 years ago

Merge and migrate all files into common files to get rid of all duplicate codes.

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Rick van der Zwet <info@rickvanderzwet.nl>
5#
6import csv
7import logging
8
9from collections import defaultdict
10
11logger = logging.getLogger(__name__)
12logger.setLevel(logging.DEBUG)
13
14def process_csv(fh, counters):
15 """ Import all points, return tuple with summary"""
16
17 # Temponary holders
18 meting_pool = defaultdict(list)
19 ap_pool = {}
20
21 csvfile = csv.reader(fh, delimiter=',')
22 # Process file, preparing new access points and measurements
23 for row in csvfile:
24 try:
25 epoch, msg_type, lat, lon, accuracy, ssid, bssid, level, frequency, capabilities = row
26 bssid = bssid.upper()
27 except ValueError:
28 # Known error, please ignore
29 if row[1] == 'gps' and len(row) == 12: continue
30 logger.error("Unable to parse line:%i '%s'" % (csvfile.line_num, row))
31 continue
32 if msg_type == "data" and lat and lon:
33 counters['meting_total'] += 1
34 if not ap_pool.has_key(bssid):
35 encryption = 'WPA' in capabilities or 'WEP' in capabilities
36 ap_pool[bssid] = (ssid, encryption)
37
38 # We store the best value found
39 key = (bssid, lat, lon)
40 signaal=(100 + int(level))
41 meting_pool[key].append(signaal)
42
43 return (counters, ap_pool, None, meting_pool)
Note: See TracBrowser for help on using the repository browser.