summaryrefslogtreecommitdiffstats
path: root/notFinishedCode/dbDemo.py
blob: 713768d76594089ce2e7087d8d23b325c264ac7d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import dbClass
from time import sleep
user = 'root'
passw = 'randompasswordSQL'
host = 'localhost'
dbname = 'gsmselftesting'

x = dbClass.DBMySQLConnection(user, passw, host, dbname)
print "connected to the DB ", x.connectDB()
print "do i have anything to do", x.anyTasksToDo()
print 'mutex says' , x.lockMutex(10)
print 'release mutex says ', x.releaseMutex()
sleep(45)

for item in x.tasksList:
 	item = x.tasksList[index]
	tempItem = item
	taskID = item[0]
	taskNo = item[1]
	callFrom = item[2]
	callTo = item[3]
	testDone = item[4]
	print "call from to ", taskID , callFrom , callTo, taskNo, testDone	
	if testDone == str(0):
		print item[0]
		tempItem[4]=str(1)
		print "delete a task from temp table", x.deleteTempTask(taskID)
		x.tasksList[index]=tempItem

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()

for item in x.tasksList:
        device = item[3]
        print "device name", device
        deviceAN= x.deviceAddress(str(device))
        print "device's IP and number", deviceAN[0], deviceAN[1]

print "update task result ", x.updateTaskResult(1,3)

print "update ping Table", x.updatePingResult(1,5,4,3,2,1)

print "delete a task from temp table", x.deleteTempTask(2)
print "add a result to the table", x.addResult(4,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', 'GSMu1', 2)
#for item in x.tasksList:
#       taskID = item[0]
#       callFrom = item[1]
#       callTo = item[2]
#       print "call from to ", taskID , callFrom , callTo

#print 'i am inserting into the table something', x.insertTaskIn2('gsm4','sip8',2)
#print 'i am inserting into the table something', x.insertTaskIn2('gsm4','sip8',2)
#print 'i am inserting into the table something', x.insertTaskIn2('gsm4','sip8',2)
#print 'i am inserting into the table something', x.insertTaskIn2('gsm4','sip8',2)
#-----------------------------------------------------------------------------------
#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
for item in x.tasksList:
        taskID = item[0]
        taskNo = item[1]
        callFrom = item[2]
        callTo = item[3]
        print "call from to ", taskID , callFrom , callTo, taskNo

print "close connection to the DB", x.closeDBConn()

del x