def execute(identifier, version, inputs): """ Execute Args: identifier (str): Process identifier. version (str): Process version. inputs (list): List of inputs for the process. Returns: cwt.wps.raw.wps.Execute """ ex = Execute() ex.Identifier = identifier ex.version = ows.VersionType(version) ex.service = 'WPS' data_inputs = DataInputsType() data_inputs.Input = inputs ex.DataInputs = data_inputs return ex
def status_failed(message, code, version, locator=None): """ Status Failed Args: message (str): Exception message. code (str): Exception code. version (str): Version string. locator (str): Locator of exception. Returns: cwt.wps.raw.wps.StatusType """ report = ows.ExceptionReport() report.version = ows.VersionType(version) exception = ows.ExceptionType() exception.exceptionCode = code if locator is not None: exception.locator = locator exception.ExceptionText = [message] report.Exception = [exception] return status_failed_from_report(report)
def process_description(identifier, title, version, process_outputs, metadata=None, data_inputs=None, abstract=None): """ Process Description Args: identifier (str): Process identifier. title (str): Process title. version (str): Process version. metadata (dict): A dict whose key/value pairs will be combined with ':' and set as the title value of the metadata element. data_inputs (list): List of input descriptions. process_outputs (list): List of output descriptions. Returns: cwt.wps.raw.wps.ProcessDescriptionType """ process = ProcessDescriptionType() process.Identifier = identifier process.Title = title if abstract is not None: process.Abstract = abstract if data_inputs is not None and len(data_inputs) > 0: process.DataInputs = CTD_ANON() process.DataInputs.Input = data_inputs if metadata is not None: for key, value in metadata.iteritems(): item = ows.MetadataType() item.title = '{}:{}'.format(key, value) process.Metadata.append(item) process.ProcessOutputs = CTD_ANON_() process.ProcessOutputs.Output = process_outputs process.processVersion = ows.VersionType(version) return process
def describe_process(identifier, version): """ Describe Process Args: identifier (list): List of str identifiers to describe. version (str): Version of the process to describe. Returns: cwt.wps.raw.cwt.DescribProcess: """ process = DescribeProcess() process.Identifier = identifier process.version = ows.VersionType(version) process.service = 'WPS' return process
def execute_response(process, status, version, lang, service_instance, status_location, outputs): """ Execute response Args: process (cwt.wps.raw.wps.ProcessBriefType): Description of the process. status (cwt.wps.raw.wps.StatusType): Status of the process. version (str): Version of the process. lang (str): Language code. service_instance (str): Url that the service was called at. status_location (str): Url that the service status can be retrieved. outputs (list): List of process outputs. Returns: cwt.wps.raw.wps.ExecuteResponse """ ex = ExecuteResponse() ex.lang = lang ex.version = ows.VersionType(version) ex.service = 'WPS' ex.serviceInstance = service_instance ex.statusLocation = status_location ex.Process = process ex.Status = status process_outputs = CTD_ANON_5() process_outputs.Output = outputs #process_outputs.Output = outputs ex.ProcessOutputs = process_outputs return ex
def capabilities(identification, provider, metadata, offerings, lang, version): """ Capabilities response Args: identification (cwt.wps.raw.ows.ServiceIdentification): Service Identification. provider (cwt.wps.raw.ows.ServiceProvider): Service Provider. metadata (cwt.wps.raw.ows.OperationsMetadata): Operations Metadata. offerings (cwt.wps.raw.wps.ProcessOfferings): Process Offerings. lang (str): Language. version (str): Supported version. Returns: cwt.wps.raw.wps.Capabilities: """ capabilities = Capabilities() capabilities.ServiceIdentification = identification capabilities.ServiceProvider = provider capabilities.OperationsMetadata = metadata capabilities.ProcessOfferings = offerings languages = Languages() languages.Default = lang languages.Supported = lang capabilities.Languages = languages capabilities.version = ows.VersionType(version) capabilities.lang = lang capabilities.service = 'WPS' return capabilities
def process_descriptions(lang, version, process_descriptions): """ Process Descriptions Args: lang (str): Language code. version (str): Version of the process offerings. descriptions (cwt.wps.raw.wps.ProcessDescriptionType): A list of process descriptions. Returns: cwt.wps.raw.wps.ProcessDescriptions """ descriptions = ProcessDescriptions() descriptions.service = 'WPS' descriptions.lang = lang descriptions.version = ows.VersionType(version) descriptions.ProcessDescription = process_descriptions return descriptions