Changeset 9658 for src


Ignore:
Timestamp:
Sep 4, 2011, 1:46:35 PM (13 years ago)
Author:
rick
Message:

Little trick to import the currenly unimported files.

Location:
src/django_gheat/wlheatmap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/wlheatmap/__init__.py

    r9544 r9658  
    11from django.shortcuts import render_to_response
     2from django.http import HttpResponse
    23from django.conf import settings
     4from gheat.models import MeetBestand
     5from django.db import IntegrityError
     6
     7import gheat.dataimport
     8import logging
     9
     10logger = logging.getLogger(__name__)
     11logger.setLevel(logging.DEBUG)
    312
    413def js_layer_base(request):
    514  return render_to_response('js/LayerBase.js', {'settings' : settings },
    615    mimetype='application/javascript')
     16
     17def process(request):
     18  response = HttpResponse()
     19  ch = logging.StreamHandler(stream=response)
     20  ch.setLevel(logging.DEBUG)
     21  formatter = logging.Formatter('%(levelname)-6s - %(name)-20s - %(message)s')
     22  ch.setFormatter(formatter)
     23  logging.getLogger().addHandler(ch)
     24 
     25  response.write('<pre>')
     26  for f in MeetBestand.objects.filter(is_imported=False):
     27    logger.info("%s | %s", f.bestand.name, f.meetrondje)
     28    try:
     29      gheat.dataimport.import_file(f.bestand.path, f.meetrondje)
     30    except IntegrityError, e:
     31      logger.error(e)
     32      continue
     33    f.is_imported = True
     34    f.save()
     35  response.write('</pre>')
     36  return response
  • src/django_gheat/wlheatmap/urls.py

    r9594 r9658  
    1919    url(r'^feature/nodes.json$', 'feature.nodes_json'),
    2020    url(r'^filters/$', 'filters.serve_filters'),
     21    url(r'^process/$', 'process'),
    2122)
Note: See TracChangeset for help on using the changeset viewer.