Ignore:
Timestamp:
Apr 18, 2011, 7:45:51 PM (14 years ago)
Author:
dennisw
Message:

Cleanup of unused php files, cosmetic changes to dataimport.py since I noticed Rick's vim message. (Sorry about the TABS)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/gheat/management/commands/dataimport.py

    r9078 r9080  
    1111def import_file(location, meetrondje, gebruiker, email):
    1212
    13     datasource = etree.parse(location)
    14     doc = datasource.findall('wireless-network')
     13  datasource = etree.parse(location)
     14  doc = datasource.findall('wireless-network')
    1515
    16     g, created = Gebruiker.objects.get_or_create(naam=gebruiker , email=email)
    17     a, created = Apparatuur.objects.get_or_create(antenne='test' , kaart='test')
    18     mr = MeetRondje.objects.create(datum=datetime.datetime.now() , naam=meetrondje , gebruiker=g , apparatuur=a)
     16  g, created = Gebruiker.objects.get_or_create(naam=gebruiker , email=email)
     17  a, created = Apparatuur.objects.get_or_create(antenne='test' , kaart='test')
     18  mr = MeetRondje.objects.create(datum=datetime.datetime.now() , naam=meetrondje , gebruiker=g , apparatuur=a)
    1919
    20     for wnetwork in doc:
    21         enc = wnetwork.find('SSID/encryption')
    22         if enc != None: enc = 'true'
    23         else: enc = 'false'
    24         ssid = wnetwork.find('SSID/essid')
    25         if ssid != None: ssid = ssid.text
    26         else: ssid = 'hidden'
    27         bssid = wnetwork.find('BSSID')
    28         if bssid != None: bssid = bssid.text
    29         lat = wnetwork.find('gps-info/min-lat')
    30         if lat != None: lat = lat.text
    31         lon = wnetwork.find('gps-info/min-lon')
    32         if lon != None: lon = lon.text
    33         if ssid is None: continue
    34         print enc, ssid, bssid, lat, lon
     20  for wnetwork in doc:
     21    enc = wnetwork.find('SSID/encryption')
     22    if enc != None: enc = 'true'
     23    else: enc = 'false'
     24    ssid = wnetwork.find('SSID/essid')
     25    if ssid != None: ssid = ssid.text
     26    else: ssid = 'hidden'
     27    bssid = wnetwork.find('BSSID')
     28    if bssid != None: bssid = bssid.text
     29    lat = wnetwork.find('gps-info/min-lat')
     30    if lat != None: lat = lat.text
     31    lon = wnetwork.find('gps-info/min-lon')
     32    if lon != None: lon = lon.text
     33    if ssid is None: continue
     34    print enc, ssid, bssid, lat, lon
    3535
    36         ap, created = Accespoint.objects.get_or_create(mac=bssid, ssid=ssid, encryptie=enc)
    37         m = Meting.objects.create(meetrondje=mr, accespoint=ap, latitude=lat, longitude=lon, signaal=100)
     36    ap, created = Accespoint.objects.get_or_create(mac=bssid, ssid=ssid, encryptie=enc)
     37    m = Meting.objects.create(meetrondje=mr, accespoint=ap, latitude=lat, longitude=lon, signaal=100)
    3838
    3939
    4040class Command(BaseCommand):
    41     option_list = BaseCommand.option_list + (
    42         make_option('-f', '--location', dest='location', default='location'),
    43         make_option('-m', '--meetrondje', dest='meetrondje', default='rondje'),
    44         make_option('-g', '--gebruiker', dest='gebruiker', default='username'),
    45         make_option('-e', '--email', dest='email', default='foo@bar.org'),
     41  option_list = BaseCommand.option_list + (
     42    make_option('-f', '--location', dest='location', default='location'),
     43    make_option('-m', '--meetrondje', dest='meetrondje', default='rondje'),
     44    make_option('-g', '--gebruiker', dest='gebruiker', default='username'),
     45    make_option('-e', '--email', dest='email', default='foo@bar.org'),
    4646    )
    4747
    48     def handle(self, *args, **options):
    49         import_file(options['location'],options['meetrondje'],options['gebruiker'],options['email'])
     48  def handle(self, *args, **options):
     49    import_file(options['location'],options['meetrondje'],options['gebruiker'],options['email'])
Note: See TracChangeset for help on using the changeset viewer.