How to use the oasislmf.utils.http.HTTP_RESPONSE_RESOURCE_NOT_FOUND function in oasislmf

To help you get started, we’ve selected a few oasislmf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OasisLMF / OasisPlatform / src / server.bak / app.py View on Github external
parameters:
    - name: location
      in: path
      description: The location of the exposure resource to summarise.
      required: true
      type: string
    """
    logging.debug("Location: {}".format(location))
    if location is None:
        return jsonify({
            'exposures': [ex for ex in map(_get_exposure_summary, sorted(os.listdir(settings.get('server', 'INPUTS_DATA_DIRECTORY')))) if ex]
        })
    else:
        exposure = _get_exposure_summary('{}{}'.format(location, TAR_FILE_SUFFIX))
        if not exposure:
            return Response(status=http.HTTP_RESPONSE_RESOURCE_NOT_FOUND)

        return jsonify({'exposures': [exposure]})
github OasisLMF / OasisPlatform / src / server.bak / app.py View on Github external
filepath = os.path.join(settings.get('server', 'OUTPUTS_DATA_DIRECTORY'), filename)

            if not filepath.endswith(TAR_FILE_SUFFIX):
                continue
            if not os.path.isfile(filepath):
                continue
            os.remove(filepath)
        response = Response(status=http.HTTP_RESPONSE_OK)

    else:

        filename = str(location) + TAR_FILE_SUFFIX
        filepath = os.path.join(settings.get('server', 'OUTPUTS_DATA_DIRECTORY'), filename)

        if not os.path.exists(filepath):
            response = Response(status=http.HTTP_RESPONSE_RESOURCE_NOT_FOUND)
        else:
            os.remove(filepath)
            response = Response(status=http.HTTP_RESPONSE_OK)

    return response