/
test_process.py
37 lines (34 loc) · 1.53 KB
/
test_process.py
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
from pywps.Process import WPSProcess
import os
import time
import types
class Process(WPSProcess):
"""Main process class"""
def __init__(self):
"""Process initialization"""
# init process
WPSProcess.__init__(self,
identifier = os.path.split(__file__)[-1].split(".")[0],
title="TESTit",
version = 0.1,
abstract = "Just testing basic functions, adding input, checking status, etc...",
storeSupported = "true",
statusSupported = "true",
)
self.valueIn = self.addLiteralInput(identifier = "val", type=types.IntType,title = "User Input Value", default = 6)
self.timePauseIn = self.addLiteralInput(identifier = "pauseTime", type=types.FloatType,title = "User Value for Pause Time", default = 1.)
self.numberPauseIn = self.addLiteralInput(identifier = "pauseNumber", type=types.IntType,title = "User Value for Number of Pauses", default = 3)
self.pauseIn = self.addLiteralInput(identifier = "pause", type=bool,title = "User Input Value", default = True)
self.textOut = self.addLiteralOutput(identifier="text", title="just some text")
def execute(self):
self.textOut.setValue("%i * 2. = %f" % (int(self.valueIn.getValue()),int(self.valueIn.getValue())*2.))
N = self.numberPauseIn.getValue()
n = self.timePauseIn.getValue()
p = self.pauseIn.getValue()
if N*n>60:
return "BAD"
if p:
for i in range(N):
self.status.set("Waiting %f second for the %i time (out of %i), just because" % (n,i+1,N),100-N+i)
time.sleep(n)
return