Exemplo n.º 1
0
    def execute(self, appstruct):
        inputs = appstruct_to_inputs(self.request, appstruct)
        # need to use ComplexDataInput
        complex_inpts = {}
        bbox_inpts = []
        for inpt in self.process.dataInputs:
            if 'ComplexData' in inpt.dataType:
                complex_inpts[inpt.identifier] = inpt
            elif 'BoundingBoxData' in inpt.dataType:
                bbox_inpts.append(inpt.identifier)
        new_inputs = []
        for inpt in inputs:
            identifier = inpt[0]
            value = inpt[1]
            if identifier in complex_inpts:
                new_inputs.append((identifier, ComplexDataInput(value)))
                if is_reference(value):
                    if value not in self.request.cart:
                        if complex_inpts[identifier].supportedValues:
                            mime_type = complex_inpts[
                                identifier].supportedValues[0].mimeType
                        else:
                            mime_type = None
                        LOGGER.debug("add input to cart: %s %s", identifier,
                                     mime_type)
                        self.request.cart.add_item(
                            value,
                            abstract=
                            "Automatically added in process execution.",
                            mime_type=mime_type)
            elif identifier in bbox_inpts:
                new_inputs.append((identifier, BoundingBoxDataInput(value)))
            else:
                new_inputs.append(inpt)
        inputs = new_inputs
        # prepare outputs
        outputs = []
        for output in self.process.processOutputs:
            outputs.append(
                (output.identifier, output.dataType == 'ComplexData'))

        from phoenix.tasks.execute import execute_process
        result = execute_process.delay(
            userid=self.request.unauthenticated_userid,
            url=self.wps.url,
            service_name=self.service_name,
            identifier=self.process.identifier,
            inputs=inputs,
            outputs=outputs,
            async=appstruct.get('_async_check', True))
        self.request.registry.notify(JobStarted(self.request, result.id))
        return result.id
Exemplo n.º 2
0
def test_is_reference():
    assert is_reference('http://testing.org')
    assert is_reference(b'http://testing.org')
    assert not is_reference('mumbo jumbo')
    assert not is_reference(b'mumbo jumbo')