本文整理汇总了Python中owslib.wps.WebProcessingService类的典型用法代码示例。如果您正苦于以下问题:Python WebProcessingService类的具体用法?Python WebProcessingService怎么用?Python WebProcessingService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebProcessingService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: complex_input_with_content
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, mimeType attribute)
# when asReference or mimeType is None - the wps service will use its default option
outputs = [("output",True,'some/mime-type')]
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))
示例2: _generateRequest
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)
示例3: _executeRequest
def _executeRequest(self, processid, inputs, output, verbose):
"""
This function makes a call to the Web Processing Service with
the specified user inputs.
"""
wps = WebProcessingService(WPS_URL)
old_stdout = sys.stdout
# create StringIO() for listening to print
result = StringIO()
if not verbose: # redirect standard output
sys.stdout = result
execution = wps.execute(processid, inputs, output)
monitorExecution(execution, download=False) # monitors for success
# redirect standard output after successful execution
sys.stdout = result
monitorExecution(execution, download=True)
result_string = result.getvalue()
output = result_string.split('\n')
tmp = output[len(output) - 2].split(' ')
sys.stdout = old_stdout
return tmp[len(tmp)-1]
示例4: wps
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
示例5: run_wps
def run_wps(process_id,input,output):
#choose the first wps engine
my_engine = WebProcessingService('http://appsdev.hydroshare.org:8282/wps/WebProcessingService', verbose=False, skip_caps=True)
my_engine.getcapabilities()
my_process = my_engine.describeprocess(process_id)
my_inputs = my_process.dataInputs
input_names = [] #getting list of input
for input1 in my_inputs:
input_names.append(input1)
#executing the process..
execution = my_engine.execute(process_id, input, output)
request = execution.request
#set store executeresponse to false
request = request.replace('storeExecuteResponse="true"', 'storeExecuteResponse="false"')
url_wps = 'http://appsdev.hydroshare.org:8282/wps/WebProcessingService'
wps_request = urllib2.Request(url_wps,request)
wps_open = urllib2.urlopen(wps_request)
wps_read = wps_open.read()
if 'href' in wps_read:
tag = 'href="'
location = wps_read.find(tag)
new= wps_read[location+len(tag):len(wps_read)]
tag2 = '"/>\n </wps:Output>\n </wps:ProcessOutputs>\n</wps:'
location2 = new.find(tag2)
final = new[0:location2]
split = final.split()
wps_request1 = urllib2.Request(split[0])
wps_open1 = urllib2.urlopen(wps_request1)
wps_read1 = wps_open1.read()
#return [final_output_url, final_data]
return [wps_read1, split]
示例6: test_wps_describeprocess_bbox
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'
示例7: test_wps_describeprocess_ceda
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'
示例8: multiple_outputs
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)
示例9: test_wps_getcapabilities_52n
def test_wps_getcapabilities_52n():
# Initialize WPS client
wps = WebProcessingService(
'http://geoprocessing.demo.52north.org:8080/52n-wps-webapp-3.3.1/WebProcessingService',
skip_caps=True)
# Execute fake invocation of GetCapabilities operation by parsing cached response from 52North service
xml = open(resource_file('wps_52nCapabilities.xml'), 'rb').read()
wps.getcapabilities(xml=xml)
# Check WPS description
assert wps.identification.type == 'WPS'
# 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 == [
('org.n52.wps.server.algorithm.test.MultiReferenceInputAlgorithm', 'for testing multiple inputs by reference'),
('org.n52.wps.server.algorithm.test.EchoProcess', 'Echo process'),
('org.n52.wps.server.algorithm.test.MultiReferenceBinaryInputAlgorithm', 'for testing multiple binary inputs by reference'), # noqa
('org.n52.wps.server.algorithm.test.LongRunningDummyTestClass', 'org.n52.wps.server.algorithm.test.LongRunningDummyTestClass'), # noqa
('org.n52.wps.server.algorithm.JTSConvexHullAlgorithm', 'org.n52.wps.server.algorithm.JTSConvexHullAlgorithm'),
('org.n52.wps.server.algorithm.test.MultipleComplexInAndOutputsDummyTestClass', 'org.n52.wps.server.algorithm.test.MultipleComplexInAndOutputsDummyTestClass'), # noqa
('org.n52.wps.server.algorithm.test.DummyTestClass', 'org.n52.wps.server.algorithm.test.DummyTestClass')]
示例10: uploadShapeFile
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
示例11: _generateRequest
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)
示例12: _executeRequest
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)
示例13: test_wps_response6
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
示例14: test_wps_getcapabilities_usgs
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
]
示例15: test_wps_describeprocess_emu_all
def test_wps_describeprocess_emu_all():
# Initialize WPS client
wps = WebProcessingService('http://localhost:8094/wps', skip_caps=True)
# Execute fake invocation of DescribeProcess operation by parsing cached response from
xml = open(resource_file('wps_EmuDescribeProcess_all.xml'), 'rb').read()
process = wps.describeprocess('nap', xml=xml)
processes = wps.describeprocess('all', xml=xml)
assert isinstance(process, Process)
assert isinstance(processes, list)