def get_capabilities(wps_host=None, wps_client=None, version='1.0.0'): """WPS GetCapabilities response. Parameters ---------- wps_host : string wps_client : pywps.tests.WpsClient version : string Returns ------- out : list of ? """ if wps_host: return WebProcessingService(wps_host, version) else: response = wps_client.get( '?service=WPS&request=GetCapabilities&version={0}'.format(version)) wps_reader = WPSReader() element = wps_reader.readFromString(response.get_data()) wps = WebProcessingService(None, version, skip_caps=True) wps._parseCapabilitiesMetadata(element) return wps
def list_wps_service_engines(app_class=None): """ Get all wps engines offered. Args: app_class (class, optional): The app class to include in the search for wps engines. Returns: (tuple): A tuple of WPS engine dictionaries. """ # Init vars wps_services_list = [] # If the app_class is given, check it first for a wps engine app_wps_services = None if app_class and issubclass(app_class): # Instantiate app class and retrieve wps services list app = app_class() app_wps_services = app.wps_services() if app_wps_services: # Search for match for app_wps_service in app_wps_services: wps = WebProcessingService(app_wps_service.endpoint, username=app_wps_service.username, password=app_wps_service.password, verbose=False, skip_caps=True) activated_wps = activate_wps(wps=wps, endpoint=app_wps_service.endpoint, name=app_wps_service.name) if activated_wps: wps_services_list.append(activated_wps) # If no wps_services are known yet check for port 8090 to 8099 if not WpsModel.objects.all(): find_wps_service_engines() # If the wps engine cannot be found in the app_class, check settings for site-wide wps engines site_wps_services = WpsModel.objects.all() for site_wps_service in site_wps_services: # Create OWSLib WebProcessingService engine object wps = WebProcessingService(site_wps_service.endpoint, username=site_wps_service.username, password=site_wps_service.password, verbose=False, skip_caps=True) # Initialize the object with get capabilities call activated_wps = activate_wps(wps=wps, endpoint=site_wps_service.endpoint, name=site_wps_service.name) if activated_wps: wps_services_list.append(activated_wps) return wps_services_list
def describe_process(identifier, wps_host=None, wps_client=None, version='1.0.0'): """WPS Describe Process response. Parameters ---------- identifer : string wps_host : string wps_client : pywps.tests.WpsClient version : string Returns ------- out : list of ? """ if wps_host: wps = WebProcessingService(wps_host, version) return wps.describeprocess(identifier) else: response = wps_client.get( ('?service=WPS&request=DescribeProcess&version={0}&' 'identifier={1}').format(version, identifier)) wps_reader = WPSReader() element = wps_reader.readFromString(response.get_data()) wps = WebProcessingService(None, version, skip_caps=True) return wps._parseProcessMetadata(element)
def get_wps_service_engine(name, app_class=None): """ Get a wps engine with the given name. Args: name (string): Name of the wps engine to retrieve. app_class (class, optional): The app class to include in the search for wps engines. Returns: (owslib.wps.WebProcessingService): A owslib.wps.WebProcessingService object. """ # If the app_class is given, check it first for a wps engine app_wps_services = None if app_class and issubclass(app_class, TethysAppBase): # Instantiate app class and retrieve wps services list app = app_class() app_wps_services = app.wps_services() if app_wps_services: # Search for match for app_wps_service in app_wps_services: # If match is found, initiate engine object if app_wps_service.name == name: wps = WebProcessingService(app_wps_service.endpoint, username=app_wps_service.username, password=app_wps_service.password, verbose=False, skip_caps=True) return activate_wps(wps=wps, endpoint=app_wps_service.endpoint, name=app_wps_service.name) # If the wps engine cannot be found in the app_class, check database for site-wide wps engines site_wps_services = WpsModel.objects.all() if site_wps_services: # Search for match for site_wps_service in site_wps_services: # If match is found initiate engine object if site_wps_service.name == name: # Create OWSLib WebProcessingService engine object wps = WebProcessingService(site_wps_service.endpoint, username=site_wps_service.username, password=site_wps_service.password, verbose=False, skip_caps=True) # Initialize the object with get capabilities call return activate_wps(wps=wps, endpoint=site_wps_service.endpoint, name=site_wps_service.name) raise NameError( 'Could not find wps service with name "{0}". Please check that a wps service with that name ' 'exists in the admin console or in your app.py.'.format(name))
def get_capabilities(wps_host=None, wps_client=None, version='1.0.0'): if wps_host: return WebProcessingService(wps_host, version) else: response = wps_client.get( '?service=WPS&request=GetCapabilities&version={0}'.format(version)) wps_reader = WPSReader() element = wps_reader.readFromString(response.get_data()) wps = WebProcessingService(None, version, skip_caps=True) wps._parseCapabilitiesMetadata(element) return wps
def describe_process(identifier, wps_host=None, wps_client=None, version='1.0.0'): if wps_host: wps = WebProcessingService(wps_host, version) return wps.describeprocess(identifier) else: response = wps_client.get( ('?service=WPS&request=DescribeProcess&version={0}&' 'identifier={1}').format(version, identifier)) wps_reader = WPSReader() element = wps_reader.readFromString(response.get_data()) wps = WebProcessingService(None, version, skip_caps=True) return wps._parseProcessMetadata(element)
def setUp(self): """Run the WPS process and store the result.""" self.wps = WebProcessingService(self.wps_host) # Get the description of the process self.p = self.wps.describeprocess(self.identifier) ### --------------------- ### ### Early fault detection ### ### --------------------- ### # Get the names of the inputs ins = [o.identifier for o in self.p.dataInputs] # Get the names of the outputs outs = [o.identifier for o in self.p.processOutputs] # Check that the params are in the inputs for key in self.params.keys(): self.assertIn(key, ins) # Check that the desired output is defined self.assertIn(self.output_name, outs) ### --------------------- ### # Execute the process self.output = self.execute_wps()
def uploadShapeFile(filePath): """ Given a file, this function encodes the file and uploads it onto geoserver. """ # encodes the file, opens it, reads it, and closes it # returns a filename in form of: filename_copy.zip filePath = _encodeZipFolder(filePath) if filePath is None: return filehandle = open(filePath, 'r') filedata = filehandle.read() filehandle.close() os.remove(filePath) # deletes the encoded file # this if for naming the file on geoServer filename = filePath.split("/") # gets rid of filepath, keeps only filename eg: file.zip filename = filename[len(filename) - 1] filename = filename.replace("_copy.zip", "") xml_gen = gdpXMLGenerator() root = xml_gen.getUploadXMLtree(filename, upload_URL, filedata) # now we have a complete XML upload request upload_request = etree.tostring(root) post = WebProcessingService(WPS_Service) execution = post.execute(None, [], request=upload_request) monitorExecution(execution) return "upload:" + filename
def test_wps_describeprocess_ceda(): # Initialize WPS client wps = WebProcessingService('http://ceda-wps2.badc.rl.ac.uk/wps', skip_caps=True) # Execute fake invocation of DescribeProcess operation by parsing cached response from CEDA service xml = open(resource_file('wps_CEDADescribeProcess.xml'), 'rb').read() process = wps.describeprocess('DoubleIt', xml=xml) # Check process description assert process.identifier == 'DoubleIt' assert process.title == 'Doubles the input number and returns value' assert process.abstract == 'This is test process used to demonstrate how the WPS and the WPS User Interface work. The process accepts an integer or floating point number and returns some XML containing the input number double.' # NOQA # Check process properties assert process.statusSupported is False assert process.storeSupported is True # Check process inputs # Example Input: # identifier=NumberToDouble, title=NumberToDouble, abstract=NumberToDouble, data type=LiteralData # Any value allowed # Default Value: None # minOccurs=1, maxOccurs=-1 for input in process.dataInputs: assert input.identifier == 'NumberToDouble' assert input.dataType == 'LiteralData' # Example Output: # identifier=OutputXML, title=OutputXML, abstract=OutputXML, data type=ComplexData # Supported Value: mimeType=text/XML, encoding=UTF-8, schema=NONE # Default Value: None # reference=None, mimeType=None # Check process outputs for output in process.processOutputs: assert output.identifier == 'OutputXML' assert output.dataType == 'ComplexData'
def multiple_outputs(): print("\nmultiple outputs ...") # get multiple outputs wps = WebProcessingService('http://localhost:8094/wps', verbose=verbose) processid = 'dummyprocess' inputs = [("input1", '1'), ("input2", '2')] # list of tuple (output identifier, asReference attribute) outputs = [("output1",True), ("output2",False)] execution = wps.execute(processid, inputs, output=outputs) monitorExecution(execution) # show status print('percent complete', execution.percentCompleted) print('status message', execution.statusMessage) # outputs for output in execution.processOutputs: print('identifier=%s, dataType=%s, data=%s, reference=%s' % (output.identifier, output.dataType, output.data, output.reference)) # errors print(execution.status) for error in execution.errors: print(error.code, error.locator, error.text)
def wps(self): # noqa: D102 if self._wps is None: language = self.context_settings["obj"].get("language") self._wps = WebProcessingService( self.url, verify=self.verify, skip_caps=True, language=language ) return self._wps
def __init__(self, request): self.service_id = request.params.get('wps') service = request.catalog.get_record_by_id(self.service_id) self.wps = WebProcessingService( url=service.url, verify=False) super(ProcessList, self).__init__(request, name='processes_list', title='')
def test_wps_describeprocess_bbox(): # Initialize WPS client wps = WebProcessingService('http://localhost:8094/wps', skip_caps=True) # Execute fake invocation of DescribeProcess operation by parsing cached response from Emu service xml = open(resource_file('wps_bbox_DescribeProcess.xml'), 'rb').read() process = wps.describeprocess('bbox', xml=xml) # Check process description assert process.identifier == 'bbox' assert process.title == 'Bounding Box' # Check process inputs # Example Input: # identifier=bbox, title=Bounding Box, abstract=None, data type=BoundingBoxData # Supported Value: EPSG:4326 # Supported Value: EPSG:3035 # Default Value: EPSG:4326 # minOccurs=1, maxOccurs=1 for input in process.dataInputs: assert input.identifier == 'bbox' assert input.dataType == 'BoundingBoxData' # Example Output: # identifier=bbox, title=Bounding Box, abstract=None, data type=BoundingBoxData # Supported Value: EPSG:4326 # Default Value: EPSG:4326 # reference=None, mimeType=None # Check process outputs for output in process.processOutputs: assert output.identifier == 'bbox' assert output.dataType == 'BoundingBoxData'
def _executeRequest(self, processid, inputs, verbose): """ This function makes a call to the Web Processing Service with the specified user inputs. """ wps = WebProcessingService(WPS_URL) # if verbose=True, then will we will monitor the status of the call. # if verbose=False, then we will return only the file outputpath. if not verbose: # redirects the standard output to avoid printing request status old_stdout = sys.stdout result = StringIO() sys.stdout = result # executes the request execution = wps.execute(processid, inputs, output="OUTPUT") monitorExecution(execution, download=True) # sets the standard output back to original sys.stdout = old_stdout result_string = result.getvalue() #parses the redirected output to get the filepath of the saved file output = result_string.split('\n') tmp = output[len(output) - 2].split(' ') return tmp[len(tmp) - 1] # executes the request execution = wps.execute(processid, inputs, output="OUTPUT") monitorExecution(execution, download=True)
def _generateRequest(dataSetURI, algorithm, method, varID, verbose): """ Takes a dataset uri, algorithm, method, and datatype. This function will generate a simple XML document to make the request specified. (Only works for ListOpendapGrids and GetGridTimeRange). Will return a list containing the info requested for (either data types or time range). """ POST = WebProcessingService(WPS_Service, verbose=verbose) xmlGen = gdpXMLGenerator() root = xmlGen.getXMLRequestTree(dataSetURI, algorithm, method, varID, verbose) request = etree.tostring(root) execution = POST.execute(None, [], request=request) _execute_request._check_for_execution_errors(execution) if method == 'getDataSetTime': seekterm = '{xsd/gdptime-1.0.xsd}time' elif method == 'getDataType': seekterm = '{xsd/gdpdatatypecollection-1.0.xsd}name' elif method == 'getDataLongName': seekterm = '{xsd/gdpdatatypecollection-1.0.xsd}description' elif method == 'getDataUnits': seekterm = '{xsd/gdpdatatypecollection-1.0.xsd}unitsstring' return _parseXMLNodesForTagText(execution.response, seekterm)
def test_wps_response6(): # Build WPS object; service has been down for some time so skip caps here wps = WebProcessingService('http://rsg.pml.ac.uk/wps/vector.cgi', skip_caps=True) # Execute face WPS invocation request = open(resource_file('wps_PMLExecuteRequest6.xml'), 'rb').read() response = open(resource_file('wps_PMLExecuteResponse6.xml'), 'rb').read() execution = wps.execute(None, [], request=request, response=response) # Check execution result assert execution.status == 'ProcessSucceeded' assert execution.url == 'http://rsg.pml.ac.uk/wps/vector.cgi' assert execution.statusLocation == \ 'http://rsg.pml.ac.uk/wps/wpsoutputs/pywps-132084838963.xml' assert execution.serviceInstance == \ 'http://rsg.pml.ac.uk/wps/vector.cgi?service=WPS&request=GetCapabilities&version=1.0.0' assert execution.version == '1.0.0' # check single output output = execution.processOutputs[0] assert output.identifier == 'output' assert output.title == 'Name for output vector map' assert output.mimeType == 'text/xml' assert output.dataType == 'ComplexData' assert output.reference is None response = output.data[0] should_return = '''<ns3:FeatureCollection xmlns:ns3="http://ogr.maptools.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://www.opengis.net/wps/1.0.0" xsi:schemaLocation="http://ogr.maptools.org/ output_0n7ij9D.xsd">\n\t\t\t\t\t <gml:boundedBy xmlns:gml="http://www.opengis.net/gml">\n\t\t\t\t\t <gml:Box>\n\t\t\t\t\t <gml:coord><gml:X>-960123.1421801626</gml:X><gml:Y>4665723.56559387</gml:Y></gml:coord>\n\t\t\t\t\t <gml:coord><gml:X>-101288.6510608822</gml:X><gml:Y>5108200.011823481</gml:Y></gml:coord>\n\t\t\t\t\t </gml:Box>\n\t\t\t\t\t </gml:boundedBy> \n\t\t\t\t\t <gml:featureMember xmlns:gml="http://www.opengis.net/gml">\n\t\t\t\t\t <ns3:output fid="F0">\n\t\t\t\t\t <ns3:geometryProperty><gml:LineString><gml:coordinates>-960123.142180162365548,4665723.565593870356679,0 -960123.142180162365548,4665723.565593870356679,0 -960123.142180162598379,4665723.565593870356679,0 -960123.142180162598379,4665723.565593870356679,0 -711230.141176006174646,4710278.48552671354264,0 -711230.141176006174646,4710278.48552671354264,0 -623656.677859728806652,4848552.374973464757204,0 -623656.677859728806652,4848552.374973464757204,0 -410100.337491964863148,4923834.82589447684586,0 -410100.337491964863148,4923834.82589447684586,0 -101288.651060882242746,5108200.011823480948806,0 -101288.651060882242746,5108200.011823480948806,0 -101288.651060882257298,5108200.011823480948806,0 -101288.651060882257298,5108200.011823480948806,0</gml:coordinates></gml:LineString></ns3:geometryProperty>\n\t\t\t\t\t <ns3:cat>1</ns3:cat>\n\t\t\t\t\t <ns3:id>1</ns3:id>\n\t\t\t\t\t <ns3:fcat>0</ns3:fcat>\n\t\t\t\t\t <ns3:tcat>0</ns3:tcat>\n\t\t\t\t\t <ns3:sp>0</ns3:sp>\n\t\t\t\t\t <ns3:cost>1002619.181</ns3:cost>\n\t\t\t\t\t <ns3:fdist>0</ns3:fdist>\n\t\t\t\t\t <ns3:tdist>0</ns3:tdist>\n\t\t\t\t\t </ns3:output>\n\t\t\t\t\t </gml:featureMember>\n\t\t\t\t\t</ns3:FeatureCollection>''' # noqa assert compare_xml(should_return, response) is True
def complex_input_with_content(): """ use ComplexDataInput with a direct content """ print("\ncomplex_input_with_content ...") wps = WebProcessingService('http://localhost:8094/wps', verbose=verbose) processid = 'wordcount' textdoc = ComplexDataInput( "ALICE was beginning to get very tired ...") # alice in wonderland inputs = [("text", textdoc)] # list of tuple (output identifier, asReference attribute) outputs = [("output", True)] execution = wps.execute(processid, inputs, output=outputs) monitorExecution(execution) # show status print('percent complete', execution.percentCompleted) print('status message', execution.statusMessage) for output in execution.processOutputs: print('identifier=%s, dataType=%s, data=%s, reference=%s' % (output.identifier, output.dataType, output.data, output.reference))
def complex_input_with_reference(): """ use ComplexDataInput with a reference to a document """ print("\ncomplex_input_with_reference ...") wps = WebProcessingService('http://localhost:8094/wps', verbose=verbose) processid = 'wordcount' textdoc = ComplexDataInput( "http://www.gutenberg.org/files/28885/28885-h/28885-h.htm" ) # alice in wonderland inputs = [("text", textdoc)] # list of tuple (output identifier, asReference attribute) outputs = [("output", True)] execution = wps.execute(processid, inputs, output=outputs) monitorExecution(execution) # show status print('percent complete', execution.percentCompleted) print('status message', execution.statusMessage) for output in execution.processOutputs: print('identifier=%s, dataType=%s, data=%s, reference=%s' % (output.identifier, output.dataType, output.data, output.reference))
def pinned_processes(request): from owslib.wps import WebProcessingService settings = request.db.settings.find_one() or {} processes = [] if 'pinned_processes' in settings: for pinned in settings.get('pinned_processes'): try: service_name, identifier = pinned.split('.', 1) url = request.route_path('processes_execute', _query=[('wps', service_name), ('process', identifier)]) wps = WebProcessingService(url=request.route_url( 'owsproxy', service_name=service_name), verify=False) # TODO: need to fix owslib to handle special identifiers process = wps.describeprocess(identifier) description = headline(process.abstract) except Exception: LOGGER.warn("could not add pinned process %s", pinned) else: processes.append( dict(title=process.identifier, description=description, url=url, service_title=wps.identification.title)) return processes
def _generateRequest(self, dataSetURI, algorithm, method, varID=None, verbose=False): """ Takes a dataset uri, algorithm, method, and datatype. This function will generate a simple XML document to make the request specified. (Only works for ListOpendapGrids and GetGridTimeRange). Will return a list containing the info requested for (either data types or time range). """ wps_Service = 'http://cida.usgs.gov/gdp/utility/WebProcessingService' POST = WebProcessingService(wps_Service, verbose=False) xmlGen = gdpXMLGenerator() root = xmlGen.getXMLRequestTree(dataSetURI, algorithm, method, varID, verbose) # change standard output to not display waiting status if not verbose: old_stdout = sys.stdout result = StringIO() sys.stdout = result request = etree.tostring(root) execution = POST.execute(None, [], request=request) if method == 'getDataSetTime': seekterm = 'time' else: seekterm = 'name' if not verbose: sys.stdout = old_stdout return self._parseXMLNodesForTagText(execution.response, seekterm)
def wps(): '''Returns a WPS instance''' # Initialize WPS client wps = WebProcessingService('http://example.org/wps', skip_caps=True) xml = open(resource_file('wps_CEDACapabilities.xml'), 'rb').read() wps.getcapabilities(xml=xml) return wps
def test_wps_execute_language(monkeypatch): def raise_on_log_error(*a): """Make sure the errors are raised, not only caught and logged""" raise AssertionError monkeypatch.setattr(owslib.wps.log, "error", raise_on_log_error) monkeypatch.setattr(owslib.wps.WPSExecution, "parseResponse", lambda *a: None) wps = WebProcessingService('http://www.example.com', language='fr-CA', skip_caps=True) execution = wps.execute('test', [], response=b'<xml></xml>') assert b'language="fr-CA"' in execution.request def mock_open_url(*args, **kwargs): assert 'language=fr-CA' in args[1] class FakeResponse: def read(self): return b'<xml></xml>' return FakeResponse() monkeypatch.setattr(owslib.wps, "openURL", mock_open_url) execution.status = 'ProcessSucceeded' execution.checkStatus(url='http://www.example.com', response=None, sleepSecs=0)
def call_wps(args): if not args.token: user_id = args.user if not user_id: logging.error("No user id found on the call, aborting!") sys.exit(1) user_token_file = os.path.join("/etc/d4science/", user_id) with open(user_token_file, "r") as f: gcube_vre_token = f.read() else: gcube_vre_token = args.token.encode("utf-8") logging.info("User: %s", args.user) logging.info("Token: (SHA256) %s", hashlib.sha256(gcube_vre_token).hexdigest()) gcube_vre_token_header = {"gcube-token": gcube_vre_token} dataminer_url = ( "http://dataminer-prototypes.d4science.org/wps/" "WebProcessingService" ) wps = WebProcessingService(dataminer_url, headers=gcube_vre_token_header) process_id = args.process process = wps.describeprocess(process_id) inputs = build_inputs(process, args.input, args.inputdata, gcube_vre_token) outputs = [(o.identifier, True) for o in process.processOutputs] # execute the process execution = wps.execute(process_id, inputs, outputs) monitorExecution(execution, sleepSecs=5, download=True) logging.info("Execution status: %s", execution.status) exit_code = 0 if execution.status == "ProcessSucceeded" else 1 logging.info("Exit code: %d", exit_code) produce_output(execution, args.output, args.outdir, gcube_vre_token_header) return exit_code
async def fimex_transfer(*, user_id: str, email: EmailStr, uri: str, wps_url: str, reducetime_start: str = None, reducetime_end: str = None, interpolate_proj_string: str = None, interpolate_method: str = None, select_variables: str, interpolate_xaxis_min: str = None, interpolate_xaxis_max: str = None, interpolate_yaxis_min: str = None, interpolate_yaxis_max: str = None, interpolate_xaxis_units: str = None, interpolate_yaxis_units: str = None, reducebox_east: str, reducebox_south: str, reducebox_west: str, reducebox_north: str, interpolate_hor_steps: str = None, inputtype: str, outputtype: str, background_tasks: BackgroundTasks): input_files = uri.split(",") fimex_list = [] for input_file in input_files: print(input_file) fimex_list.append( Fimex(wps_url, input_file, reducetime_start, reducetime_end, interpolate_proj_string, interpolate_method, select_variables, interpolate_xaxis_min, interpolate_xaxis_max, interpolate_yaxis_min, interpolate_yaxis_max, interpolate_xaxis_units, interpolate_yaxis_units, reducebox_east, reducebox_south, reducebox_west, reducebox_north, interpolate_hor_steps, inputtype, outputtype)) # wps=http://localhost:5000/wps?request=GetCapabilities&service=WPS # input_file = 'http://OpeDAP-server/thredds/dodsC/NBS/S2B/2018/02/18/S2B_MSIL1C_20180218T110109_N0206_R094_T33WWS_20180218T144023.nc' # wps=http://localhost:5000/cgi-bin/pywps.cgi?service=wps&version=1.0.0&request=getcapabilities wps = WebProcessingService(wps_url, verbose=False, skip_caps=True) config = confuse.Configuration('Basket', __name__) transaction = Transaction(str(uuid.uuid4()), user_id, email, status.Status.ORDERED, "nordatanet", fimex_list) solr_client = SolrClient(config['solr']['endpoint'].get(), "basket") solr_client.update(transaction.toSolrDocument()) try: for fimex in fimex_list: execution = wps.execute('transformation', fimex.input_map(), output=fimex.output_map()) background_tasks.add_task(doFinal, execution, email, transaction) print(execution.statusLocation) except requests.exceptions.ConnectionError as ce: raise HTTPException(status_code=502, detail="Failed to establish a connection") return transaction.toJson()
def test_wps_getcapabilities_usgs(): # Initialize WPS client wps = WebProcessingService('http://cida.usgs.gov/gdp/process/WebProcessingService', skip_caps=True) # Execute fake invocation of GetCapabilities operation by parsing cached response from USGS service xml = open(resource_file('wps_USGSCapabilities.xml'), 'rb').read() wps.getcapabilities(xml=xml) # Check WPS description assert wps.updateSequence is not None assert wps.identification.type == 'WPS' assert wps.identification.title == 'Geo Data Portal WPS Implementation' assert wps.identification.abstract == 'A Geo Data Portal Service based on the 52north implementation of WPS 1.0.0' # Check available operations operations = [op.name for op in wps.operations] assert operations == [ 'GetCapabilities', 'DescribeProcess', 'Execute'] # Check high level process descriptions processes = [(p.identifier, p.title) for p in wps.processes] assert processes == [ ('gov.usgs.cida.gdp.wps.algorithm.filemanagement.ReceiveFiles', 'gov.usgs.cida.gdp.wps.algorithm.filemanagement.ReceiveFiles'), # noqa ('gov.usgs.cida.gdp.wps.algorithm.discovery.CalculateWCSCoverageInfo', 'gov.usgs.cida.gdp.wps.algorithm.discovery.CalculateWCSCoverageInfo'), # noqa ('gov.usgs.cida.gdp.wps.algorithm.communication.EmailWhenFinishedAlgorithm', 'gov.usgs.cida.gdp.wps.algorithm.communication.EmailWhenFinishedAlgorithm'), # noqa ('gov.usgs.cida.gdp.wps.algorithm.communication.GeoserverManagementAlgorithm', 'gov.usgs.cida.gdp.wps.algorithm.communication.GeoserverManagementAlgorithm'), # noqa ('gov.usgs.cida.gdp.wps.algorithm.discovery.GetWcsCoverages', 'gov.usgs.cida.gdp.wps.algorithm.discovery.GetWcsCoverages'), # noqa ('gov.usgs.cida.gdp.wps.algorithm.filemanagement.GetWatersGeom', 'gov.usgs.cida.gdp.wps.algorithm.filemanagement.GetWatersGeom'), # noqa ('gov.usgs.cida.gdp.wps.algorithm.discovery.ListOpendapGrids', 'gov.usgs.cida.gdp.wps.algorithm.discovery.ListOpendapGrids'), # noqa ('gov.usgs.cida.gdp.wps.algorithm.filemanagement.CreateNewShapefileDataStore', 'gov.usgs.cida.gdp.wps.algorithm.filemanagement.CreateNewShapefileDataStore'), # noqa ('gov.usgs.cida.gdp.wps.algorithm.discovery.GetGridTimeRange', 'gov.usgs.cida.gdp.wps.algorithm.discovery.GetGridTimeRange'), # noqa ]
def _show_languages(ctx, param, value): if not value or ctx.resilient_parsing: return url = os.environ.get('WPS_SERVICE') or DEFAULT_URL wps = WebProcessingService(url, verify=get_ssl_verify()) click.echo(','.join(wps.languages.supported)) ctx.exit()
def __init__(self, request): self.request = request self.execution = None self.service_name = None self.processid = None self.process = None if 'job_id' in request.params: job = request.db.jobs.find_one( {'identifier': request.params['job_id']}) self.service_name = job.get('service_name') self.execution = check_status(url=job.get('status_location'), response=job.get('response'), verify=False, sleep_secs=0) self.processid = self.execution.process.identifier elif 'wps' in request.params: self.service_name = request.params.get('wps') self.processid = request.params.get('process') if self.service_name: # TODO: avoid getcaps self.wps = WebProcessingService(url=request.route_url( 'owsproxy', service_name=self.service_name), verify=False) # TODO: need to fix owslib to handle special identifiers self.process = self.wps.describeprocess(self.processid) super(ExecuteProcess, self).__init__(request, name='processes_execute', title='')
def create_from_process(cls, url, identifier, request_template, username=None, password=None, output_hook=None): try: wps = WebProcessingService(url, username=username, password=password, verbose=False, skip_caps=False) process = wps.describeprocess(identifier) if process: _f = open(request_template) _run = cls.objects.create(identifier=identifier, title=process.title, abstract=process.abstract, version=wps.version, url=url, service_instance=wps.url, username=username, password=password, request_template=File(_f), output_hook=output_hook) _run._initialized = True _run._wps = wps return _run except: log.exception("Could not create Process!") raise return wps.id
def get_providers(request): """ Lists registered providers. """ store = get_db(request).get_store(StoreServices) providers = [] for service in store.list_services(): try: if service.type.lower() != "wps": continue wps = WebProcessingService(url=service.url, headers=get_cookie_headers( request.headers)) providers.append( dict(id=service.name, title=getattr(wps.identification, "title", ""), abstract=getattr(wps.identification, "abstract", ""), url="{base_url}/providers/{provider_id}".format( base_url=get_wps_restapi_base_url( get_settings(request)), provider_id=service.name), public=service.public)) except Exception as exc: warnings.warn( "Exception occurred while fetching wps {0} : {1!r}".format( service.url, exc), NonBreakingExceptionWarning) return HTTPOk(json={"providers": providers})
def __init__(self, name, url, identifier, inputs=None, linked_inputs=None, monitor=None, progress_range=None, headers=None, **_): """ :param name: task name :param url: url of the WPS provider :param identifier: identifier of the WPS task :param inputs: dict of static inputs for the wps (multiple values can be passed for each key by using an array) :param linked_inputs: dict of dynamic inputs of the wps obtained from upstream tasks (multiple values can be passed for each key by using an array) :param monitor: status and progress monitor :param progress_provider: :param progress_range: progress range of this task in the overall workflow :param headers: headers to be included in the wps call :param _: Accept any others parameters coming from the workflow description """ ProgressMonitorPE.__init__(self, name, monitor) # Convert dict of values or array of values to a flat list of key, value tuple inputs = list(self.iter_inputs(inputs)) linked_inputs = list(self.iter_inputs(linked_inputs)) # Defaults argument (with mutable type) if not progress_range: progress_range = [0, 100] self.set_progress_provider( RangeProgress(progress_range[0], progress_range[1])) self.wps = WebProcessingService(url=url, skip_caps=True, verify=False, headers=headers) self.identifier = identifier self.proc_desc = self.wps.describeprocess(identifier) self._validate_inputs(inputs, linked_inputs) # These are the static inputs # (linked inputs will be appended to inputs just before execution by the _set_inputs function) self.static_inputs = inputs self.dynamic_inputs = [] # Will be filled as PE are connected to us (by the get_output function) self.outputs = [] for _input in linked_inputs: # Here we add PE input that will need to be connected if _input[0] not in self.inputconnections: self._add_input(_input[0]) self._add_linked_input(_input[0], _input[1])