weaver.wps.utils

Module Contents

weaver.wps.utils.LOGGER[source]
weaver.wps.utils._get_settings_or_wps_config(container: Ellipsis, weaver_setting_name: str, config_setting_section: str, config_setting_name: str, default_not_found: str, message_not_found: str)str[source]
weaver.wps.utils.get_wps_path(container: weaver.typedefs.AnySettingsContainer)str[source]

Retrieves the WPS path (without hostname).

Searches directly in settings, then weaver.wps_cfg file, or finally, uses the default values if not found.

weaver.wps.utils.get_wps_url(container: weaver.typedefs.AnySettingsContainer)str[source]

Retrieves the full WPS URL (hostname + WPS path).

Searches directly in settings, then weaver.wps_cfg file, or finally, uses the default values if not found.

weaver.wps.utils.get_wps_output_dir(container: weaver.typedefs.AnySettingsContainer)str[source]

Retrieves the WPS output directory path where to write XML and result files.

Searches directly in settings, then weaver.wps_cfg file, or finally, uses the default values if not found.

weaver.wps.utils.get_wps_output_path(container: weaver.typedefs.AnySettingsContainer)str[source]

Retrieves the WPS output path (without hostname) for staging XML status, logs and process outputs.

Searches directly in settings, then weaver.wps_cfg file, or finally, uses the default values if not found.

weaver.wps.utils.get_wps_output_url(container: weaver.typedefs.AnySettingsContainer)str[source]

Retrieves the WPS output URL that maps to WPS output directory path.

Searches directly in settings, then weaver.wps_cfg file, or finally, uses the default values if not found.

weaver.wps.utils.get_wps_local_status_location(url_status_location: str, container: weaver.typedefs.AnySettingsContainer, must_exist: bool = True)Optional[str][source]

Attempts to retrieve the local XML file path corresponding to the WPS status location as URL.

Parameters
  • url_status_location – URL reference pointing to some WPS status location XML.

  • container – any settings container to map configured local paths.

  • must_exist – return only existing path if enabled, otherwise return the parsed value without validation.

Returns

found local file path if it exists, None otherwise.

weaver.wps.utils._describe_process_cached(self: owslib.wps.WebProcessingService, identifier: str, xml: Optional[weaver.xml_util.XML] = None)weaver.typedefs.ProcessOWS[source]
weaver.wps.utils._get_wps_client_cached(url: str, headers: weaver.typedefs.HeadersType, verify: bool, language: Optional[str])owslib.wps.WebProcessingService[source]
weaver.wps.utils.get_wps_client(url: str, container: Optional[weaver.typedefs.AnySettingsContainer] = None, verify: bool = None, headers: Optional[weaver.typedefs.HeadersType] = None, language: Optional[str] = None)owslib.wps.WebProcessingService[source]

Obtains a WebProcessingService with pre-configured request options for the given URL.

Parameters
  • url – WPS URL location.

  • container – request or settings container to retrieve headers and other request options.

  • verify – flag to enable SSL verification (overrides request options from container).

  • headers – specific headers to apply (overrides retrieved ones from container).

  • language – preferred response language if supported by the service.

Returns

created WPS client object with configured request options.

weaver.wps.utils.check_wps_status(location: Ellipsis = None, response: Optional[weaver.xml_util.XML] = None, sleep_secs: int = 2, verify: bool = True, settings: Optional[weaver.typedefs.AnySettingsContainer] = None)owslib.wps.WPSExecution[source]

Run owslib.wps.WPSExecution.checkStatus() with additional exception handling.

Parameters
  • location – job URL or file path where to look for job status.

  • response – WPS response document of job status.

  • sleep_secs – number of seconds to sleep before returning control to the caller.

  • verify – flag to enable SSL verification.

  • settings – application settings to retrieve any additional request parameters as applicable.

Returns

OWSLib.wps.WPSExecution object.

weaver.wps.utils.load_pywps_config(container: weaver.typedefs.AnySettingsContainer, config: Optional[Union[str, Dict[str, str]]] = None)configparser.ConfigParser[source]

Loads and updates the PyWPS configuration using Weaver settings.

weaver.wps.utils.set_wps_language(wps: owslib.wps.WebProcessingService, accept_language: Optional[str] = None, request: Optional[weaver.typedefs.AnyRequestType] = None)Optional[str][source]

Applies the best match between requested accept languages and supported ones by the WPS server.

Given the Accept-Language header value, match the best language to the supported languages retrieved from WPS. By default, and if no match is found, sets WebProcessingService.language property to None.

See also

Details about the format of the Accept-Language header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language

Note

This function considers quality-factor weighting and parsing resolution of Accept-Language header according to RFC 7231, section 5.3.2.

Parameters
  • wps – service for which to apply a supported language if matched.

  • accept_language (str) – value of the Accept-Language header.

  • request – request from which to extract Accept-Language header if not provided directly.

Returns

language that has been set, or None if no match could be found.