Changeset 9072
- Timestamp:
- Apr 18, 2011, 3:12:48 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/dataimport.py
r9069 r9072 3 3 import settings 4 4 setup_environ(settings) 5 #from xml.dom.minidom import parse6 5 from gheat.models import * 7 6 from lxml import etree 8 7 9 d oc = etree.parse('/home/dennis/Desktop/test.netxml')10 test = doc.findall('wireless-network')8 datasource = etree.parse('/home/dennis/Desktop/test2.netxml') 9 doc = datasource.findall('wireless-network') 11 10 12 for wnetwork in test: 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' 13 18 bssid = wnetwork.find('BSSID') 14 print bssid.text 15 manuf = wnetwork.find('manuf') 16 print manuf.text 17 18 # attr = wnetwork.attrib 19 # print(attr['BSSID']) 20 # print(attr['lon']) 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 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 40 26 41 27 # g = Gebruiker.objects.get_or_create(naam= , email= ) … … 45 31 # mr = MeetRondje.objects.create(datum= , naam= , gebruiker_id=g.id , apparatuur_id=a.id ) 46 32 # 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()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 TracChangeset
for help on using the changeset viewer.