diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-03-24 16:18:36 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-03-24 16:18:36 (GMT) |
commit | 957661c9b9fbefd1a2e7302911fe2e3e793f34ef (patch) | |
tree | 010eeba446ff885e8061dcfd50cc64e0a93a06a8 | |
parent | 6bd65d0a0e8509a57dde032a0a29c102ce47e0f1 (diff) |
updated program slot import to be more robust.
-rw-r--r-- | program/management/commands/importprogramslots.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/program/management/commands/importprogramslots.py b/program/management/commands/importprogramslots.py index 4d71afa..8739bbb 100644 --- a/program/management/commands/importprogramslots.py +++ b/program/management/commands/importprogramslots.py @@ -44,15 +44,18 @@ WHERE letzter_termin > current_date AND titel NOT LIKE 'Musikprogramm' AND titel try: rrule = RRULES[rhytmus] - try: show = Show.objects.get(name=titel) - - programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, tstart=tstart, tend=tend, until=letzter_termin) - programslot.save() - counter += 1 except ObjectDoesNotExist: print 'show with name "%s" not found' % titel + else: + programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, tstart=tstart, + tend=tend, until=letzter_termin) + try: + programslot.save() + counter += 1 + except: + pass except KeyError: print 'rhythmus "%i" is not supported for sendung "%s"' % (rhytmus, titel) @@ -73,15 +76,17 @@ WHERE letzter_termin > current_date AND titel LIKE '%%(Wiederholung)'""") try: rrule = RRULES[rhytmus] - try: show = Show.objects.get(name=titel) - - programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, tstart=tstart, tend=tend, until=letzter_termin, is_repetition=True) - programslot.save() - counter += 1 except ObjectDoesNotExist: print 'show with name "%s" not found' % titel + else: + programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, tstart=tstart, tend=tend, until=letzter_termin, is_repetition=True) + try: + programslot.save() + counter += 1 + except: + pass except KeyError: print 'rhythmus "%i" is not supported for sendung "%s"' % (rhytmus, titel) |