summaryrefslogtreecommitdiffstats
path: root/notFinishedCode
diff options
context:
space:
mode:
authorRefik Hadzialic2011-07-15 17:57:54 +0200
committerRefik Hadzialic2011-07-15 17:57:54 +0200
commitd7f19b2e34e1b939750a04e2102c9830231387af (patch)
treedd893716a6a1a8dccbaf1f3f3f97dee71747704b /notFinishedCode
parentI added two new functions that were requested by Tri, for checking is there a... (diff)
downloadgsm-selftest-d7f19b2e34e1b939750a04e2102c9830231387af.tar.gz
gsm-selftest-d7f19b2e34e1b939750a04e2102c9830231387af.tar.xz
gsm-selftest-d7f19b2e34e1b939750a04e2102c9830231387af.zip
Added a function that searches for a task inside the task list!
Diffstat (limited to 'notFinishedCode')
-rw-r--r--notFinishedCode/dbClass.py37
1 files changed, 26 insertions, 11 deletions
diff --git a/notFinishedCode/dbClass.py b/notFinishedCode/dbClass.py
index 5e323cf..ff0e485 100644
--- a/notFinishedCode/dbClass.py
+++ b/notFinishedCode/dbClass.py
@@ -224,9 +224,8 @@ class DBMySQLConnection:
for record in output:
columns = list()
for entry in record:
- columns.append(str(entry))
notFound = 1
- self.tasksList.append(columns)
+
if notFound == 0:
if self.insertTaskIn2(fromDevice, toDevice, taskNo) == 1:
return 4 #i inserted the new task
@@ -267,8 +266,21 @@ class DBMySQLConnection:
return 2 #duplicate entry for the key
return 3
else:
- return 0
+ return 0
+
+ def searchTaskList(self, fromDevice, toDevice):
+ if self.connectionCreated == 1:
+ for item in self.tasksList:
+ taskID = item[0]
+ taskNo = item[1]
+ callFrom = item[2]
+ callTo = item [3]
+ if callFrom == fromDevice and callTo == toDevice:
+ return 1 #that task was found
+ return 2 #that task wasn't found
+ else:
+ return 0
user = 'root'
passw = 'randompasswordSQL'
host = 'localhost'
@@ -277,7 +289,6 @@ dbname = 'gsmselftesting'
x = DBMySQLConnection(user, passw, host, dbname)
print "connected to the DB ", x.connectDB()
print "do i have anything to do", x.anyTasksToDo()
-
for item in x.tasksList:
taskID = item[0]
taskNo = item[1]
@@ -285,6 +296,10 @@ for item in x.tasksList:
callTo = item[3]
print "call from to ", taskID , callFrom , callTo, taskNo
+print "found", x.searchTaskList('S1IP2','GSM1')
+#if variable == 0:
+# print x.insertTaskIn2('gsm4','sip8',2)
+
print "remove a task ",x.removeTaskFromList('2')
#print x.cleanTasksList()
@@ -303,13 +318,13 @@ print "add a result to the table", x.addResult(2,34)
#new task to do
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#just made for Tri :)---------------------------------------------------------------
-print x.cleanTasksList()
-print "do i have any task from SIP1 to GSM1 to do", x.anyTasksFromTo('SIP2', 'GSM1', 2)
-for item in x.tasksList:
- taskID = item[0]
- callFrom = item[1]
- callTo = item[2]
- print "call from to ", taskID , callFrom , callTo
+#print x.cleanTasksList()
+#print "do i have any task from SIP1 to GSM1 to do", x.anyTasksFromTo('SIP2', 'GSM1', 2)
+#for item in x.tasksList:
+# taskID = item[0]
+# callFrom = item[1]
+# callTo = item[2]
+# print "call from to ", taskID , callFrom , callTo
#print x.insertTaskIn2('gsm4','sip8',2)
#-----------------------------------------------------------------------------------