#!/usr/bin/env python
from django.core.management import setup_environ
import settings
setup_environ(settings)
from xml.dom.minidom import parse
from gheat.models import *

datasource = open('/home/dennis/Desktop/test.netxml')
dom = parse(datasource)

for wnetwork in dom.getElementsByTagName('wireless-network'):
    for bssid in wnetwork.getElementsByTagName('BSSID'):
        bssid = bssid.firstChild.nodeValue
        print bssid
    for manuf in wnetwork.getElementsByTagName('manuf'):
        manuf = manuf.firstChild.nodeValue
        print manuf
    for enc in wnetwork.getElementsByTagName('encryption'):
        enc = enc.firstChild.nodeValue
        print enc
    for ssid in wnetwork.getElementsByTagName('ssid'):
        ssid = ssid.firstChild.nodeValue
        print ssid
    for lat in wnetwork.getElementsByTagName('min-lat'):
        lat = lat.firstChild.nodeValue
        print lat
    for lon in wnetwork.getElementsByTagName('min-lon'):
        lon = lon.firstChild.nodeValue
        print lon

    g = Gebruiker(naam= , email= )
    g.save()
    a = Apparatuur(antenne= , kaart= )
    a.save()
    mr = MeetRondje(datum= , naam= , gebruiker_id=g.id , apparatuur_id=a.id )
    mr.save()
    ap = Accespoint(mac= , ssid= , encryptie= )
    ap.save()
    m = Meting(meetrondje_id=mr.id, accespoint_id=ap.id, latitude= , longitude= , signaal= )
    m.save()


