summaryrefslogtreecommitdiffstats
path: root/For Weekly Test/tricode/gsmselftest-website3.py
diff options
context:
space:
mode:
Diffstat (limited to 'For Weekly Test/tricode/gsmselftest-website3.py')
-rw-r--r--For Weekly Test/tricode/gsmselftest-website3.py126
1 files changed, 78 insertions, 48 deletions
diff --git a/For Weekly Test/tricode/gsmselftest-website3.py b/For Weekly Test/tricode/gsmselftest-website3.py
index d83e64c..1f33e1a 100644
--- a/For Weekly Test/tricode/gsmselftest-website3.py
+++ b/For Weekly Test/tricode/gsmselftest-website3.py
@@ -32,6 +32,10 @@ class TimeoutException(Exception):
global resultsList
resultsList = list()
+global taskNo
+dbStatus = None
+global caller
+global callee
def timeout_handler(signum, frame):
raise TimeoutException()
@@ -65,26 +69,25 @@ def allPing(): #ping all existing devices
gsmBox2 = server.ping(1)
def initDB(): # function for connection database
- global dbStatus
- global db
-
- db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
- db.connectDB()
- dbStatus = db.connectDB()
- if dbStatus == 1:
- print 'Lock the mutex: ' + str(db.lockMutex(600))
+ global dbStatus
+ global db
+ if dbStatus != 1:
+ db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
+ db.connectDB()
+ dbStatus = db.connectDB()
+ if dbStatus == 1:
+ print 'Lock the mutex: ' + str(db.lockMutex(600))
def initTrueTable(x):
initResult = trueTableClass.trueTable(x)
initResult.initTrueTable()
- global finalResult
+
print '\n'
openBSC = None
asterikServer = None
finalResult = list()
for x in initResult.nanoBts:
- print x
- finalResult.append(x)
+
name = x[0]
if x[1] == True:
openBSC = True
@@ -107,9 +110,6 @@ def initTrueTable(x):
else:
print bcolors.OKGREEN +name+ ' not Working'+ bcolors.ENDC
- finalResult.append(['openBSC', openBSC])
- finalResult.append(['asterikServer', asterikServer])
-
print ''
if openBSC != None:
if openBSC == True:
@@ -151,7 +151,10 @@ def isThere(keyword,lists):
def testDest(callFrom, callTo, tried):
makeTest.initTest(callFrom,callTo)#xxxx
+ db.insertTask(taskNum,callFrom,callTo)
smartResultList.append([callFrom,callTo, makeTest.result,tried])
+ taskID = db.maxTaskID()
+ db.addResult(taskID, makeTest.result)
if WebStatus == True:
errorCodes(callFrom, callTo, makeTest.result)
@@ -277,7 +280,6 @@ def smartTest():
for RZ in cpgsmRZList:
repeat = False
for gsmrzResult in smartResultList:
-
if gsmrzResult[0] == RZ or gsmrzResult[1] == RZ:
if int(gsmrzResult[2]) == 486 or int(gsmrzResult[2]) == 801 or int(gsmrzResult[2]) == 802:
repeat = True
@@ -287,9 +289,15 @@ def smartTest():
if int(gsmrzResult[2]) == 200:
repeat = False
if gsmrzResult[1] == RZ and int(gsmrzResult[2]) == 998:
- cpgsmRZList.remove(RZ)
+ try:
+ cpgsmRZList.remove(RZ)
+ except ValueError:
+ message = 'Error'
if gsmrzResult[0] == RZ and int(gsmrzResult[2]) == 999:
- cpgsmRZList.remove(RZ)
+ try:
+ cpgsmRZList.remove(RZ)
+ except ValueError:
+ message = 'Error'
if len(cpgsmRZList) > 1:
if repeat == True:
@@ -305,21 +313,23 @@ def smartTest():
for remov in rem:
for x in smartResultList:
if x == remov:
- smartResultList.remove(x)
-
+ try:
+ smartResultList.remove(x)
+ except ValueError:
+ message = 'Error'
return smartResultList
def doSmartTest(status):
+ global taskNum
global WebStatus
initDB()
- allPing()
- db.updatePingResult('0', sipServer, sipGate, unisip, gsmBox1, gsmBox2)
+ taskNum = db.maxTaskNo()
global makeTest
if status == True:
WebStatus = True
else:
WebStatus = False
- makeTest = initTestClass.doTest()
+ makeTest = initTestClass.initTesting()
result = smartTest()
initTrueTable(result)
if status == True:
@@ -330,7 +340,7 @@ def doSipTest():
#destList = ['gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm' ]
destList = ['landline', 'unisip']
- doTest = initTestClass.doTest()
+ doTest = initTestClass.initTesting()
for callTo in destList:
callFrom = 'sip'
@@ -340,7 +350,7 @@ def doSipTest():
def doIncomingTest(): #incoming call to RZ network
destList = ['GSMRZ1','unisip', 'GSMRZ2','GSMRZ3']
- doTest = initTestClass.doTest()
+ doTest = initTestClass.initTesting()
for callTo in destList:
callFrom = 'landline'
doTest.initTest(callFrom,callTo)
@@ -351,7 +361,7 @@ def doGsmrzTest():
destList = ['GSMRZ1','GSMRZ2', 'GSMRZ3']
callList = ['sip']
- doTest = initTestClass.doTest()
+ doTest = initTestClass.initTesting()
for callFrom in callList:
for callTo in destList:
@@ -364,7 +374,7 @@ def doGsmExtTest():
destList = ['GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm']
callList = ['sip']
- doTest = initTestClass.doTest()
+ doTest = initTestClass.initTesting()
for callFrom in callList:
for callTo in destList:
@@ -379,21 +389,6 @@ def doAllTest():
doGsmrzTest()
doGsmExtTest()
-#no need anymore
-def regularTest(x):
- initDB()
- allPing()
- db.updatePingResult('0', sipServer, sipGate, unisip, gsmBox1, gsmBox2)
- regulartest = initTestClass.doTest()
- regulartest.smartTest()
- if x == True:
- for messages in regulartest.messageList:
- sendResultWebsite(messages)
- print messages
- sleep(0.25)
- initTrueTable(regulartest.smartResultList)
- sendFinishMessage()
- initTrueTable(regulartest.smartResultList)
def sendResultWebsite(message):
if server.sendData(message+ chr(10)) == 1:
@@ -421,13 +416,35 @@ def sendFinishMessage():
def withDB(x):
initDB()
+
+ if x == False:
+ deviceLists = db.deviceList()
+ callerFound = False
+ calleeFound = False
+ for device in deviceLists:
+ if caller == device[0]:
+ callerFound = True
+ break
+
+ for device in deviceLists:
+ if callee == device[0]:
+ calleeFound = True
+ break
+ if callerFound != True or calleeFound != True:
+ if callerFound != True:
+ print 'No device with name', caller
+ if calleeFound != True:
+ print 'No device with name', callee
+ if callerFound == True and calleeFound == True:
+ taskNumber = db.maxTaskNo()
+ db.insertTaskIn2(caller, callee, taskNumber)
resultsList = list()
if dbStatus == 1: # Checking connection to database
if db.anyTasksToDo() == 1: # Checking task on the table
allPing()
i=0
- makeTest = initTestClass.doTest()
+ makeTest = initTestClass.initTesting()
for item in db.tasksList:
@@ -451,7 +468,7 @@ def withDB(x):
resultsList.append([callFrom, callTo, makeTest.result])
db.errorCode(makeTest.result)
- print makeTest.result
+
if int(makeTest.result) == 200:
print bcolors.OKGREEN +'Result : ' +str(makeTest.result)+ ' ' +db.errCode + bcolors.ENDC
else:
@@ -623,6 +640,13 @@ def closeFunction(dbConn,serverSocket):
if len(sys.argv) > 1:
command = sys.argv[1]
+ if len(sys.argv) > 2:
+ try:
+ caller = sys.argv[2]
+ callee = sys.argv[3]
+ except ValueError:
+ print "Error given caller and destination. Type '--help' for more information."
+
print ' '
if command == '--all':
@@ -646,9 +670,12 @@ if len(sys.argv) > 1:
doIncomingTest()
elif command == '--smart':
+ initDB()
resultsList = list()
+ allPing()
+ taskNo = db.maxTaskNo()
+ db.updatePingResult(taskNo, sipServer, sipGate, unisip, gsmBox1, gsmBox2)
doSmartTest(False)
- #regularTest(False)
elif command == '--devconf':
updateDevice()
@@ -662,11 +689,12 @@ if len(sys.argv) > 1:
print file.read()
else:
- print "command not found, Type '--help', '--credits' for more information."
+ print "command not found, Type '--help' for more information."
print '\n'
else:
global server
global tried
+
initDB() # should put db condition
server = ServerClassSoftware.ServerHandlerSoftware(34500) #define the port
@@ -685,9 +713,9 @@ else:
withDB(True)
if test == 'SMART TEST':
- #allPing()
- #taskNo = db.maxTaskNo()
- #db.updatePingResult(taskNo, sipServer, sipGate, unisip, gsmBox1, gsmBox2)
+ allPing()
+ taskNo = db.maxTaskNo()
+ db.updatePingResult(taskNo, sipServer, sipGate, unisip, gsmBox1, gsmBox2)
server.sendData('CONFIRM\n')
print 'SMART TEST STARTED'
resultsList = list()
@@ -701,6 +729,8 @@ else:
else:
sys.exit('WE DIDN\'T RECEIVE THE CONFIRMATION')
+db.closeDBConn()
+