From 50d4df8b4d48b855bd18e9922355b7f3f2b4da4e Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 20 Mar 2012 14:57:45 +0100 Subject: captcha decrypting for all plugin types, new interaction manager --- module/interaction/InteractionTask.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'module/interaction/InteractionTask.py') diff --git a/module/interaction/InteractionTask.py b/module/interaction/InteractionTask.py index 7963a5c72..b372321b0 100644 --- a/module/interaction/InteractionTask.py +++ b/module/interaction/InteractionTask.py @@ -30,12 +30,14 @@ class InteractionTask(BaseInteractionTask): storage = None #: Timestamp when task expires wait_until = 0 - #: The received result as string representation + #: The received result result = None #: List of registered handles handler = None #: Error Message error = None + #: Timeout locked + locked = False def __init__(self, *args, **kwargs): BaseInteractionTask.__init__(self, *args, **kwargs) @@ -46,25 +48,28 @@ class InteractionTask(BaseInteractionTask): self.wait_until = 0 def convertResult(self, value): + #TODO: convert based on input/output return value def getResult(self): return self.result def setResult(self, value): - pass + self.result = self.convertResult(value) - def setWaiting(self, sec): - self.wait_until = max(time() + sec, self.wait_until) + def setWaiting(self, sec, lock=False): + if not self.locked: + self.wait_until = max(time() + sec, self.wait_until) + if lock: self.locked = True - def isWaiting(self, sec): + def isWaiting(self): if self.result or self.error or time() > self.waitUntil: return False return True def timedOut(self): - return time() > self.waitUntil + return time() > self.wait_until > 0 def correct(self): [x.taskCorrect(self) for x in self.handler] -- cgit v1.2.3