Skip to content

Commit

Permalink
fix exists.. call as func
Browse files Browse the repository at this point in the history
  • Loading branch information
mossplix committed Jun 11, 2012
1 parent 54899e2 commit 80c2342
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions ureport/management/commands/fix_kannel.py
Expand Up @@ -29,15 +29,21 @@ def handle(self, **options):
lines=f.readlines()
for line in lines:
parts=line.strip().rsplit('[FID:]')[1].split('] [')
identity=num.search(parts[0]).groups()[0]
message_text=parts[3].rsplit(':')[-1]
msg=Message.objects.filter(connection__identity=identity,text=message_text,direction="I")
if msg.exists:
identity=num.search(parts[1]).groups()[0]
message_text=parts[4].rsplit(':')[-1]
try:
connection=Connection.objects.get(identity=identity)
msg=Message.objects.filter(connection__identity=identity,text=message_text,direction="I")
if msg.exists():
pass
else:

msg=Message.objects.create(connection__identity=identity,text=message_text,direction="I")
print "created "+msg.text
if poll.objects.filter(pk=connection.contact.pk):
poll.process_response(msg)
except Connection.DoesNotExist:
pass
else:

msg=Message.objects.create(connection__identity=identity,text=message_text,direction="I")
print "created "+msg.text
poll.process_response(msg)


0 comments on commit 80c2342

Please sign in to comment.