From 9f6430ca71dedf9ac0f1ad527a3c3ae2bd1f351a Mon Sep 17 00:00:00 2001
From: RaNaN <Mast3rRaNaN@hotmail.de>
Date: Sun, 1 Aug 2010 18:40:51 +0200
Subject: ocr + db fix

---
 module/AccountManager.py |  4 ++--
 module/FileDatabase.py   | 18 ++++++++++++------
 module/PluginManager.py  |  9 +++++----
 module/plugins/Plugin.py |  3 +--
 4 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/module/AccountManager.py b/module/AccountManager.py
index ff3db5a47..8c4213912 100644
--- a/module/AccountManager.py
+++ b/module/AccountManager.py
@@ -27,7 +27,7 @@ class AccountManager():
 		
 		self.core = core
 		
-		self.accounts = {} # key = (plugin, accountname)
+		self.accounts = {} # key = ( plugin )
 		
 		self.loadAccounts()
 		
@@ -44,7 +44,7 @@ class AccountManager():
 		pass
 		
 	#----------------------------------------------------------------------
-	def saveAccount(self):
+	def saveAccounts(self):
 		"""save all account information"""
 		pass
 		
diff --git a/module/FileDatabase.py b/module/FileDatabase.py
index 5085bc16a..b52acd4d0 100644
--- a/module/FileDatabase.py
+++ b/module/FileDatabase.py
@@ -522,13 +522,19 @@ class FileDatabaseBackend(Thread):
 
 	@queue
 	def getJob(self, occ):
-		if len(occ) == 1:
-			occ = "(%)" % str(occ)
-		else:
-			occ = str(occ)
-		
 		"""return pyfile instance, which is suitable for download and dont use a occupied plugin"""
-		self.c.execute("SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=1 AND l.plugin NOT IN %s AND l.status IN (2,3,6) LIMIT 5" % occ) # very bad!
+		
+		cmd = "("
+		i = 0
+		for item in occ:
+			if i != 0: cmd += ", "
+			cmd += "'%s'" % item
+		
+		cmd += ")"
+		
+		cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=1 AND l.plugin NOT IN %s AND l.status IN (2,3,6) LIMIT 5" % cmd
+			
+		self.c.execute(cmd) # very bad!
 
 		return [x[0] for x in self.c ]
 
diff --git a/module/PluginManager.py b/module/PluginManager.py
index 7ed7d3788..db746975a 100644
--- a/module/PluginManager.py
+++ b/module/PluginManager.py
@@ -191,12 +191,13 @@ class PluginManager():
         """return captcha modul if existent"""
         if self.captchaPlugins.has_key(name):
             plugin = self.captchaPlugins[name]
-            if plugin.has_key("module"):
-                return plugin["module"]
+            if plugin.has_key("class"):
+                return plugin["class"]
         
-            plugin["module"] = __import__(plugin["path"], globals(), locals(), [plugin["name"]] , -1)
+            module = __import__(plugin["path"], globals(), locals(), [plugin["name"]] , -1)
+            plugin["class"] = getattr(module, name)
         
-            return plugin["module"]
+            return plugin["class"]
         
         return None
     #----------------------------------------------------------------------
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 69e398439..e3b1b3299 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -178,8 +178,7 @@ class Plugin(object):
         
         f = temp.file
         f.write(content)
-        #f.close()
-        
+        f.flush()
         
         
         Ocr = self.core.pluginManager.getCaptchaPlugin(self.__name__)
-- 
cgit v1.2.3