- Timestamp:
- May 8, 2011, 9:31:41 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/management/commands/import_kismet.py
r9158 r9168 51 51 print "#INFO: Going to import %s points" % len(points) 52 52 for point in points: 53 #XXX: This needs to be either the 'bssid' or the 'source', accesspoint from or too data. 54 bssid = point.attrib['bssid'] 53 55 # XXX: Filter this in the beginning with XPath, but etree does not support that (yet). 54 if point.attrib['bssid']in ['GP:SD:TR:AC:KL:OG','00:00:00:00:00:00']:56 if bssid in ['GP:SD:TR:AC:KL:OG','00:00:00:00:00:00']: 55 57 continue 56 if point.attrib['bssid']in ap_ignore:58 elif bssid in ap_ignore: 57 59 continue 58 ap = ap_cache[point.attrib['bssid']] 60 elif not ap_cache.has_key(bssid): 61 try: 62 ap = Accespoint.objects.get(mac=bssid) 63 ap_cache[bssid] = ap 64 except Accespoint.DoesNotExist: 65 print "#ERROR: Cannot found SSID for BSSID '%s'" % bssid 66 continue 59 67 60 68 # XXX: Signal need properly be a relation of signal_dbm and noice_dbm 61 69 signaal = 100 + int(point.attrib['signal_dbm']) 62 70 63 meting ,created = Meting.objects.get_or_create(meetrondje=mr, accespoint=ap,71 meting= Meting.objects.create(meetrondje=mr, accespoint=ap_cache[bssid], 64 72 latitude=point.attrib['lat'], longitude=point.attrib['lon'], 65 73 signaal=signaal) 66 74 # Give some feedback to the user 67 if created: 68 count += 1 69 if (count % 1000) == 0: 70 print count, 71 elif (count % 100) == 0: 72 print ".", 75 count += 1 76 if (count % 1000) == 0: 77 sys.stdout.write(str(count)) 78 elif (count % 100) == 0: 79 sys.stdout.write(".") 80 sys.stdout.flush() 81 82 sys.stdout.write("%s\n" % count) 83 print "#INFO: All done, goodbye" 84 73 85 74 86 class Command(BaseCommand): 75 args = '<gpsxml> <netxml>'87 args = '<gpsxml> [<netxml>]' 76 88 option_list = BaseCommand.option_list + ( 77 89 make_option('-m', '--meetrondje', dest='meetrondje', default='rondje',help='Naam van het meetrondje'), … … 80 92 ) 81 93 82 # TODO: Condider netxml file to be the gpsxml file with diffent suffix.83 94 def handle(self, *args, **options): 84 95 try: 85 (gpsxml_file, netxml_file) = args 96 if len(args) == 2: 97 (gpsxml_file, netxml_file) = args 98 elif len(args) == 1: 99 (gpsxml_file,) = args 100 netxml_file = gpsxml_file[:-6] + 'netxml' 101 else: 102 raise ValueError 86 103 except ValueError: 87 104 self.print_help(sys.argv[0],sys.argv[1])
Note:
See TracChangeset
for help on using the changeset viewer.