Ignore:
Timestamp:
Dec 23, 2011, 9:16:20 AM (13 years ago)
Author:
rick
Message:

Importer fails if one file files, this makes it more reliable...

File:
1 edited

Legend:

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

    r9819 r9823  
    123123    apparatuur, created = Apparatuur.objects.get_or_create(kaart=options['kaart'])
    124124
     125    # Meetrondje is deducted and checked from first filename
     126    filename = args[0]
     127    logger.info("Processing '%s'" % filename)
     128    meetrondje, created = MeetRondje.objects.get_or_create(
     129      datum=get_date(filename), naam=get_meetrondje(filename),
     130      gebruiker=gebruiker, apparatuur=apparatuur)
     131    if not options['force'] and not created:
     132      raise CommandError("Meetrondje '%s' already imported",  meetrondje)
     133
    125134    # Check if all files are valid
    126135    for filename in args:
    127       logger.info("Processing '%s'" % filename)
    128       meetrondje, created = MeetRondje.objects.get_or_create(
    129         datum=get_date(filename), naam=get_meetrondje(filename),
    130         gebruiker=gebruiker, apparatuur=apparatuur)
    131       if not options['force'] and not created:
    132         logger.error("Meetrondje '%s' already imported",  meetrondje)
    133         continue
    134 
    135136      logger.info('Meetrondje: %s', meetrondje)
    136137      meetbestand = MeetBestand(meetrondje=meetrondje,is_imported=True)
Note: See TracChangeset for help on using the changeset viewer.