1 | #!/usr/bin/env python
|
---|
2 | from django.core.management import setup_environ
|
---|
3 | import settings
|
---|
4 | setup_environ(settings)
|
---|
5 | from gheat.models import *
|
---|
6 | from lxml import etree
|
---|
7 |
|
---|
8 | datasource = etree.parse('/home/dennis/Desktop/test2.netxml')
|
---|
9 | doc = datasource.findall('wireless-network')
|
---|
10 |
|
---|
11 | for 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()
|
---|