1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
"""
This example calls processes on a Emu WPS: https://github.com/bird-house/emu
"""
from owslib.wps import WebProcessingService, ComplexDataInput, monitorExecution
def multiple_outputs():
print("\nmultiple outputs ...")
# get multiple outputs
wps = WebProcessingService('http://localhost:8094/wps')
processid = 'dummyprocess'
inputs = [("input1", '1'), ("input2", '2')]
# list of tuple (output identifier, asReference attribute, mimeType attribute)
# when asReference or mimeType is None - the wps service will use its default option
outputs = [("output1",True,'some/mime-type'), ("output2",False,None)]
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 complex_input_with_reference():
"""
use ComplexDataInput with a reference to a document
"""
print("\ncomplex_input_with_reference ...")
wps = WebProcessingService('http://localhost:8094/wps')
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, 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))
def complex_input_with_content():
"""
use ComplexDataInput with a direct content
"""
print("\ncomplex_input_with_content ...")
wps = WebProcessingService('http://localhost:8094/wps')
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))
if __name__ == '__main__':
# call the examples ...
multiple_outputs()
complex_input_with_reference()
complex_input_with_content()
|