source: src/django_gheat/gheat/dataimport.py@ 9072

Last change on this file since 9072 was 9072, checked in by dennisw, 14 years ago

dataimport.py - werkt soort van, import data naar gheat_meting en gheat_accespoint, rest volgt. SSID's zonder naam worden tijdelijk geskipped wegens 'None' problemen.

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/env python
2from django.core.management import setup_environ
3import settings
4setup_environ(settings)
5from gheat.models import *
6from lxml import etree
7
8datasource = etree.parse('/home/dennis/Desktop/test2.netxml')
9doc = datasource.findall('wireless-network')
10
11for wnetwork in doc:
12 enc = wnetwork.find('SSID/encryption')
13 if enc != None: enc = 'true'
14 else: enc = 'false'
15 ssid = wnetwork.find('SSID/essid')
16 if ssid != None: ssid = ssid.text
17 else: ssid = 'hidden'
18 bssid = wnetwork.find('BSSID')
19 if bssid != None: bssid = bssid.text
20 lat = wnetwork.find('gps-info/min-lat')
21 if lat != None: lat = lat.text
22 lon = wnetwork.find('gps-info/min-lon')
23 if lon != None: lon = lon.text
24 if ssid is None: continue
25 print enc, ssid, bssid, lat, lon
26
27# g = Gebruiker.objects.get_or_create(naam= , email= )
28# g.save()
29# a = Apparatuur.objects.get_or_create(antenne= , kaart= )
30# a.save()
31# mr = MeetRondje.objects.create(datum= , naam= , gebruiker_id=g.id , apparatuur_id=a.id )
32# mr.save()
33 ap = Accespoint(mac=bssid, ssid=ssid, encryptie=enc)
34 ap.save()
35 m = Meting(meetrondje_id=1, accespoint_id=ap.id, latitude=lat, longitude=lon, signaal=100)
36 m.save()
Note: See TracBrowser for help on using the repository browser.