示例#1
0
 def __init__(self):
     ConfigFileParser.__init__(self, config.get('userInterfaceConfig', None))
示例#2
0
 def __init__(self):
     ConfigFileParser.__init__(self, config.get('helpTextConfig', None))
示例#3
0
 def __init__(self):
     ConfigFileParser.__init__(self, config.get('displayOptionsConfig', None))
示例#4
0
 def __init__(self):
     ConfigFileParser.__init__(self, config.get('furtherInfoConfig', None))
示例#5
0
 def __init__(self):
     ConfigFileParser.__init__(self, config.get('outlineConfig', None))
示例#6
0
 def __init__(self):
     ConfigFileParser.__init__(self, config.get('endpointConfig', None))
     log.debug("Read %s", config.get('endpointConfig', None))
示例#7
0
def makeWcsExportFile(exportParams):
    """Retrieves an export file using WCS. If multiple dimension values are specified, the result
        will contain data for each.
    @param exportParams: object holding all the parametes for an export
    @return ExportResult holding request status and output file if successful
    """
    layerInfo = exportParams.layerInfoList[exportParams.animationLayerNumber - 1]

    # Modify parameters to take into account the dimension over which a range is specified.
    # Include workaround for COWS Server limitations - time must have start and end values, other
    # dimensions must be a single value or range start and end values only.
    baseParams = _getParams(layerInfo.params)
    log.debug("baseParams = %s" % (baseParams,))
    log.debug("Animation dimension is %s" % exportParams.animationDimension)
    if (exportParams.animationDimension != None) and (exportParams.animationDimension in baseParams):
        log.debug("Animation dimension found in parameters")
        if exportParams.animationDimension == "TIME":
            vals = list(_orderValues(exportParams.startValue, exportParams.endValue, expectTime=True))
            baseParams[exportParams.animationDimension] = vals
            log.debug("Animation dimension is time: (start, end)=(%s, %s)" % (vals[0], vals[1]))
        else:
            # For WCS servers that accept comma separated list of dimension values, the following
            # would be used:
            # baseParams[exportParams.animationDimension] = exportParams.startValue
            # baseParams[exportParams.animationDimension] = ','.join(exportParams.dimensionValues)

            # Set dimension value or range.
            if exportParams.startValue == exportParams.endValue:
                baseParams[exportParams.animationDimension] = exportParams.startValue
            else:
                baseParams[exportParams.animationDimension] = "%s,%s" % _orderValues(
                    exportParams.startValue, exportParams.endValue
                )
            log.debug(
                "Animation dimension is not time: %s=%s"
                % (exportParams.animationDimension, baseParams[exportParams.animationDimension])
            )
            if "TIME" in baseParams:
                timeValue = baseParams["TIME"]
                baseParams["TIME"] = [timeValue, timeValue]
                log.debug("Setting time to %s" % timeValue)

    baseParams["ENDPOINT"] = layerInfo.endpoint

    # Fetch the data to a file.
    errorReason = None
    try:
        (data, headers) = _getWcsData(baseParams)

        outFileName = headers.get("filename", None)
        if outFileName is not None:
            fileParts = os.path.basename(outFileName).rsplit(".", 1)
            fileSuffix = ("." + fileParts[1]) if len(fileParts) == 2 else ".dat"
        outFile = tempfile.NamedTemporaryFile(
            prefix=exportParams.fileNamePrefix,
            suffix=fileSuffix,
            delete=False,
            dir=config.get("export_file_dir", tempfile.gettempdir()),
        )
        log.debug("File: %s" % (outFile.name))
        outFile.write(data)
        outFile.close()
    except Exception, err:
        log.error("Exception retrieving WCS data: %s" % err)
        errorReason = err.__str__()
        outFile = None