From 21e85152c15204fdac0047d025fba4da2a6a086b Mon Sep 17 00:00:00 2001 From: Triatmoko Date: Tue, 1 Nov 2011 23:03:55 +0100 Subject: search the bug on dbclass --- For Weekly Test/tricode/DbClass.py | 59 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'For Weekly Test/tricode/DbClass.py') diff --git a/For Weekly Test/tricode/DbClass.py b/For Weekly Test/tricode/DbClass.py index a3bf486..8733ec9 100755 --- a/For Weekly Test/tricode/DbClass.py +++ b/For Weekly Test/tricode/DbClass.py @@ -266,42 +266,43 @@ class DBMySQLConnection: else: return 0 #I am not connected - def lockMutex(self, seconds): - if self.connectionCreated == 1: - try: - successful = self.cur.execute("SELECT IS_FREE_LOCK('SoftwareStarted')") - output = self.cur.fetchone() + def lockMutex(self, seconds): + if self.connectionCreated == 1: + try: + successful = self.cur.execute("SELECT IS_FREE_LOCK('SoftwareStarted')") + output = self.cur.fetchone() if output[0] == 1: - #resource is free which means software is not started yet - successful = self.cur.execute("SELECT GET_LOCK('SoftwareStarted', %i)"%(int(seconds))) + #resource is free which means software is not started yet + successful = self.cur.execute("SELECT GET_LOCK('SoftwareStarted', %i)"%(int(seconds))) - output1 = self.cur.fetchone() - if output1[0] == 1: - #I got the lock now - self.lockSet = 1 - return 1 - elif output1[0] == 0: - return 7 #if the attempt timed out (for example, because another client has previously locked the name) - else: - return 6 # if an error occurred (such as running out of memory or the thread was killed with - elif output[0] ==0: - return 4 #software is already running and somebody has allocated the mutex - else: - #means some not so good bug - return 5 # if an error occurs (such as an incorrect argument). + output1 = self.cur.fetchone() + if output1[0] == 1: + #I got the lock now + self.lockSet = 1 + return 1 + elif output1[0] == 0: + return 7 #if the attempt timed out (for example, because another client has previously locked the name) + else: + return 6 # if an error occurred (such as running out of memory or the thread was killed with + elif output[0] ==0: + return 4 #software is already running and somebody has allocated the mutex + else: + #means some not so good bug + return 5 # if an error occurs (such as an incorrect argument). except MySQLdb.Error, e: - error = str(e) - if error[1:5] == '1062': - return 2 #duplicate entry for the key - if debugMode == 1: - print str(e) + error = str(e) + if error[1:5] == '1062': + return 2 #duplicate entry for the key + if debugMode == 1: + print str(e) return 3 - else: - return 0 + else: + return 0 + def maxTaskNo(self): if self.connectionCreated == 1: try: - succ = self.cur.execute("SELECT taskNo FROM TaskTable") + succ = self.cur.execute("SELECT max(taskNo) FROM TaskTable") taskNo = self.cur.fetchone() self.taskNo = taskNo[0] if self.taskNo == None or self.taskNo == '0' or self.taskNo == '' or self.taskNo == 0: -- cgit v1.2.3-55-g7522