#!/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 *
from lxml import etree

doc = etree.parse('/home/dennis/Desktop/test.netxml')
test = doc.findall('wireless-network')

for wnetwork in test:
    bssid = wnetwork.find('BSSID')
    print bssid.text
    manuf = wnetwork.find('manuf')
    print manuf.text

#    attr = wnetwork.attrib
#    print(attr['BSSID'])
#    print(attr['lon'])

#    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.objects.get_or_create(naam= , email= )
#    g.save()
#    a = Apparatuur.objects.get_or_create(antenne= , kaart= )
#    a.save()
#    mr = MeetRondje.objects.create(datum= , naam= , gebruiker_id=g.id , apparatuur_id=a.id )
#    mr.save()
#    ap = Accespoint.objects.get_or_create(mac= , ssid= , encryptie= )
#    ap.save()
#    m = Meting.objects.create(meetrondje_id=mr.id, accespoint_id=ap.id, latitude= , longitude= , signaal= )
#    m.save()
