-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from climateintelligence/add-dummy-sleep-process
added a sleep process
- Loading branch information
Showing
3 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from .wps_say_hello import SayHello | ||
from .wps_sleep import Sleep | ||
from .wps_drought import Drought | ||
|
||
processes = [ | ||
SayHello(), | ||
Drought(), | ||
Sleep(), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from pywps import Process, LiteralInput, LiteralOutput | ||
from pywps.app.Common import Metadata | ||
from pywps.ext_autodoc import MetadataUrl | ||
|
||
|
||
class Sleep(Process): | ||
"""A long running process, just sleeping.""" | ||
|
||
def __init__(self): | ||
inputs = [ | ||
LiteralInput( | ||
"delay", "Delay between every update", default="2", data_type="float" | ||
) | ||
] | ||
outputs = [LiteralOutput("sleep_output", "Sleep Output", data_type="string")] | ||
|
||
super(Sleep, self).__init__( | ||
self._handler, | ||
identifier="sleep", | ||
version="1.0", | ||
title="Sleep Process", | ||
abstract="Testing a long running process, in the sleep. " | ||
"This process will sleep for a given delay or 10 seconds if not a valid value.", | ||
profile="", | ||
metadata=[ | ||
MetadataUrl( | ||
"User Guide", | ||
"https://emu.readthedocs.io/en/latest/processes.html", | ||
anonymous=True, | ||
), # noqa | ||
Metadata("PyWPS Demo", "https://pywps-demo.readthedocs.io/en/latest/"), | ||
], | ||
inputs=inputs, | ||
outputs=outputs, | ||
store_supported=True, | ||
status_supported=True, | ||
) | ||
|
||
@staticmethod | ||
def _handler(request, response): | ||
import time | ||
|
||
if "delay" in request.inputs: | ||
sleep_delay = request.inputs["delay"][0].data | ||
else: | ||
sleep_delay = 2 | ||
|
||
response.update_status("PyWPS Process started. Waiting...", 0) | ||
time.sleep(sleep_delay) | ||
response.update_status("PyWPS Process started. Waiting...", 20) | ||
time.sleep(sleep_delay) | ||
response.update_status("PyWPS Process started. Waiting...", 40) | ||
time.sleep(sleep_delay) | ||
response.update_status("PyWPS Process started. Waiting...", 60) | ||
time.sleep(sleep_delay) | ||
response.update_status("PyWPS Process started. Waiting...", 80) | ||
time.sleep(sleep_delay) | ||
response.outputs["sleep_output"].data = "done sleeping" | ||
|
||
response.update_status("PyWPS Process completed.", 100) | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters