示例#1
0
 def delete_coverage(dataset_id):
     """
     Deletes a coverage attached to a dataset from the WCST service
     :param dataset_id: string - the id of the dataset to which this coverage is attached to
     """
     request = wcst.WCSTDeleteRequest(RasterUtil.dataset_id_to_coverage_id(dataset_id))
     executor = wcst.WCSTExecutor(RasterUtil.get_wcst_url())
     executor.execute(request)
示例#2
0
    def insert_coverage(coverage_url, dataset_id):
        """
        Inserts a coverage attached to a dataset into the WCST service

        :param coverage_url: string - url to the coverage to be inserted (can be in any gdal supported format + GML)
        :param dataset_id: string - the id of the dataset to which this coverage is attached to
        """
        coverage_local_path = RasterUtil.get_gml_path_from_dataset(coverage_url, dataset_id)
        request = wcst.WCSTInsertRequest(coverage_local_path)
        executor = wcst.WCSTExecutor(RasterUtil.get_wcst_url())
        executor.execute(request)
def rasterstorer_delete(context):
    """
    Task for deleting a raster in celery app. Keep it simple, we just need to call WCST DeleteCoverage request and
    it will take care of the rest
    @:param resource_id the id of the resource to be imported
    @:param context the context in which to execute the task
    """
    log = rasterstorer_delete.get_logger()
    try:
        log.info("[Raster_Delete]Deleting resource %s..." % context["resource_dict"]["id"])
        util = RasterUtil(context, log)
        util.delete_coverage()
        log.info("[Raster_Delete]Resource %s was deleted successfully." % (context["resource_dict"]["id"]))
    except Exception as ex:
        log.info("[Raster_Delete]Resource %s could not be deleted. Exception message %s"
                 % (context["resource_dict"]["id"], ex.message))
        raise
示例#4
0
def rasterstorer_delete(context):
    """
    Task for deleting a raster in celery app. Keep it simple, we just need to call WCST DeleteCoverage request and
    it will take care of the rest
    @:param resource_id the id of the resource to be imported
    @:param context the context in which to execute the task
    """
    log = rasterstorer_delete.get_logger()
    try:
        log.info("[Raster_Delete]Deleting resource %s..." % context["resource_dict"]["id"])
        util = RasterUtil(context, log)
        util.delete_coverage()
        log.info("[Raster_Delete]Resource %s was deleted successfully." % (context["resource_dict"]["id"]))
    except Exception as ex:
        log.info("[Raster_Delete]Resource %s could not be deleted. Exception message %s"
                 % (context["resource_dict"]["id"], ex.message))
        raise
def rasterstorer_identify(context):
    """
    Task for downloading the resource and preparing it for ingest
    @:param context: the context in which to execute the task
    """
    log = rasterstorer_identify.get_logger()

    log.info('Received an identify task: context=\n%s' % (json.dumps(context, indent=4)))

    try:
        log.info("[Raster_Identify]Downloading resource %s..." % context["resource_dict"]["id"])
        util = RasterUtil(context, log)
        util.download_resource()
        log.info('[Raster_Identify]Downloaded resource %s' % context["resource_dict"]["id"])
    except CannotDownload as ex:
        # Retry later, maybe the resource is still uploading
        log.error('[Raster_Identify] Failed to download: %s' % ex.message)
        rasterstorer_identify.retry(exc=ex, countdown=60)
示例#6
0
def rasterstorer_identify(context):
    """
    Task for downloading the resource and preparing it for ingest
    @:param context: the context in which to execute the task
    """
    log = rasterstorer_identify.get_logger()

    log.info('Received an identify task: context=\n%s' % (json.dumps(context, indent=4)))

    try:
        log.info("[Raster_Identify]Downloading resource %s..." % context["resource_dict"]["id"])
        util = RasterUtil(context, log)
        util.download_resource()
        log.info('[Raster_Identify]Downloaded resource %s' % context["resource_dict"]["id"])
    except CannotDownload as ex:
        # Retry later, maybe the resource is still uploading
        log.error('[Raster_Identify] Failed to download: %s' % ex.message)
        rasterstorer_identify.retry(exc=ex, countdown=60)
示例#7
0
    def insert_coverage(coverage_url, dataset_id, base_url):
        """
        Inserts a coverage attached to a dataset into the WCST service

        :param coverage_url: string - url to the coverage to be inserted (can be in any gdal supported format + GML)
        :param dataset_id: string - the id of the dataset to which this coverage is attached to
        """

        coverage_local_path = RasterUtil.get_gml_path_from_dataset(coverage_url, dataset_id)
        gml_url = base_url + os.path.basename(coverage_local_path)

        #Execute the wcst insert request
        request = wcst.WCSTInsertRequest(gml_url)
        executor = wcst.WCSTExecutor(RasterUtil.get_wcst_url())
        response = executor.execute(request)

        #Cleanup
        os.remove(coverage_local_path)
        os.remove(coverage_local_path.replace(".xml", ".raster"))

        return response
示例#8
0
def rasterstorer_import(context):
    """
    Task for publishing a raster in celery app. Keep it simple, initialize the context correctly then generate a gml
    and submit it to petascope
    @:param context the context in which to execute the task
    """
    log = rasterstorer_import.get_logger()
    try:
        setup_rasterstorer_in_task_context(context)
        util = RasterUtil(context, log)
        util.insert_coverage()
        util.check_import_successful()
        util.add_wcs_resource()
        util.add_wms_resource()
        util.finalize()
        log.info("[Raster_Import]Resource %s was imported successfully." %
                 (context["resource_dict"]["id"]))
    except Exception as ex:
        log.info(
            "[Raster_Import]Resource %s could not be imported. Exception message: %s"
            % (context["resource_dict"]["id"], ex.message))
        raise
def rasterstorer_import(context):
    """
    Task for publishing a raster in celery app. Keep it simple, initialize the context correctly then generate a gml
    and submit it to petascope
    @:param context the context in which to execute the task
    """
    log = rasterstorer_import.get_logger()
    try:
        setup_rasterstorer_in_task_context(context)
        util = RasterUtil(context, log)
        util.insert_coverage()
        util.check_import_successful()
        util.add_wcs_resource()
        util.add_wms_resource()
        util.finalize()
        log.info("[Raster_Import]Resource %s was imported successfully." % (context["resource_dict"]["id"]))
    except Exception as ex:
        log.info("[Raster_Import]Resource %s could not be imported. Exception message: %s"
                 % (context["resource_dict"]["id"], ex.message))
        raise