コード例 #1
0
def encode_process_full(process):
    """ Encode a full process description (ProcessDescription element) of the
    ProcessDescriptions XML document.
    """
    if getattr(process, 'asynchronous', False):
        supports_store = True
        supports_update = True
    else:
        supports_store = False
        supports_update = False

    # TODO: remove backward compatibility support for inputs/outputs dicts
    if isinstance(process.inputs, dict):
        process.inputs = process.inputs.items()
    if isinstance(process.outputs, dict):
        process.outputs = process.outputs.items()

    inputs = [
        item for item in (
            encode_input_descr(fix_parameter(n, p)) for n, p in process.inputs
        ) if item is not None
    ]
    outputs = [
        encode_output_descr(fix_parameter(n, p)) for n, p in process.outputs
    ]

    elem = _encode_process_brief(process, NIL("ProcessDescription"))
    if supports_store:
        elem.attrib["storeSupported"] = "true"
    if supports_update:
        elem.attrib["statusSupported"] = "true"
    elem.append(NIL("DataInputs", *inputs))
    elem.append(NIL("ProcessOutputs", *outputs))

    return elem
コード例 #2
0
def parse_params(param_defs):
    """ Parse process's inputs/outputs parameter definitions. """
    if isinstance(param_defs, dict):
        param_defs = param_defs.iteritems()
    return OrderedDict((param.identifier, (name, param))
                       for name, param in ((name, fix_parameter(name, param))
                                           for name, param in param_defs))
コード例 #3
0
def _encode_common_response(process, status_elem, inputs, raw_inputs,
                            resp_doc):
    """Encode common execute response part shared by all specific responses."""
    inputs = inputs or {}
    conf = CapabilitiesConfigReader(get_eoxserver_config())
    url = conf.http_service_url
    if url[-1] == "?":
        url = url[:-1]
    elem = WPS(
        "ExecuteResponse",
        encode_process_brief(process),
        WPS("Status", status_elem, creationTime=isoformat(now())),
        {
            "service":
            "WPS",
            "version":
            "1.0.0",
            ns_xml("lang"):
            "en-US",
            "serviceInstance":
            ("%s?service=WPS&version=1.0.0&request=GetCapabilities" % url)
        },
    )

    if resp_doc.lineage:
        inputs_data = []
        for id_, prm in process.inputs:
            if isinstance(prm, RequestParameter):
                continue
            prm = fix_parameter(id_, prm)
            data = inputs.get(id_)
            rawinp = raw_inputs.get(prm.identifier)
            if rawinp is not None:
                inputs_data.append(_encode_input(data, prm, rawinp))
        elem.append(WPS("DataInputs", *inputs_data))

        outputs_def = []
        for id_, prm in process.outputs:
            prm = fix_parameter(id_, prm)
            outdef = resp_doc.get(prm.identifier)
            if outdef is not None:
                outputs_def.append(encode_output_def(outdef))
        elem.append(WPS("OutputDefinitions", *outputs_def))

    return elem
コード例 #4
0
ファイル: execute_util.py プロジェクト: EOxServer/eoxserver
def parse_params(param_defs):
    """ Parse process's inputs/outputs parameter definitions. """
    if isinstance(param_defs, dict):
        param_defs = param_defs.iteritems()
    return OrderedDict(
        (param.identifier, (name, param)) for name, param in (
            (name, fix_parameter(name, param)) for name, param in param_defs
        )
    )
コード例 #5
0
ファイル: execute.py プロジェクト: DREAM-ODA-OS/eoxserver
def _normalize_params(param_defs):
    if isinstance(param_defs, dict):
        param_defs = param_defs.iteritems()
    params, param_ids = [], []
    for name, param in param_defs:
        param = fix_parameter(name, param) # short-hand def. expansion
        param_ids.append(param.identifier)
        params.append((name, param))
    return params, param_ids
コード例 #6
0
def _encode_common_response(process, status_elem, inputs, raw_inputs, resp_doc):
    """Encode common execute response part shared by all specific responses."""
    inputs = inputs or {}
    conf = CapabilitiesConfigReader(get_eoxserver_config())
    url = conf.http_service_url
    if url[-1] == "?":
        url = url[:-1]
    elem = WPS("ExecuteResponse",
        encode_process_brief(process),
        WPS("Status", status_elem, creationTime=isoformat(now())),
        {
            "service": "WPS",
            "version": "1.0.0",
            ns_xml("lang"): "en-US",
            "serviceInstance": (
                "%s?service=WPS&version=1.0.0&request=GetCapabilities" % url
            )
        },
    )

    if resp_doc.lineage:
        inputs_data = []
        for id_, prm in process.inputs:
            if isinstance(prm, RequestParameter):
                continue
            prm = fix_parameter(id_, prm)
            data = inputs.get(id_)
            rawinp = raw_inputs.get(prm.identifier)
            if rawinp is not None:
                inputs_data.append(_encode_input(data, prm, rawinp))
        elem.append(WPS("DataInputs", *inputs_data))

        outputs_def = []
        for id_, prm in process.outputs:
            prm = fix_parameter(id_, prm)
            outdef = resp_doc.get(prm.identifier)
            if outdef is not None:
                outputs_def.append(encode_output_def(outdef))
        elem.append(WPS("OutputDefinitions", *outputs_def))

    return elem
コード例 #7
0
def encode_process_full(process):
    """ Encode full process description used in DescribeProcess response."""
    # TODO: support for async processes
    supports_store = False
    supports_update = False

    # TODO: remove backward compatibitity support for inputs/outputs dicts
    if isinstance(process.inputs, dict):
        process.inputs = process.inputs.items()
    if isinstance(process.outputs, dict):
        process.outputs = process.outputs.items()

    inputs = [encode_input_descr(fix_parameter(n, p)) for n, p in process.inputs]
    outputs = [encode_output_descr(fix_parameter(n, p)) for n, p in process.outputs]

    elem = _encode_process_brief(process, NIL("ProcessDescription"))
    if supports_store:
        elem.attrib["storeSupported"] = "true"
    if supports_update:
        elem.attrib["statusSupported"] = "true"
    elem.append(NIL("DataInputs", *inputs))
    elem.append(NIL("ProcessOutputs", *outputs))

    return elem
コード例 #8
0
def extend_processes(processes):
    """ Add the process definition to the process. """
    wps_processes = get_wps_processes()
    for process in processes:
        # skip processes which are not available
        if process.identifier not in wps_processes:
            continue
        wps_process = wps_processes[process.identifier]
        # add name and description if missing
        if not process.name:
            process.name = wps_process.title
        if not process.description:
            process.description = wps_process.__doc__
        # extend the class with the sanitized WPS input definitions
        process.inputs = [
            idef for idef in (
                fix_parameter(iid, idef) for iid, idef
                in wps_processes[process.identifier].inputs
            ) if not idef.identifier.startswith('\\')
        ]
        yield process