def run(*script_args):
    path = os.path.dirname(os.path.realpath(__file__))
    # pull out the demo user
    user = User.objects.get(username='******')
    # create the test job
    bbox = Polygon.from_bbox((-10.85, 6.25, -10.62, 6.40))  # monrovia
    # bbox = Polygon.from_bbox((13.84,-33.87,34.05,-25.57))  #(w,s,e,n) horn of africa
    the_geom = GEOSGeometry(bbox, srid=4326)
    job = Job.objects.create(name='TestJob',
                             description='Test description', user=user,
                             the_geom=the_geom)
    region = Region.objects.get(name='Africa')
    job.region = region
    job.save()
    # add the format(s)
    formats = [
            ExportFormat.objects.get(slug='obf'),
            ExportFormat.objects.get(slug='thematic')
    ]
    job.formats = formats
    job.save()
    # add the tags (defaults to hdm presets)
    parser = PresetParser(preset='./tasks/tests/files/hdm_presets.xml')
    tags_dict = parser.parse()
    for entry in tags_dict:
        tag = Tag.objects.create(
            key=entry['key'],
            value=entry['value'],
            geom_types=entry['geom_types'],
            data_model='HDM',
            job=job
        )
    # run the export.. tasks processed on celery queue
    # results available at /api/runs url
    runner = ExportTaskRunner()
    runner.run_task(job_uid=str(job.uid))
Beispiel #2
0
 def get(self, request, format='json'):
     path = os.path.dirname(os.path.realpath(__file__))
     parser = PresetParser(path + '/osm_presets.xml')
     data = parser.build_hdm_preset_dict()
     return JsonResponse(data, status=status.HTTP_200_OK)
Beispiel #3
0
 def get(self, request, format='json'):
     path = os.path.dirname(os.path.realpath(__file__))
     parser = PresetParser(path + '/osm_presets.xml')
     data = parser.build_hdm_preset_dict()
     return JsonResponse(data, status=status.HTTP_200_OK)