Changeset 9180 for src/django_gheat
- Timestamp:
- May 12, 2011, 7:51:59 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/management/commands/import_droidstumbler.py
r9179 r9180 31 31 32 32 def import_droidstumbler(location, meetrondje, gebruiker, email, datum,show_progres=False): 33 33 """ Import all points, return tuple with summary""" 34 34 g, created = Gebruiker.objects.get_or_create(naam=gebruiker , email=email) 35 35 a, created = Apparatuur.objects.get_or_create(antenne='buildin' , kaart='mobilePhone') 36 36 mr, created = MeetRondje.objects.get_or_create(datum=datum , naam=meetrondje , gebruiker=g , apparatuur=a) 37 37 38 meting_count = 0 39 new_ap_count = 0 38 40 ap_cache = {} 39 41 meting_pool = {} … … 54 56 if not ap_cache.has_key(bssid): 55 57 ap_cache[bssid], created = Accespoint.objects.get_or_create(mac=bssid, ssid=ssid, encryptie=capabilities) 58 if created: new_ap_count += 1 56 59 57 60 # We store the best value found … … 65 68 66 69 # Import the data into the database 67 count = 070 meting_count = 0 68 71 for (ap,lat,lon),signal in meting_pool.iteritems(): 69 72 try: … … 75 78 # Give some feedback to the user 76 79 if show_progres: 77 count = user_feedback(count, 100, 1000)80 meting_count = user_feedback(meting_count, 100, 1000) 78 81 79 82 if show_progres: 80 sys.stdout.write("%s\n" % count) 83 sys.stdout.write("%s\n" % meting_count) 84 85 return (len(ap_cache), new_ap_count, meting_count, len(meting_pool) - meting_count) 81 86 82 87 … … 113 118 datum = datetime.datetime.strptime(datum,'%Y-%m-%d-%H%M%S') 114 119 except ValueError: 115 logging.error("Invalid date '%s'" % options['datum']) 116 sys.exit(1) 120 raise CommandError("Invalid date '%s'\n" % options['datum']) 117 121 118 self.stdout.write('Meetrondje: %s @ %s\n' % (meetrondje, datum)) 119 self.stdout.write("Going to import '%s' for gebruiker '%s <%s>'\n" % (os.path.basename(csv_file), options['gebruiker'], options['email'])) 120 import_droidstumbler(csv_file,meetrondje,options['gebruiker'],options['email'], datum, True) 121 self.stdout.write("All done, goodbye") 122 self.stdout.write('#INFO: Meetrondje: %s @ %s\n' % (meetrondje, datum)) 123 self.stdout.write("#INFO: Going to import '%s' for gebruiker '%s <%s>'\n" % (os.path.basename(csv_file), options['gebruiker'], options['email'])) 124 (ap_count, new_ap_count, meting_count, meting_error_count) = import_droidstumbler(csv_file,meetrondje,options['gebruiker'],options['email'], datum, True) 125 self.stdout.write("#INFO: Import summary accespoints: added:%s processed:%s\n" % (new_ap_count, ap_count)) 126 self.stdout.write("#INFO: Import summary metingen: added:%s error:%s\n" % (meting_count, meting_error_count))
Note:
See TracChangeset
for help on using the changeset viewer.