Changeset 9069
- Timestamp:
- Apr 18, 2011, 11:22:24 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/dataimport.py
r9050 r9069 3 3 import settings 4 4 setup_environ(settings) 5 from xml.dom.minidom import parse5 #from xml.dom.minidom import parse 6 6 from gheat.models import * 7 from lxml import etree 7 8 8 d atasource = open('/home/dennis/Desktop/test.netxml')9 dom = parse(datasource)9 doc = etree.parse('/home/dennis/Desktop/test.netxml') 10 test = doc.findall('wireless-network') 10 11 11 for wnetwork in dom.getElementsByTagName('wireless-network'): 12 for bssid in wnetwork.getElementsByTagName('BSSID'): 13 bssid = bssid.firstChild.nodeValue 14 print bssid 15 for manuf in wnetwork.getElementsByTagName('manuf'): 16 manuf = manuf.firstChild.nodeValue 17 print manuf 18 for enc in wnetwork.getElementsByTagName('encryption'): 19 enc = enc.firstChild.nodeValue 20 print enc 21 for ssid in wnetwork.getElementsByTagName('ssid'): 22 ssid = ssid.firstChild.nodeValue 23 print ssid 24 for lat in wnetwork.getElementsByTagName('min-lat'): 25 lat = lat.firstChild.nodeValue 26 print lat 27 for lon in wnetwork.getElementsByTagName('min-lon'): 28 lon = lon.firstChild.nodeValue 29 print lon 12 for wnetwork in test: 13 bssid = wnetwork.find('BSSID') 14 print bssid.text 15 manuf = wnetwork.find('manuf') 16 print manuf.text 30 17 31 g = Gebruiker(naam= , email= ) 32 g.save() 33 a = Apparatuur(antenne= , kaart= ) 34 a.save() 35 mr = MeetRondje(datum= , naam= , gebruiker_id=g.id , apparatuur_id=a.id ) 36 mr.save() 37 ap = Accespoint(mac= , ssid= , encryptie= ) 38 ap.save() 39 m = Meting(meetrondje_id=mr.id, accespoint_id=ap.id, latitude= , longitude= , signaal= ) 40 m.save() 18 # attr = wnetwork.attrib 19 # print(attr['BSSID']) 20 # print(attr['lon']) 41 21 22 # for bssid in wnetwork.getElementsByTagName('BSSID'): 23 # bssid = bssid.firstChild.nodeValue 24 # print bssid 25 # for manuf in wnetwork.getElementsByTagName('manuf'): 26 # manuf = manuf.firstChild.nodeValue 27 # print manuf 28 # for enc in wnetwork.getElementsByTagName('encryption'): 29 # enc = enc.firstChild.nodeValue 30 # print enc 31 # for ssid in wnetwork.getElementsByTagName('ssid'): 32 # ssid = ssid.firstChild.nodeValue 33 # print ssid 34 # for lat in wnetwork.getElementsByTagName('min-lat'): 35 # lat = lat.firstChild.nodeValue 36 # print lat 37 # for lon in wnetwork.getElementsByTagName('min-lon'): 38 # lon = lon.firstChild.nodeValue 39 # print lon 42 40 41 # g = Gebruiker.objects.get_or_create(naam= , email= ) 42 # g.save() 43 # a = Apparatuur.objects.get_or_create(antenne= , kaart= ) 44 # a.save() 45 # mr = MeetRondje.objects.create(datum= , naam= , gebruiker_id=g.id , apparatuur_id=a.id ) 46 # mr.save() 47 # ap = Accespoint.objects.get_or_create(mac= , ssid= , encryptie= ) 48 # ap.save() 49 # m = Meting.objects.create(meetrondje_id=mr.id, accespoint_id=ap.id, latitude= , longitude= , signaal= ) 50 # m.save()
Note:
See TracChangeset
for help on using the changeset viewer.