예제 #1
0
def parse_raster_layer_if_log_is_empty(sender, instance, created, **kwargs):
    if created:
        RasterLayerParseStatus.objects.create(rasterlayer=instance)
        RasterLayerMetadata.objects.create(rasterlayer=instance)

    if instance.rasterfile.name and instance.parsestatus.log == '':
        if hasattr(settings, 'RASTER_USE_CELERY') and settings.RASTER_USE_CELERY:
            from raster.tasks import parse_raster_layer_with_celery
            parse_raster_layer_with_celery.delay(instance)
        else:
            from raster.parser import RasterLayerParser
            parser = RasterLayerParser(instance)
            parser.parse_raster_layer()