Commit bf8acc53 authored by luxcem's avatar luxcem

updates logger

parent 3cbff9fe
......@@ -26,10 +26,7 @@ from representatives.tasks import import_representatives_from_compotista
class Command(BaseCommand):
"""
Command to import representative from a compotista server first
command call should not be in parallel (group and counstituency
would be created in double or triple), next calls could be or not in
parallel
Command to import representative from a compotista server
"""
def add_arguments(self, parser):
......
......@@ -24,7 +24,7 @@ from datetime import datetime
from django.db import models
from django.utils.functional import cached_property
from django.utils.encoding import smart_str
from django.utils.encoding import smart_str, smart_unicode
class TimeStampedModel(models.Model):
......@@ -124,7 +124,7 @@ class Representative(HashableModel, TimeStampedModel):
hashable_fields = ['remote_id']
def __unicode__(self):
return u'{} ({})'.format(self.full_name.decode('utf-8'), self.remote_id)
return u'{} ({})'.format(smart_unicode(self.full_name), self.remote_id)
def gender_as_str(self):
genders = {0: 'N/A', 1: 'F', 2: 'M'}
......
......@@ -33,16 +33,12 @@ from representatives.models import Representative, Group, Constituency, Mandate,
from representatives.serializers import RepresentativeDetailSerializer
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
steam_handler = logging.StreamHandler()
steam_handler.setLevel(logging.DEBUG)
logger.addHandler(steam_handler)
@shared_task
def import_a_representative(data, verbose=False):
'''
Import a representative from a serialized
Python datatypes
python datatypes
'''
# We use a lock to import only one representative at a time
......@@ -67,9 +63,7 @@ def import_a_representative(data, verbose=False):
@shared_task
def import_representatives_from_compotista(delay=False):
compotista_server = getattr(settings,
'COMPOTISTA_SERVER',
'http://compotista.mm.staz.be')
compotista_server = settings.COMPOTISTA_SERVER
import_start_datetime = timezone.now()
url = compotista_server + '/export/latest/'
res = urlopen(url)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment