|
20 | 20 | from pywps.inout.outputs import output_from_json |
21 | 21 | import pywps.configuration as config |
22 | 22 | from pywps.exceptions import (StorageNotSupported, OperationNotSupported, |
23 | | - ServerBusy, NoApplicableCode) |
| 23 | + ServerBusy, NoApplicableCode, |
| 24 | + InvalidParameterValue) |
24 | 25 | from pywps.app.exceptions import ProcessError |
25 | 26 | from pywps.inout.storage.builder import StorageBuilder |
| 27 | +from pywps.inout.outputs import ComplexOutput |
26 | 28 | import importlib |
27 | 29 |
|
28 | 30 |
|
@@ -311,6 +313,7 @@ def launch_next_process(self): |
311 | 313 | process._set_uuid(uuid) |
312 | 314 | process._setup_status_storage() |
313 | 315 | process.async_ = True |
| 316 | + process.setup_outputs_from_wps_request(new_wps_request) |
314 | 317 | new_wps_response = ExecuteResponse(new_wps_request, process=process, uuid=uuid) |
315 | 318 | new_wps_response.store_status_file = True |
316 | 319 | process._run_async(new_wps_request, new_wps_response) |
@@ -446,3 +449,31 @@ def _set_grass(self, wps_request): |
446 | 449 | LOGGER.debug('GISRC {}, GISBASE {}, GISDBASE {}, LOCATION {}, MAPSET {}'.format( |
447 | 450 | os.environ.get('GISRC'), os.environ.get('GISBASE'), |
448 | 451 | dbase, location, os.path.basename(mapset_name))) |
| 452 | + |
| 453 | + def setup_outputs_from_wps_request(self, wps_request): |
| 454 | + # set as_reference to True for all the outputs specified as reference |
| 455 | + # if the output is not required to be raw |
| 456 | + if not wps_request.raw: |
| 457 | + for wps_outpt in wps_request.outputs: |
| 458 | + |
| 459 | + is_reference = wps_request.outputs[wps_outpt].get('asReference', 'false') |
| 460 | + mimetype = wps_request.outputs[wps_outpt].get('mimetype', '') |
| 461 | + if is_reference.lower() == 'true': |
| 462 | + # check if store is supported |
| 463 | + if self.store_supported == 'false': |
| 464 | + raise StorageNotSupported( |
| 465 | + 'The storage of data is not supported for this process.') |
| 466 | + |
| 467 | + is_reference = True |
| 468 | + else: |
| 469 | + is_reference = False |
| 470 | + |
| 471 | + for outpt in self.outputs: |
| 472 | + if outpt.identifier == wps_outpt: |
| 473 | + outpt.as_reference = is_reference |
| 474 | + if isinstance(outpt, ComplexOutput) and mimetype != '': |
| 475 | + data_format = [f for f in outpt.supported_formats if f.mime_type == mimetype] |
| 476 | + if len(data_format) == 0: |
| 477 | + raise InvalidParameterValue( |
| 478 | + 'MimeType ' + mimetype + ' not valid') |
| 479 | + outpt.data_format = data_format[0] |
0 commit comments