diff options
author | mkaay <mkaay@mkaay.de> | 2010-08-25 16:48:55 +0200 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-08-25 16:48:55 +0200 |
commit | 3c9f55270a83b0e88ec0dc516f9d9921e4d7b6ea (patch) | |
tree | c5b2b1bfeb7eb8df2b97be118f6cbcec4e29cb3b /module/CaptchaManager.py | |
parent | ul.to fetching, so.biz expire (diff) | |
download | pyload-3c9f55270a83b0e88ec0dc516f9d9921e4d7b6ea.tar.xz |
merged gui
Diffstat (limited to 'module/CaptchaManager.py')
-rw-r--r-- | module/CaptchaManager.py | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/module/CaptchaManager.py b/module/CaptchaManager.py deleted file mode 100644 index d6a8fd077..000000000 --- a/module/CaptchaManager.py +++ /dev/null @@ -1,116 +0,0 @@ -# -*- coding: utf-8 -*- - -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: mkaay -""" - -from uuid import uuid4 as uuid -from threading import Lock - -class CaptchaManager(): - def __init__(self, core): - self.lock = Lock() - self.core = core - self.tasks = [] - - def newTask(self, plugin): - task = CaptchaTask(plugin, self) - self.lock.acquire() - self.tasks.append(task) - self.lock.release() - return task - - def removeTask(self, task): - self.lock.acquire() - self.tasks.remove(task) - self.lock.release() - - def getTask(self): - self.lock.acquire() - for task in self.tasks: - status = task.getStatus() - if status == "waiting" or status == "shared-user": - self.lock.release() - return task - self.lock.release() - return None - - def getTaskFromID(self, tid): - self.lock.acquire() - for task in self.tasks: - if task.getID() == tid: - self.lock.release() - return task - self.lock.release() - return None - -class CaptchaTask(): - def __init__(self, plugin, manager): - self.lock = Lock() - self.plugin = plugin - self.manager = manager - self.captchaImg = None - self.captchaType = None - self.result = None - self.status = "preparing" - self.id = uuid().hex - - def setCaptcha(self, img, imgType): - self.lock.acquire() - self.captchaImg = img - self.captchaType = imgType - self.lock.release() - - def getCaptcha(self): - return self.captchaImg, self.captchaType - - def setResult(self, result): - self.lock.acquire() - self.result = result - self.lock.release() - - def getResult(self): - return self.result - - def getID(self): - return self.id - - def getStatus(self): - return self.status - - def setDone(self): - self.lock.acquire() - self.status = "done" - self.lock.release() - - def setWaiting(self): - self.lock.acquire() - self.status = "waiting" - self.lock.release() - - def setWatingForUser(self, exclusive): - self.lock.acquire() - if exclusive: - self.status = "user" - else: - self.status = "shared-user" - self.lock.release() - - def removeTask(self): - self.manager.removeTask(self) - - def __str__(self): - return "<CaptchaTask '%s'>" % (self.getID(),) |