Skip to content
Snippets Groups Projects
Commit bbbb87cf authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

cleaned up host import code.

parent d9881962
No related branches found
No related tags found
No related merge requests found
...@@ -36,25 +36,30 @@ ORDER BY titel, beginn, ende""") ...@@ -36,25 +36,30 @@ ORDER BY titel, beginn, ende""")
hosts = [] hosts = []
for macher in macher.decode('latin1').encode('utf8').split(','): for macher in macher.decode('latin1').encode('utf8').split(','):
macher = macher.strip()
try: try:
host = Host.objects.get(name=macher.strip()) host = Host.objects.get(name=macher)
hosts.append(host)
except MultipleObjectsReturned: except MultipleObjectsReturned:
print 'multiple hosts with name "%s" found' % macher print 'multiple hosts with name "%s" found' % macher
except ObjectDoesNotExist: except ObjectDoesNotExist:
print 'host with name "%s" not found' % macher print 'host with name "%s" not found' % macher
else:
hosts.append(host)
try: try:
show = Show.objects.get(name=titel) show = Show.objects.get(name=titel)
print 'sendung "%s" already imported as show "%s"' % (titel, show) print 'sendung "%s" already imported as show "%s"' % (titel, show)
except ObjectDoesNotExist: except ObjectDoesNotExist:
show = Show(broadcastformat=TALK, name=titel, slug=slug, short_description='FIXME', description=beschreibung) show = Show(broadcastformat=TALK, name=titel, slug=slug, short_description='FIXME', description=beschreibung)
show.save() try:
counter += 1
for h in hosts:
show.hosts.add(h)
show.save() show.save()
counter += 1
except:
print 'ERR: sendung "%s" could not be imported' % titel
else:
for h in hosts:
show.hosts.add(h)
show.save()
cursor.close() cursor.close()
connection.close() connection.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment