Beispiel #1
0
    def handle(self, *args, **options):
        
        akvo = AkvoFlow.objects.get(pk=options.get('akvo'))
        api = FlowAPI(instance=akvo.instance, key=akvo.key, secret=akvo.secret)
        cartodb = CartoDb.objects.get(pk=options.get('cartodb'))
    
        project = ProjectLocatie.objects.get(pk=options.get('proj'))
        user = User.objects.get(username=options.get('user'))

        days = None if options.get('all') else 7
        
        try:
            logger.debug('Meetpuntgegevens ophalen')
            m1,w1 = importAkvoRegistration(api, akvo, projectlocatie=project,user=user,days=days)
            logger.debug('Waarnemingen ophalen')
            m2,w2=importAkvoMonitoring(api, akvo, days)
            mp = m1|m2
            wn = w1|w2
            if mp:
                logger.debug('Grafieken aanpassen')
                util.updateSeries(mp, user)
                #logger.debug('Cartodb actualiseren')
                util.exportCartodb(cartodb, mp, 'allemetingen')
            
            akvo.last_update = timezone.now()
            akvo.save()        
        except Exception as e:
            logger.exception('Probleem met verwerken nieuwe EC metingen: %s',e)
        finally:
            pass
Beispiel #2
0
def export_cdb_meetpunten(modeladmin, request, queryset):
    util.exportCartodb(CartoDb.objects.get(pk=1), queryset, "allemetingen")
Beispiel #3
0
 def handle(self, *args, **options):
     for p in ProjectLocatie.objects.all():
         mps = [m.meetpunt for m in p.meetlocatie_set.all()]
         exportCartodb(p.cartodb, mps)