summaryrefslogtreecommitdiffstats
path: root/For Weekly Test/tricode/gsmselftest.py
diff options
context:
space:
mode:
authorgsmselftest2011-11-02 18:41:14 +0100
committergsmselftest2011-11-02 18:41:14 +0100
commita5308bf13c21c85f1759f2ce51e015a5ac5d9ee0 (patch)
treeac72461edded16da983384976656cb8160a97eaa /For Weekly Test/tricode/gsmselftest.py
parentMerge branch 'master' of lab.ks.uni-freiburg.de:lsfks/projekte/gsm-selftest (diff)
downloadgsm-selftest-a5308bf13c21c85f1759f2ce51e015a5ac5d9ee0.tar.gz
gsm-selftest-a5308bf13c21c85f1759f2ce51e015a5ac5d9ee0.tar.xz
gsm-selftest-a5308bf13c21c85f1759f2ce51e015a5ac5d9ee0.zip
final version
Diffstat (limited to 'For Weekly Test/tricode/gsmselftest.py')
-rwxr-xr-xFor Weekly Test/tricode/gsmselftest.py622
1 files changed, 499 insertions, 123 deletions
diff --git a/For Weekly Test/tricode/gsmselftest.py b/For Weekly Test/tricode/gsmselftest.py
index 274a67c..3bda2c5 100755
--- a/For Weekly Test/tricode/gsmselftest.py
+++ b/For Weekly Test/tricode/gsmselftest.py
@@ -7,13 +7,38 @@ import PingClass
import trueTableClass
import initTestClass
import usbDetectClass
+import ServerClassSoftware
+import signal
+import random
from time import sleep
+class bcolors:
+ HEADER = '\033[95m'
+ OKBLUE = '\033[94m'
+ OKGREEN = '\033[92m'
+ WARNING = '\033[93m'
+ FAIL = '\033[91m'
+ ENDC = '\033[0m'
+
+ def disable(self):
+ self.HEADER = ''
+ self.OKBLUE = ''
+ self.OKGREEN = ''
+ self.WARNING = ''
+ self.FAIL = ''
+ self.ENDC = ''
+class TimeoutException(Exception):
+ pass
+
global resultsList
resultsList = list()
+global taskNo
+dbStatus = None
+global caller
+global callee
-GSMListPrefix = [['GSMExt.Tm','0151'],['GSMExt.Tm','0160'],['GSMExt.Tm','0170'],['GSMExt.Tm','0171'],['GSMExt.Tm','0175'],['GSMExt.Voda','0152'],['GSMExt.Voda','0162'],['GSMExt.Voda','0172'],['GSMExt.Voda','0173'],['GSMExt.Voda','0174'],['GSMExt.Eplus','0157'],['GSMExt.Eplus','0177'],['GSMExt.Eplus','0155'],['GSMExt.Eplus','0163'],['GSMExt.Eplus','0178'],['GSMExt.O2','0159'],['GSMExt.O2','0176'],['GSMExt.O2','0179'],['GSMRZ1','0761']]
-
+def timeout_handler(signum, frame):
+ raise TimeoutException()
def allPing(): #ping all existing devices
@@ -25,94 +50,308 @@ def allPing(): #ping all existing devices
serverAdd = db.deviceAddress(str('landline'))
server = PingClass.Ping(str(serverAdd[4]))
- sipGate = server.ping(2)
+ sipGate = server.ping(1)
serverAdd = db.deviceAddress(str('sip'))
server = PingClass.Ping(str(serverAdd[4]))
- sipServer = server.ping(2)
+ sipServer = server.ping(1)
serverAdd = db.deviceAddress(str('unisip'))
server = PingClass.Ping(str(serverAdd[4]))
- unisip = server.ping(2)
+ unisip = server.ping(1)
serverAdd = db.deviceAddress(str('GSMRZ2'))
server = PingClass.Ping(str(serverAdd[4]))
- gsmBox1 = server.ping(2)
+ gsmBox1 = server.ping(1)
serverAdd = db.deviceAddress(str('GSMRZ3'))
server = PingClass.Ping(str(serverAdd[4]))
- gsmBox2 = server.ping(2)
-
-def initDB():
- global dbStatus
- global db
-
- db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
- db.connectDB()
- dbStatus = db.connectDB()
-
+ gsmBox2 = server.ping(1)
+
+def initDB(): # function for connection database
+ 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()
+
print '\n'
openBSC = None
+ asterikServer = None
+ finalResult = list()
for x in initResult.nanoBts:
+
name = x[0]
if x[1] == True:
openBSC = True
asterikServer = True
- print name+ ' Working'
+ print bcolors.OKGREEN +name+ ' Working'+ bcolors.ENDC
+
else:
if int(x[1]) == 486:
- print name+ ' not Working'
+ print bcolors.FAIL+name+ ' not Working' + bcolors.ENDC
elif int(x[1]) == 200:
- print name+ ' Working'
+ print bcolors.OKGREEN +name+ ' Working'
+ asterikServer = True
+ elif int(x[1]) == 402:
+ print bcolors.WARNING +name+ ' not Working need top up the credit'
+ asterikServer = True
elif int(x[1]) == 998 or int(x[1]) == 999:
- print name+ ' not Working, handler error'
+ print bcolors.FAIL+name+ ' not Working, handler error'+ bcolors.ENDC
+ elif int(x[1]) == 801 or int(x[1]) == 802:
+ print bcolors.FAIL+name+ ' Device Error, Check the device'+ bcolors.ENDC
else:
- print name+ ' not Working'
+ print bcolors.OKGREEN +name+ ' not Working'+ bcolors.ENDC
+
print ''
if openBSC != None:
if openBSC == True:
- print 'openBSC working'
+ print bcolors.OKGREEN +'openBSC working'+ bcolors.ENDC
else:
- print 'openBSC doesnt work'
+ print bcolors.FAIL+'openBSC doesnt work'+ bcolors.ENDC
print ''
- if initResult.asteriskServer == True:
- print 'asterik server is working'
- print '\n'
+ if initResult.asteriskServer == True or asterikServer == True:
+ print bcolors.OKGREEN +'asterik server is working'+ bcolors.ENDC
+ print ''
if initResult.outGoingRZ == True:
- print 'Outgoing call from RZ is working'
+ print bcolors.OKGREEN +'Outgoing call from RZ is working'+ bcolors.ENDC
elif initResult.outGoingRZ == False:
- print 'Outgoing call from RZ is not working'
+ print bcolors.FAIL+'Outgoing call from RZ is not working'+ bcolors.ENDC
if initResult.incomingRZ == True:
- print 'incoming call from outside RZ to GSM RZ is working'
+ print bcolors.OKGREEN +'incoming call from outside RZ to GSM RZ is working'+ bcolors.ENDC
elif initResult.incomingRZ == False:
- print 'incoming call from outside RZ to GSM RZ is not working'
+ print bcolors.FAIL+'incoming call from outside RZ to GSM RZ is not working'+ bcolors.ENDC
print '\n'
+
+def errorCodes(callFrom, callTo, result):
+ message = '|' + str(callFrom) + '|' + str(callTo) + '|' + str(result) + '|' + str(db.errorCode(result))
+ print message
+ sendResultWebsite(message)
+
+ # function to search in the list
+def isThere(keyword,lists):
+ x = 0
+ for item in lists:
+
+ if item == keyword:
+ return 1
+ else:
+ x = x+1
+
+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)
+
+def smartTest():
+ global smartResultList
+ smartResultList = list()
+ deviceLists = db.deviceList()
+ gsmList = list()
+ gsmRZList = list()
+ sipList = list()
+ destList = list()
+ rem = list()
+ item = list()
+
+ cpgsmRZList = list()
+
+ for lists in deviceLists: #define category of the device
+ device = lists[0]
+ if device[0:5] == 'GSMRZ':
+ gsmRZList.append(device)
+ cpgsmRZList.append(device)
+ elif device[0:5] == 'GSMEx':
+ gsmList.append(device)
+ else:
+ sipList.append(device)
+
+ if device[0:5] == 'GSMRZ' or device[0:5] == 'GSMEx' or device == 'sip':
+ destList.append(device)
+ #first test from university telphone network to random GSM RZ avaliable
+ i = random.randint(0, len(gsmRZList)-1)
+ callTo = gsmRZList[i]
+ callFrom = 'unisip'
+ testDest(callFrom, callTo, 1)
+ gsmRZList.remove(callTo)
+ destList.remove(callTo)
+
+
+
+ for callFrom in gsmRZList:
+ i = random.randint(0, len(destList)-1) #Check whether the caller and dest are same
+ callTo = destList[i]
+ if callFrom == callTo: #Check whether the caller and dest are same
+ if i == 0:
+ i = i+1 # if it in the first list, change to be the second list else, just back on step.
+ else:
+ i = i-1
+ callTo = destList[i]
+
+ destList.remove(callTo)
+ destList.remove(callFrom)
+ gsmRZList.remove(callFrom)
+ testDest(callFrom, callTo, 1)
+
+
+ # test incoming call from outside rz network to gsm rz
+ i = random.randint(0, len(gsmRZList)-1) #
+ callTo = gsmRZList[i]
+ callFrom = 'landline'
+
+ if isThere(callTo,destList) == 1: # Checking whether caller at gsmrz list in the destination list, if yes delete it.
+ destList.remove(callTo)
+ testDest(callFrom, callTo, 1)
+
+ for callTo in destList:
+ callFrom = 'sip'
+ if callFrom != callTo:
+ testDest(callFrom, callTo, 1)
+
+ #checking unsuccess call, to make sure that destination are really unreachable
+ for dest in smartResultList:
+ #check unsuccess call and did the test have already tried, 2 means has been check
+ if int(dest[2]) == 486 or int(dest[2]) == 999 or int(dest[2]) == 998 or int(dest[2]) == 801 or int(dest[2]) == 802:
+ if int(dest[3]) != 2 and dest[1] != 'sip':
+ testDestination = True
+ founds = False
+ testCaller = True
+ # make sure that destination have not tested by another part and give success result.
+ for test in smartResultList:
+ if test[1] == dest[1] or test[0] == dest[1]:
+ if int(test[2]) == 200:
+ testDestination = False
+ if test[1] == dest[0] or test[0] == dest[0]:
+ if int(test[2]) == 200:
+ testCaller = False
+ #if destination have not tested by other part. try to test from RZ GSM
+ if int(test[2]) == 200:
+ for caller in cpgsmRZList:
+ if caller == test[0] or caller == test[1]:
+ callFrom = caller
+ founds = True
+
+ if dest[0] != 'sip':
+ founds = False
+
+ if testDestination == True:
+ if founds != True:
+ callFrom = 'sip'
+ callTo = dest[1]
+ if dest[0] != 'sip':
+ testDest(callFrom, callTo, 2)
+ rem.append(dest)
+
+ #check unsuccess call because caller handler having problem
+ #destination handler having problem, we should make test also to the caller
+ if int(dest[2]) == 998 or int(dest[2]) == 802 or int(dest[2]) == 486:
+ if testCaller == True:
+ if founds != True:
+ callFrom = 'sip'
+ callTo = dest[0]
+ testDest(callFrom, callTo, 2)
+ rem.append(dest)
+
+
+ caller = dest[0] # to test nanobts if the test come from RZ GSM but fehler
+ if caller[0:5] == 'GSMRZ' and int(dest[3]) != 2 and dest[1] != 'sip':
+ if int(dest[2]) == 486 or int(dest[2]) == 402:
+ callFrom = 'sip'
+ testDest(callFrom, dest[0], 2)
+ rem.append(dest)
+
+ # test to make sure nanoBTS working or not. sice probably that nanotbts seems error but actually not.
+ 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
+ From = gsmrzResult[0]
+ To = gsmrzResult[1]
+ result = gsmrzResult[2]
+ if int(gsmrzResult[2]) == 200:
+ repeat = False
+ if gsmrzResult[1] == RZ and int(gsmrzResult[2]) == 998:
+ try:
+ cpgsmRZList.remove(RZ)
+ except ValueError:
+ message = 'Error'
+ if gsmrzResult[0] == RZ and int(gsmrzResult[2]) == 999:
+ try:
+ cpgsmRZList.remove(RZ)
+ except ValueError:
+ message = 'Error'
+
+ if len(cpgsmRZList) > 1:
+ if repeat == True:
+ i = random.randint(0, len(cpgsmRZList)-1) #
+ if i == 0:
+ x = i+1
+ else:
+ x = i-1
+ testDest(cpgsmRZList[x], cpgsmRZList[i], 2)
+ item = '['+str(From)+','+str(callTo)+','+str(result)+','+str(1)+']'
+ rem.append(item)
+
+ for remov in rem:
+ for x in smartResultList:
+ if x == remov:
+ try:
+ smartResultList.remove(x)
+ except ValueError:
+ message = 'Error'
+ return smartResultList
+
+def doSmartTest(status):
+ global taskNum
+ global WebStatus
+ initDB()
+ taskNum = db.maxTaskNo()
+ global makeTest
+ if status == True:
+ WebStatus = True
+ else:
+ WebStatus = False
+ makeTest = initTestClass.initTesting()
+ result = smartTest()
+ initTrueTable(result)
+ if status == True:
+ sendFinishMessage()
+
def doSipTest():
#destList = ['gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm' ]
- destList = ['landline']
- doTest = initTestClass.doTest()
+ destList = ['landline', 'unisip']
+ doTest = initTestClass.initTesting()
for callTo in destList:
callFrom = 'sip'
doTest.initTest(callFrom,callTo)
resultsList.append([callFrom, callTo, doTest.result])
+ initTrueTable(resultsList)
+def doIncomingTest(): #incoming call to RZ network
-def doLandlineTest():
-
- destList = ['GSMRZ1','unisip', 'sip']
- doTest = initTestClass.doTest()
+ destList = ['GSMRZ1','unisip', 'GSMRZ2','GSMRZ3']
+ doTest = initTestClass.initTesting()
for callTo in destList:
-
callFrom = 'landline'
doTest.initTest(callFrom,callTo)
resultsList.append([callFrom, callTo, doTest.result])
@@ -122,10 +361,9 @@ def doGsmrzTest():
destList = ['GSMRZ1','GSMRZ2', 'GSMRZ3']
callList = ['sip']
- doTest = initTestClass.doTest()
+ doTest = initTestClass.initTesting()
for callFrom in callList:
-
for callTo in destList:
doTest.initTest(callFrom,callTo)
resultsList.append([callFrom, callTo, doTest.result])
@@ -136,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:
@@ -147,15 +385,122 @@ def doGsmExtTest():
def doAllTest():
doSipTest()
- doLandlineTest()
+ doIncomingTest()
doGsmrzTest()
doGsmExtTest()
-def regularTest():
- regulartest = initTestClass.doTest()
- regulartest.smartTest()
- initTrueTable(regulartest.smartResultList)
- #print regulartest.smartResultList
+
+def sendResultWebsite(message):
+ if server.sendData(message+ chr(10)) == 1:
+ print 'data sent successfully'
+ test = server.receiveData(5)
+ if test == 'TIMEOUT':
+ closeFunction(db,server)
+ sys.exit(2)
+ if test == 'CONTINUE':
+ print 'continue'
+
+def sendFinishMessage():
+ if server.connected == 1:
+ server.sendData('TEST DONE\n')
+ test = server.receiveData(5)
+ if test == 'TIMEOUT':
+ closeFunction(db,server)
+ if test == 'DISCONNECT':
+ close = server.closeConnection()
+ if close == 1:
+ print 'Closed connection successfully'
+
+ print 'release mutex says ', db.releaseMutex()
+
+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
+ db.closeDBConn()
+ sys.exit(1)
+ if calleeFound != True:
+ print 'No device with name', callee
+ db.closeDBConn()
+ sys.exit(1)
+ 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.initTesting()
+
+ for item in db.tasksList:
+
+ taskID = item[0]
+ taskNo = item[1]
+ callFrom = item[2]
+ callTo = item[3]
+
+ if i == 0:
+ db.updatePingResult(taskNo, sipServer, sipGate, unisip, gsmBox1, gsmBox2)
+ print '\n'
+ print 'Task ID :', taskID
+ print 'Calling From :', callFrom
+ print 'To :', callTo
+
+
+ makeTest.initTest(callFrom,callTo)
+
+ db.addResult(taskID, makeTest.result)
+
+ resultsList.append([callFrom, callTo, makeTest.result])
+
+ db.errorCode(makeTest.result)
+
+ if int(makeTest.result) == 200:
+ print bcolors.OKGREEN +'Result : ' +str(makeTest.result)+ ' ' +db.errCode + bcolors.ENDC
+ else:
+ print bcolors.FAIL+'Result : ' +str(makeTest.result)+ ' ' +db.errCode + bcolors.ENDC
+
+ if x == True: # if x = True means that this function call by website
+
+ message = '|' + str(callFrom) + '|' + str(callTo) + '|' + str(makeTest.result) + '|' + str(db.errCode)
+ sendResultWebsite(message) # send result to website
+
+ db.deleteTempTask(taskID)
+ i = i+1
+
+ db.cleanTasksList()
+
+ if x == True:
+ sendFinishMessage() #send finish message to website and close the connection
+
+ print '\n'
+
+ initTrueTable(resultsList) # fetch result list and make adjustment about the result
+ db.closeDBConn()
+ else:
+ print bcolors.FAIL+"--- No job at all ---" + bcolors.ENDC
+ db.closeDBConn()
+ else:
+ print bcolors.FAIL+'Cant connect to database'+ bcolors.ENDC
+ sys.exit(1)
def findPort(portName): # take information in existing usb port
global connect
@@ -178,7 +523,7 @@ def findPort(portName): # take information in existing usb port
else:
connect = 0
-def initDevice(deviceName): # Manual init device
+def initDevice(deviceName):
print 'Device Name :',deviceName
print ' Device IMEI : ',
imei = sys.stdin.readline().rstrip("\r\n")
@@ -187,48 +532,62 @@ def initDevice(deviceName): # Manual init device
print 'Port Name : /dev/',
portName = sys.stdin.readline().rstrip("\r\n")
print ''
-
+
if imei == '' or portName == '':
- print ' == cant save device configuration, please fill IMEI / port name of the device =='
+ print bcolors.FAIL+' == cant save device configuration, please fill IMEI / port name of the device =='+ bcolors.ENDC
else:
findPort(portName)
if connect == 1:
if str(IMEI) != str(imei) and str(num) != str(number):
- print '== error, device not found IMEI and Number doesnt match =='
+ print bcolors.FAIL+'== error, device not found =='+ bcolors.ENDC
elif str(IMEI) == str(imei):
- if number == '':
- print ' == cant save device configuration, number missing =='
- else:
- portClass.initUpdate(deviceName, portName, number) # update device database
- print '== Device succeced added, please re-check the number =='
+ portClass.initUpdate(deviceName, portName, number)
+ print bcolors.OKGREEN +'== Device succeced added =='+ bcolors.ENDC
elif str(num) == str(number) and str(IMEI) != str(imei):
- portClass.initUpdate(deviceName, portName, number) # update device database
- print '== Device succeced added, but have different IMEI =='
+ portClass.initUpdate(deviceName, portName, number)
+ print bcolors.WARNING+'== Device succeced added, but have different IMEI =='+ bcolors.ENDC
else:
- print '== error, no device connected =='
+ print bcolors.FAIL+'== error, no device connected =='+ bcolors.ENDC
-
-def autoUpdateDevice():
+def autoUpdateDevice(status):
+ initDB()
+ GSMListPrefix = list()
+ GSMListPrefix = db.GSMPrefix()
i = 0
x = 0
+ count = 0
while i !=10:
portName ='ttyUSB'+str(i) #checking usb connection
- findPort(portName)
+
i=i+1
- if connect == 1:
- for listNum in GSMListPrefix:
- if prefix == listNum[1]:
- print 'Device Name :',listNum[0]
- print 'IMEI :',IMEI
- print 'Phone Number :',num
- print 'Port Name : /dev/'+portName
- x=x+1
- newPortName = '/dev/'+portName
- portClass.initUpdate(listNum[0], newPortName, num)
- print '\n'
+ old_handler = signal.signal(signal.SIGALRM, timeout_handler)
+ signal.alarm(15)
+ try:
+ findPort(portName)
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ if connect == 1:
+ for listNum in GSMListPrefix:
+ if prefix == listNum[1]:
+ print 'Device Name :',listNum[0]
+ print 'IMEI :',IMEI
+ print 'Phone Number :',num
+ print 'Port Name : /dev/'+portName
+ x=x+1
+ newPortName = '/dev/'+portName
+ portClass.initUpdate(listNum[0], newPortName, num)
+ print '\n'
+ except TimeoutException:
+ signal.signal(signal.SIGALRM, old_handler)
+ signal.alarm(0)
+ count = count + 1
+ message = "Timeout"
+ if status == True:
+ sendFinishMessage()
+ else:
- print '== FINISH =='
- print 'Found '+str(x)+' devices'
+ print '== FINISH =='
+ print 'Found '+str(x)+' devices'
def updateDevice(): #update port name list of device on DB
quit = False
@@ -250,10 +609,10 @@ def updateDevice(): #update port name list of device on DB
print " 5. GSM RZ 1"
print " 6. Back to menu"
print ""
- print "your choice : ",
+ print "your choise : ",
input = sys.stdin.readline().rstrip("\r\n")
- if input == '8':
+ if input == '6':
break
elif input == '1':
initDevice('GSMExt.O2')
@@ -265,21 +624,27 @@ def updateDevice(): #update port name list of device on DB
initDevice('GSMExt.Tm')
elif input == '5':
initDevice('GSMRZ1')
- elif input == '6':
- break
else:
print 'please choose between 1-6'
if input == 'a': #automatic configuration
- autoUpdateDevice()
+ autoUpdateDevice(False)
if input == "q":
break
sys.exit()
+def closeFunction(dbConn,serverSocket):
+ print 'Release the mutex: ' + str(dbConn.releaseMutex())
+ print 'Close the DB Connection: ' + str(dbConn.closeDBConn())
+ del dbConn
+ del serverSocket
+ sys.exit()
+
if len(sys.argv) > 1:
command = sys.argv[1]
+
print ' '
if command == '--all':
@@ -298,71 +663,82 @@ if len(sys.argv) > 1:
resultsList = list()
doGsmExtTest()
- elif command == '--landline':
+ elif command == '--incoming':
resultsList = list()
- doLandlineTest()
+ doIncomingTest()
elif command == '--smart':
+ initDB()
resultsList = list()
- regularTest()
+ allPing()
+ taskNo = db.maxTaskNo()
+ db.updatePingResult(taskNo, sipServer, sipGate, unisip, gsmBox1, gsmBox2)
+ doSmartTest(False)
elif command == '--devconf':
updateDevice()
+ elif command == '--db':
+ 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."
+ else:
+ print "Error given caller and destination. Type '--help' for more information."
+ sys.exit()
+ resultsList = list()
+ withDB(False)
+
elif command == '--help':
file = open('help.txt', 'r')
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:
-
- initDB()
- resultsList = list()
- if dbStatus == 1:
+ global server
+ global tried
- if db.anyTasksToDo() == 1:
-
- #allPing()
- i=0
- makeTest = initTestClass.doTest()
- for item in db.tasksList:
-
- taskID = item[0]
- taskNo = item[1]
- callFrom = item[2]
- callTo = item[3]
-
- #if i == 0:
- #db.updatePingResult(taskNo, sipServer, sipGate, unisip, gsmBox1, gsmBox2)
- print '\n'
- print 'Task ID :', taskID
- print 'Calling From :', callFrom
- print 'To :', callTo
-
- makeTest.initTest(callFrom,callTo)
-
- db.addResult(taskID, makeTest.result)
+ initDB() # should put db condition
+ server = ServerClassSoftware.ServerHandlerSoftware(34500) #define the port
+ tried = server.openSocket(10)
- resultsList.append([callFrom, callTo, makeTest.result])
-
- db.errorCode(makeTest.result)
- print 'Result : ' +makeTest.result+ ' ' +db.errCode
-
- db.deleteTempTask(taskID)
- i = i+1
+ if tried == 'TIMEOUT':
+ closeFunction(db,server)
+
+ test = server.receiveData(10)
+ if test == 'TIMEOUT':
+ closeFunction(db,server)
+
+ if test == 'START TEST':
+ server.sendData('CONFIRM\n')
+ print 'TEST STARTED'
+ withDB(True)
+
+ if test == 'SMART TEST':
+ allPing()
+ taskNo = db.maxTaskNo()
+ db.updatePingResult(taskNo, sipServer, sipGate, unisip, gsmBox1, gsmBox2)
+ server.sendData('CONFIRM\n')
+ print 'SMART TEST STARTED'
+ resultsList = list()
+ doSmartTest(True)
+ #regularTest(True)
- db.cleanTasksList()
- print '\n'
-
- initTrueTable(resultsList) # fetch result list and make adjustment about the result
- else:
- print "--- No job at all ---"
+ if test == 'UPDATE DEVICE':
+ server.sendData('CONFIRM\n')
+ print 'UPDATE DEVICE STARTED'
+ autoUpdateDevice(True)
else:
- sys.exit(1)
+ sys.exit('WE DIDN\'T RECEIVE THE CONFIRMATION')
+
+ db.closeDBConn()
+