Completed ACE update

This commit is contained in:
Fergal Moran
2013-09-24 20:55:12 +01:00
parent c6dbbb8632
commit 1acf06e85e
26 changed files with 142 additions and 147 deletions

View File

@@ -1,9 +1,11 @@
import shutil
from celery.task import task
import os
from django.contrib.gis.geoip import GeoIP
from core.utils.waveform import generate_waveform
from dss import settings
from spa.signals import waveform_generated
from spa.models.userprofile import UserProfile
@task(time_limit=3600)
def create_waveform_task(in_file, uid):
@@ -20,3 +22,23 @@ def create_waveform_task(in_file, uid):
waveform_generated.send(sender=None, uid=uid)
else:
print "Outfile is missing"
@task
def update_geo_info_task(ip_address, profile_id):
try:
ip = '188.141.70.110' if ip_address == '127.0.0.1' else ip_address
if ip:
g = GeoIP()
city = g.city(ip)
country = g.country(ip)
try:
user = UserProfile.objects.get(pk=profile_id)
user.city = city['city']
user.country = country['country_name']
user.save()
except ObjectDoesNotExist:
pass
print "Updated user location"
except Exception, e:
print e.message
pass