From 65c9b8b6b1a46b79b72e266e0036d4992ce62589 Mon Sep 17 00:00:00 2001 From: Triatmoko Date: Mon, 1 Aug 2011 14:41:47 +0200 Subject: add new file for agustus. this test include truetable to indicate which part is broken and also have test adjusment which onl test importan part in the network. --- For Weekly Test/19-08-2011/ClientClass.py | 123 ++++++++++ For Weekly Test/19-08-2011/ClientClass.pyc | Bin 0 -> 3601 bytes For Weekly Test/19-08-2011/ControllerClass.py | 233 ++++++++++++++++++ For Weekly Test/19-08-2011/ControllerClass.pyc | Bin 0 -> 6970 bytes For Weekly Test/19-08-2011/DbClass.py | 295 +++++++++++++++++++++++ For Weekly Test/19-08-2011/DbClass.pyc | Bin 0 -> 8119 bytes For Weekly Test/19-08-2011/GSMClass.py | 304 ++++++++++++++++++++++++ For Weekly Test/19-08-2011/GSMClass.pyc | Bin 0 -> 7176 bytes For Weekly Test/19-08-2011/GSMHandler.py | 286 ++++++++++++++++++++++ For Weekly Test/19-08-2011/Landline handler.log | 210 ++++++++++++++++ For Weekly Test/19-08-2011/LogFileClass.py | 21 ++ For Weekly Test/19-08-2011/LogFileClass.pyc | Bin 0 -> 1494 bytes For Weekly Test/19-08-2011/PingClass.py | 28 +++ For Weekly Test/19-08-2011/PingClass.pyc | Bin 0 -> 1251 bytes For Weekly Test/19-08-2011/SIP handler.log | 168 +++++++++++++ For Weekly Test/19-08-2011/SIPHandler.py | 229 ++++++++++++++++++ For Weekly Test/19-08-2011/ServerClass.py | 152 ++++++++++++ For Weekly Test/19-08-2011/ServerClass.pyc | Bin 0 -> 4563 bytes For Weekly Test/19-08-2011/TestProcessLog.log | 200 ++++++++++++++++ For Weekly Test/19-08-2011/TrueTable.py | 167 +++++++++++++ For Weekly Test/19-08-2011/TrueTable2.py | 172 ++++++++++++++ For Weekly Test/19-08-2011/gsmselftest.py | 293 +++++++++++++++++++++++ For Weekly Test/19-08-2011/help.txt | 11 + For Weekly Test/19-08-2011/true table.txt | 43 ++++ 24 files changed, 2935 insertions(+) create mode 100644 For Weekly Test/19-08-2011/ClientClass.py create mode 100644 For Weekly Test/19-08-2011/ClientClass.pyc create mode 100644 For Weekly Test/19-08-2011/ControllerClass.py create mode 100644 For Weekly Test/19-08-2011/ControllerClass.pyc create mode 100644 For Weekly Test/19-08-2011/DbClass.py create mode 100644 For Weekly Test/19-08-2011/DbClass.pyc create mode 100644 For Weekly Test/19-08-2011/GSMClass.py create mode 100644 For Weekly Test/19-08-2011/GSMClass.pyc create mode 100644 For Weekly Test/19-08-2011/GSMHandler.py create mode 100644 For Weekly Test/19-08-2011/Landline handler.log create mode 100644 For Weekly Test/19-08-2011/LogFileClass.py create mode 100644 For Weekly Test/19-08-2011/LogFileClass.pyc create mode 100644 For Weekly Test/19-08-2011/PingClass.py create mode 100644 For Weekly Test/19-08-2011/PingClass.pyc create mode 100644 For Weekly Test/19-08-2011/SIP handler.log create mode 100644 For Weekly Test/19-08-2011/SIPHandler.py create mode 100644 For Weekly Test/19-08-2011/ServerClass.py create mode 100644 For Weekly Test/19-08-2011/ServerClass.pyc create mode 100644 For Weekly Test/19-08-2011/TestProcessLog.log create mode 100644 For Weekly Test/19-08-2011/TrueTable.py create mode 100644 For Weekly Test/19-08-2011/TrueTable2.py create mode 100755 For Weekly Test/19-08-2011/gsmselftest.py create mode 100644 For Weekly Test/19-08-2011/help.txt create mode 100644 For Weekly Test/19-08-2011/true table.txt (limited to 'For Weekly Test/19-08-2011') diff --git a/For Weekly Test/19-08-2011/ClientClass.py b/For Weekly Test/19-08-2011/ClientClass.py new file mode 100644 index 0000000..46c3b00 --- /dev/null +++ b/For Weekly Test/19-08-2011/ClientClass.py @@ -0,0 +1,123 @@ +import socket +import sys +import os +import string +import signal + +class TimeoutException(Exception): + pass + +class Connection: + def __init__(self, h, p): + self.host = h + self.port = p + self.s = None + self.connected = 0 + + self.debugMode = 0 + + def connect(self): + self.s = None + + for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM): + af, socktype, proto, canonname, sa = res + try: + self.s = socket.socket(af, socktype, proto) + self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets + except socket.error, msg: + self.s = None + self.connected = 0 + continue + try: + self.s.connect(sa) + except socket.error, msg: + self.s.close() + self.connected = 0 + self.s = None + continue + break + if self.s is None: + self.connected = 0 + return 0 #couldn't connect to the server + else: + self.connected = 1 + return 1 #successfully connected to the server + + def sendData(self, data): + if self.connected == 1: + try: + self.s.send(data) + return 1 + except Exception, e: + if self.debugMode == 1: + import traceback + print traceback.format_exc() + print e + self.connected = 0 + return 2 + + else: + return 0 + + def receiveData(self, timeout): + if self.connected == 1: + + def timeout_handler(signum, frame): + raise TimeoutException() + + old_handler = signal.signal(signal.SIGALRM, timeout_handler) + signal.alarm(timeout) #start the timeout alarm, for timeout seconds + try: + data = self.s.recv(1024) + + #stop the timeout function + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + + return data + + + except TimeoutException: + #timeout happened + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'TIMEOUT' + + except Exception, e: + + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + + error = str(e) + if self.debugMode == 1: + import traceback + print traceback.format_exc() + print e + self.connected = 0 + if error[0:11] == '[Errno 104]': + return 3 #the other side reset the connection,[Errno 104] Connection reset by peer + + return 2 + else: + return 0 + + def closeConnection(self): + if self.connected == 1: + try: + self.connected = 0 + SHUT_RDWR = 2 + self.s.shutdown(SHUT_RDWR) + self.s.close() + return 1 + except Exception, e: + self.connected = 0 + error = str(e) + if self.debugMode == 1: + import traceback + print traceback.format_exc() + print e + if error[0:11] == '[Errno 107]': + return 3 #the other side closed the connection before us, [Errno 107] Transport endpoint is not connected + return 2 + else: + return 0 diff --git a/For Weekly Test/19-08-2011/ClientClass.pyc b/For Weekly Test/19-08-2011/ClientClass.pyc new file mode 100644 index 0000000..7cdfa60 Binary files /dev/null and b/For Weekly Test/19-08-2011/ClientClass.pyc differ diff --git a/For Weekly Test/19-08-2011/ControllerClass.py b/For Weekly Test/19-08-2011/ControllerClass.py new file mode 100644 index 0000000..9c6b74e --- /dev/null +++ b/For Weekly Test/19-08-2011/ControllerClass.py @@ -0,0 +1,233 @@ +import sys +import os +import subprocess + +import ClientClass + +import LogFileClass +logger = LogFileClass.Logging('TestProcessLog.log') + +from time import sleep + + +class test: + + def __init__(self, callFrom, callAdd, accCaller, callTo, recAdd, destNo, accDest): + + self.callFrom = callFrom + self.dest = callTo + self.destNo = destNo + self.accDest = accDest + self.accCaller = accCaller + self.repeatTest = None + self.portAdd = None + self.portCaller = None + self.portDest = None + self.resultCaller = None + self.resultDest = None + self.testResult = None + self.callAdd = callAdd + self.recAdd = recAdd + self.receiver = None + self.caller = None + self.connected = None + + + def FuncTest(self): + + logger.logEvent('') + + self.initCaller() + sleep(3) + + self.callerGreeting() + + if self.connected == 'OK': + + self.caller.sendData('CALLER|'+self.destNo) + callerHandler = self.caller.receiveData(15) + + if callerHandler == "CALLER READY": + logger.logEvent('Caller handler : Ready') + + self.initReceiver() + sleep(3) + self.receiverGreeting() + + if self.connected == 'OK': + + self.receiver.sendData('RECEIVER') + destHandler = self.receiver.receiveData(15) + + if destHandler == 'RECEIVER READY': + logger.logEvent('Receiver handler : Ready') + + self.startCall() + self.waitingFeedback() + + else: + self.testResult = 604 + logger.logEvent('604 General Handler Error: Destination handler no respond timeout') + self.caller.sendData('TERMINATE CONNECTION') + self.receiver.closeConnection() + + else: + logger.logEvent('998 General Handler Error: Could not connect Destination handler') + self.testResult = 998 + self.caller.sendData('TERMINATE CONNECTION') + self.caller.closeConnection() + else: + self.testResult = 605 + logger.logEvent('605 General Handler Error: caller handler no respond timeout') + + self.caller.closeConnection() + + else: + self.testResult = 999 + logger.logEvent('999 General Handler Error: Could not connect to Caller handler') + + + + def waitingFeedback(self): + logger.logEvent('Waiting Feedback') + self.resultCaller = self.caller.receiveData(30) + self.resultDest = self.receiver.receiveData(30) + + if self.resultCaller <> 'CALL OK' or self.resultDest <> 'CALL OK': + + logger.logEvent('Test Failed') + self.testResult = 486 + self.repeatTest = True + self.initTerminate() + + else: + logger.logEvent('Test Succeed') + self.testResult = 200 + self.initTerminate() + + + def startCall(self): + logger.logEvent('Start Call') + self.receiver.sendData('RECEIVE START') + self.caller.sendData('CALL START') + + + def initCaller(self): + logger.logEvent('init Caller') + logger.logEvent(self.callFrom) + + if self.callFrom =="gsmr1": + self.portCaller = 50007 + self.portAdd = '' + self.initGSM(self.portCaller, self.portAdd) + + elif self.callFrom =="gsmr2": + self.portCaller = 50008 + + elif self.callFrom =="gsmr3": + self.portCaller = 50009 + + elif self.callFrom =="gsmeO": + self.portCaller = 50010 + self.portAdd = '/dev/ttyUSB0' + self.initGSM(self.portCaller, self.portAdd) + + elif self.callFrom =="gsmeV": + self.portCaller = 50011 + self.portAdd = '/dev/ttyUSB1' + self.initGSM(self.portCaller, self.portAdd) + + elif self.callFrom =="gsmeT": + self.portCaller = 50012 + self.portAdd = '' + self.initGSM(self.portCaller, self.portAdd) + + elif self.callFrom =="gsmeE": + self.portCaller = 50013 + self.portAdd = '/dev/ttyUSB2' + self.initGSM(self.portCaller, self.portAdd) + + else: + self.portCaller = 50099 + subprocess.Popen(args=["gnome-terminal", '--command=python SIPHandler.py '+self.accCaller+ ' ' +str(self.portCaller)]) + + def initReceiver(self): + logger.logEvent('init Receiver') + logger.logEvent(self.dest) + + if self.dest =="gsmr1": + self.portDest = 50007 + self.portAdd = '' + self.initGSM(self.portDest, self.portAdd) + + elif self.dest =="gsmr2": + self.portDest = 50008 + + elif self.dest =="gsmr3": + self.portDest = 50009 + + elif self.dest =="gsmeO": + self.portDest = 50010 + self.portAdd = '/dev/ttyUSB0' + self.initGSM(self.portDest, self.portAdd) + + elif self.dest =="gsmeV": + self.portDest = 50011 + self.portAdd = '/dev/ttyUSB1' + self.initGSM(self.portDest, self.portAdd) + + elif self.dest =="gsmeT": + self.portDest = 50012 + self.portAdd = '' + self.initGSM(self.portDest, self.portAdd) + + elif self.dest =="gsmeE": + self.portDest = 50013 + self.portAdd = '/dev/ttyUSB2' + self.initGSM(self.portDest, self.portAdd) + + else: + self.portDest = 50100 + subprocess.Popen(args=['gnome-terminal', '--command=python SIPHandler.py '+self.accDest+ ' ' +str(self.portDest)]) + + def initTerminate(self): + self.caller.sendData('TERMINATE CONNECTION') + self.receiver.sendData('TERMINATE CONNECTION') + + def callerGreeting(self): + self.connected = None + self.caller = ClientClass.Connection(self.callAdd,self.portCaller) + self.caller.connect() + + if self.caller.connected == 1: + logger.logEvent('Connected to Caller Handler') + self.caller.sendData('HELLO HANDLER') + if self.caller.receiveData(15) == 'HELLO CONTROLLER': + logger.logEvent('Caller Handler respond') + self.connected = 'OK' + else: + logger.logEvent('Cannt connect to Caller') + self.connected = 'NOT OK' + + def receiverGreeting(self): + self.connected = None + self.receiver = ClientClass.Connection(self.recAdd, self.portDest) + self.receiver.connect() + + if self.receiver.connected == 1: + logger.logEvent('Connected to Receiver Handler') + self.receiver.sendData('HELLO HANDLER') + if self.receiver.receiveData(15) == 'HELLO CONTROLLER': + logger.logEvent('Receiver Handler respond') + self.connected = 'OK' + else: + logger.logEvent('Cannt connect to Receiver') + self.connected = 'NOT OK' + + def initGSM(self, portCommunication, portDevice): + + subprocess.Popen(args=["gnome-terminal", '--command=python GSMHandler.py '+str(portCommunication)+ ' ' +str(portDevice)]) + + + + diff --git a/For Weekly Test/19-08-2011/ControllerClass.pyc b/For Weekly Test/19-08-2011/ControllerClass.pyc new file mode 100644 index 0000000..3efebe9 Binary files /dev/null and b/For Weekly Test/19-08-2011/ControllerClass.pyc differ diff --git a/For Weekly Test/19-08-2011/DbClass.py b/For Weekly Test/19-08-2011/DbClass.py new file mode 100644 index 0000000..e5ef961 --- /dev/null +++ b/For Weekly Test/19-08-2011/DbClass.py @@ -0,0 +1,295 @@ +import MySQLdb +import string + +class DBMySQLConnection: + def __init__(self, username, password, host, dbname): + #initialize at the start all the user parameters + self.usern = username + self.passw = password + self.host = host + self.db = dbname + self.connectionCreated = 0 + self.tasksList = list() + self.errCode = None + global debugMode + debugMode = 0 + + def connectDB(self): + try: + #try the connection + self.datBaseConn=MySQLdb.connect(self.host,self.usern, self.passw,self.db) + self.datBaseConn.paramstyle = 'format' + self.cur = self.datBaseConn.cursor() #make the cursor, used for sending queries + self.connectionCreated = 1 #use it as an indicator that the connection was created + return 1 + + except MySQLdb.Error, e: + #if we have an error then try to catch it + error=str(e) + if error[1:5] == '1045': + #wrong username or password + return 0 + elif error[1:5] == '2002': + #can't connect to mysql, mysql shutdown or wrong host + return 2 + else: + if debugMode == 1: + print error + return 3 + + def closeDBConn(self): + #close the connection to the database here + if self.connectionCreated == 1: + try: + #close the cursor and then the connection to the DB + self.cur.close() + self.datBaseConn.close() + return 1 + except MySQLdb.Error, e: + #in case of an error + if debugMode == 1: + error = str(e) + print error + return 3 + else: + #I never really had a connection + return 0 + + def anyTasksToDo(self): + #see are there any jobs to be executed and make a list out of it + if self.connectionCreated == 1: + try: + self.cur.execute("SELECT * FROM TempTaskTable") + output = self.cur.fetchall() #get the mysql response + #parse the output from the mysql by creating a list + #with lists where each attribue(column) gets independent + #element of the list + + for record in output: + columns = list() + for entry in record: + columns.append(str(entry)) + #columns.append(str(0)) + self.tasksList.append(columns) + return 1 + except MySQLdb.Error, e: + error = str(e) + if error[1:5] == '1146': + return 2 #the table doesn't exist + if debugMode == 1: + print str(e) + return 3 + else: + return 0 + + def cleanTasksList(self): + if self.connectionCreated == 1: + del self.tasksList[:] + return 1 + else: + return 0 + + def removeTaskFromList(self, taskID): + #remove only one task from the task list + if self.connectionCreated == 1: + for index in range(len(self.tasksList)): + item = self.tasksList[index] + if item[0] == str(taskID): + #self.tasksList.remove(index) + #print 'found it' + del self.tasksList[index] + return 1 #deleted taskID + + return 2 #didn't find that taskID + else: + return 0 + + def deviceAddress(self,deviceName): + if self.connectionCreated == 1: + try: + successful = self.cur.execute("SELECT `deviceIP`,`number`, `username`, `password`, `server` FROM DeviceAddressTable where `deviceName`=%s", deviceName) + output = self.cur.fetchall() #get the mysql response + #parse the output from the mysql by creating a list + #with lists where each attribue(column) gets independent + #element of the list + + deviceAddr = '' + for record in output: + columns = list() + for entry in record: + columns.append(str(entry)) + deviceAddr = columns + + return deviceAddr + except MySQLdb.Error, e: + error = str(e) + if error[1:5] == '1146': + return 2 #the table doesn't exist + if debugMode == 1: + print str(e) + return 3 #some error happened + else: + return 0 #I am not connected + + def updateTaskResult(self, taskID, status): + if self.connectionCreated == 1: + try: + successful = self.cur.execute("UPDATE TaskTable SET status=%i WHERE taskID=%i"%(int(status), int(taskID))) + output = self.cur.fetchone() + + if debugMode == 1: + print output + if successful == 0: + return 1 #update successful + else: + return 4 #taskID doesn't exist + + except MySQLdb.Error, e: + if debugMode == 1: + print str(e) + return 3 + else: + return 0 + + def updatePingResult(self, taskNo, sipServer, sipGate, sipLoc, gsmBox1, gsmBox2): + if self.connectionCreated == 1: + try: + successful = self.cur.execute("UPDATE PingResultTable SET sipServer=%i, sipGate=%i, sipLoc=%i, gsmBox1=%i, gsmBox2=%i WHERE taskNo=%i"%(int(sipServer), int(sipGate), int(sipLoc), int(gsmBox1), int(gsmBox2), int(taskNo))) + output = self.cur.fetchone() + + if debugMode == 1: + print output + if successful == 0: + return 1 #ping table updated + else: + return 4 #the taskNo didn't exist + + + except MySQLdb.Error, e: + if debugMode == 1: + print str(e) + return 3 + else: + return 0 + + def deleteTempTask(self, taskID): + if self.connectionCreated == 1: + try: + successful = self.cur.execute("DELETE FROM TempTaskTable WHERE taskID=%i"%(int(taskID))) + output = self.cur.fetchone() + + if debugMode == 1: + print output + + if successful == 1: + return 1 #deleted it + else: + return 4 #that taskID didn't exist or something else + except MySQLdb.Error, e: + if debugMode == 1: + print str(e) + return 3 + + else: + return 0 + + def addResult(self, taskID, result): + if self.connectionCreated == 1: + try: + successful = self.cur.execute("INSERT INTO ResultTable(taskID, result) VALUES ('%i', '%i')"%(int(taskID), int(result))) + output = self.cur.fetchone() + + if debugMode == 1: + print output + if successful == 1: + return 1 #successfully added the result + else: + return 4 #hmmm + 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) + return 3 + else: + return 0 + + + def insertTaskIn2(self, fromDevice, toDevice, taskNo, status): + if self.connectionCreated == 1: + try: + #I used here a transaction since I want the mysql to execute a few commands and tell me was it successful rather than to execute some and there happens a mistake and one part is updated and the other isn't + newQuery = "START TRANSACTION; INSERT INTO `TaskTable` (`taskNo`, `from`, `to`, `status`) VALUES ('" + str(taskNo) + "', '" + str(fromDevice) + "', '" + str(toDevice) +"', '0'); SELECT @taskID := LAST_INSERT_ID(); INSERT INTO `TempTaskTable` (`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES (@taskID, '" + str(taskNo) + "', '" + str(fromDevice) + "', '"+ str(toDevice) + "', '"+ str(status) + "'); COMMIT;" + + + successful = self.cur.execute(newQuery) + output = self.cur.fetchone() + + + #without closing the cursos we get a MySQL error, the mistake is an internal mistak of the MySQLdb python library + # self.cur.close() + # self.cur = self.datBaseConn.cursor() + + while self.cur.nextset() is not None: pass + + newQuery1 = 'SELECT taskID FROM `TempTaskTable` ORDER BY taskID DESC LIMIT 1'; + successful1 = self.cur.execute(newQuery1) + record = self.cur.fetchone() + + columns = list() + for entry in record: + columns.append(str(entry)) + + columns.append(str(taskNo)) + columns.append(str(fromDevice)) + columns.append(str(toDevice)) + columns.append(str(status)) + #columns.append(str(0)) + self.tasksList.append(columns) + + return 1 + + if debugMode == 1: + print output + + except MySQLdb.Error, e: + error = str(e) + if debugMode == 1: + print str(e) + if error[1:5] == '1062': + return 2 #duplicate entry for the key + return 3 + else: + return 0 + + + def searchTaskList(self, fromDevice, toDevice): + if self.connectionCreated == 1: + for item in self.tasksList: + if item != '': + 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 + + def errorCode(self,code): + if self.connectionCreated == 1: + try: + successful = self.cur.execute("SELECT description FROM ErrorCodeTable where `errorcode`=%s", code) + data = self.cur.fetchone() + self.errCode = data[0] + return self.errCode + + except MySQLdb.Error, e: + error = str(e) + if error[1:5] == '1146': + return 2 #the table doesn't exist + if debugMode == 1: + print str(e) + return 3 #some error happened + else: + return 0 #I am not connected diff --git a/For Weekly Test/19-08-2011/DbClass.pyc b/For Weekly Test/19-08-2011/DbClass.pyc new file mode 100644 index 0000000..bb6a774 Binary files /dev/null and b/For Weekly Test/19-08-2011/DbClass.pyc differ diff --git a/For Weekly Test/19-08-2011/GSMClass.py b/For Weekly Test/19-08-2011/GSMClass.py new file mode 100644 index 0000000..e994814 --- /dev/null +++ b/For Weekly Test/19-08-2011/GSMClass.py @@ -0,0 +1,304 @@ +from serial import * #serial port library +import string +import sys +import signal + +class TimeoutException(Exception): + pass + +class serialPort(): + + def __init__(self, portAddress, baudRate, timeout): + self.portAddress = portAddress + self.portExist = 0 + self.ser = 0 + self.baudRate = baudRate + self.signalStrength = 0 + #self.callerConnected = -1 + self.timer = timeout + + self.debugMode = 0 + + def portInit(self): + portName = self.portAddress[-4:] + portExist = os.popen('dmesg | grep ' + portName).read() + + if portExist == '': + return 0 + else: + try: + self.ser = Serial( + port=self.portAddress, + baudrate=self.baudRate, + bytesize=EIGHTBITS, + parity=PARITY_NONE, + stopbits=STOPBITS_ONE + #timeout=0, + #writeTimeout=0 + #xonxoff=0, + #rtscts=0 + #interCharTimeout=None + #I didn't need to set these variables :) + ) + + self.ser.flushInput() #clean the input buffer for serial port + self.ser.write('AT\r') + + received = self.__receiveData() + + if received == 'OK': + self.portExist = 1 + return 1 #cellphone is OK, receives commands + elif received == 'TIMEOUT': + return 'TIMEOUT' + else: + return 2 #cellphone has an error + + except Exception, e: + import traceback + if self.debugMode == 1: + print e + print traceback.format_exc() + + self.portExist = 3 + return 3 + + def callNumber(self,numberToCall): + if self.portExist == 1: + try: + self.ser.flushInput() #clean the input buffer for serial port + self.ser.write('ATD'+str(numberToCall)+';\r') + if self.__receiveData() == 'OK': + return 1 + else: + return 4 + + except Exception, e: + import traceback + if self.debugMode == 1: + print e + print traceback.format_exc() + + return 3 + else: + return 0 + + + def hangUp(self): + if self.portExist == 1: + try: + self.ser.flushInput() #clean the input buffer for serial port + self.ser.write('AT+CHUP\r') + received = self.__receiveData() + if received == 'OK': + return 1 + elif received == 'ERROR': + return 2 #other side hang up the call + else: + return 4 + except Exception, e: + import traceback + if self.debugMode == 1: + print e + print traceback.format_exc() + return 3 + else: + return 0 + + + def closePort(self): + if self.portExist == 1: + try: + self.ser.flushInput() #clean the input buffer for serial port + self.ser.close() + return 1 + except Exception, e: + import traceback + if self.debugMode == 1: + print e + print traceback.format_exc() + return 3 + else: + return 0 + + def getSignalQuality(self): + if self.portExist == 1: + try: + self.ser.flushInput() #clean the input buffer for serial port + self.ser.write('AT+CSQ\r') + if self.__receiveData() == 'OK': + if self.__receiveData == 'SIGNAL': + return 1 + else: + return 4 + else: + return 2 + except Exception, e: + import traceback + if self.debugMode == 1: + print e + print traceback.format_exc() + return 3 + + else: + return 0 + + def receiveCall(self): + if self.portExist == 1: + try: + self.ser.flushInput() #clean the input buffer for serial port + if self.__receiveData() == 'RING': + self.ser.write('ATA\r') + if self.__receiveData()=='OK': + return 1 + else: + return 4 + else: + return 2 + + except Exception, e: + import traceback + if self.debugMode == 1: + print e + print traceback.format_exc() + return 3 + else: + return 0 + + def currentCall(self): + if self.portExist == 1: + try: + self.ser.flushInput() #clean the input buffer for serial port + self.ser.write('AT+CLCC\r') + received = self.__receiveData() + if received == 'OK': + return 2 #not yet in a call + elif received == 'ACTIVE': + return 1 #in a call + elif received == 'HELD': + return 5 #held call + elif received == 'DIALING': + return 6 #dialing + elif received == 'ALERTING': + return 7 #alerting the call + elif received == 'INCOMING': + return 8 #incoming call + elif received == 'WAITING': + return 9 #waiting for a call + + else: + return received #in some other state + except Exception, e: + import traceback + if self.debugMode == 1: + print e + print traceback.format_exc() + return 3 + else: + return 0 + + def __receiveData(self): + def timeout_handler(signum, frame): + raise TimeoutException() + + old_handler = signal.signal(signal.SIGALRM, timeout_handler) + signal.alarm(self.timer) + + bufferData = '' + lines = '' + line = '' + + try: + while True: + bufferData = bufferData + self.ser.read(self.ser.inWaiting()) #read the serial port and add it to the buffer variable + if '\n' in bufferData: #if a new line character is found in the buffer then the cellphone has sent something + lines = bufferData.split('\n') #parse the buffer variable with the new line character + last_received = lines.pop(0) #put into last_received variable the first content from lines (FIFO) + + bufferData = '\n'.join(lines) #add a new line to the buffer variable + + last_received=last_received.split('\n') #parse the last received value with new lines + line = last_received[0].replace(chr(13), '') #remove \r from the first parsed value in last_received and return me a nicely parsed value :) + if self.debugMode == 1: + if len(line) > 0: + print line + + if line == 'OK': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'OK' + + elif line == 'ERROR': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'ERROR' + + elif line[0:11] == '+CME ERROR:': + if self.debugMode == 1: + print 'ERROR:', line + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'ERROR' + + elif line == 'RING': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'RING' + + elif line[0:5] == '+CSQ:': #+CSQ: + space = int(string.find(line,' '))+1 #find the (space) sign + coma = int(string.find(line,',')) #find the , (coma) sign + self.signalStrength = (int(line[space:coma])*2)-113 + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'SIGNAL' + + elif line == 'NO CARRIER': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'NO CARRIER' + + elif line == 'BUSY': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'BUSY' + + elif line[0:6] == '+CLCC:': + #+CLCC: 1,0, + #self.ser.flushInput() + if line[11:12] == '0': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'ACTIVE' + elif line[11:12] == '1': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'HELD' + elif line[11:12] == '2': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'DIALING' + elif line[11:12] == '3': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'ALERTING' + elif line[11:12] == '4': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'INCOMING' + elif line[11:12] == '5': + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'WAITING' + + except TimeoutException: + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'TIMEOUT' + + except Exception, e: + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + print 'NO GOOD' + print e + return 3 diff --git a/For Weekly Test/19-08-2011/GSMClass.pyc b/For Weekly Test/19-08-2011/GSMClass.pyc new file mode 100644 index 0000000..93ccd6c Binary files /dev/null and b/For Weekly Test/19-08-2011/GSMClass.pyc differ diff --git a/For Weekly Test/19-08-2011/GSMHandler.py b/For Weekly Test/19-08-2011/GSMHandler.py new file mode 100644 index 0000000..a5b61c3 --- /dev/null +++ b/For Weekly Test/19-08-2011/GSMHandler.py @@ -0,0 +1,286 @@ +import ServerClass +import GSMClass +import LogFileClass +from time import sleep +import sys + +global portListen +global portAddress + + +if len(sys.argv) <> 3: + print "Error given command" + sys.exit(2) + + +portListen = int(sys.argv[1]) +portAddress = sys.argv[2] + +def initLogfile(): + global nameOfLogFile + + if portListen == 50007: + nameOfLogFile = 'GSM RZ1 handler.log' + + elif portListen == 50010: + nameOfLogFile = 'GSM O2 handler.log' + + elif portListen == 50011: + nameOfLogFile = 'GSM Vodaphone handler.log' + + elif portListen == 50012: + nameOfLogFile = 'GSM TMobile handler.log' + + elif portListen == 50013: + nameOfLogFile = 'GSM EPlus handler.log' + else: + print "No port listening found" + + +baudRate = 19200 + +initLogfile() +logger = LogFileClass.Logging(nameOfLogFile) + +errorCount = 0 + +logger.logEvent('') + +whileCounter =0 + +#define global varibales +global lastState +global resetState +lastState = 0 +resetState = 0 + + +def initSystem(): + print 'init system' + + global handlerSocket + global gsmDevice + global initTalkVar + global lastState + + global numberToCall + global resetState + + initTalkVar = 0 #variable used to know if we initialized the start talk + lastState = 0 #variable used to know + numberToCall = '000' #number to call + resetState = 0 + + handlerSocket = ServerClass.ServerHandler(portListen) + logger.logEvent('LISTEN ON PORT: '+str(portListen)) + + #add this if you need it + gsmDevice = GSMClass.serialPort(portAddress, baudRate, 45) + + initDevice = gsmDevice.portInit() + ######################################################## + + #add nice formating to the log file :) + anyConnection = handlerSocket.openSocket() + + + if anyConnection == 1 and initDevice == 1: + logger.logEvent('CONNECTION ESTABLISHED AND DEVICE WORKING: ' + str(handlerSocket.connectedTo())) + return 1 + + elif anyConnection == 1 and initDevice == 0: + logger.logEvent('$connection established but device not working: ' + str(handlerSocket.connectedTo())) + terminateConnection() + return 2 + else: + logger.logEvent('$no connection') + sys.exit(1) + return 0 + +def receiveMessage(timeout): + + message = str(handlerSocket.receiveData(timeout)) + + if message != '0' and message !='NO DATA': + print 'in receive message', message, lastState + + if message == 'HELLO HANDLER' and lastState == 0: + outcome = initTalk() + if outcome == 1: + logger.logEvent('TALK INITIALIZATION SENT') + else: + logger.logEvent('$talk initialization not sent: ' + str(outcome)) + + elif message == 'RECEIVER' and lastState == 1: + outcome = initReceiver() + if outcome == 1: + logger.logEvent('RECEIVER READY SENT') + else: + logger.logEvent('$receiver ready not sent: ' + str(outcome)) + + elif message == 'RECEIVE START' and lastState == 2: + outcome = receiveStart() + if outcome == 1: + logger.logEvent('RECEIVE STATUS REPORTED') + else: + logger.logEvent('$receive status not reported: ' + str(outcome)) + + elif message[0:6] == 'CALLER' and lastState == 1: + outcome = initCaller() + + global numberToCall + numberToCall = message[7:] + if outcome == 1: + logger.logEvent('CALLER READY SENT') + else: + logger.logEvent('$caller ready not sent: ' + str(outcome)) + + elif message == 'CALL START' and lastState == 4: + outcome = callStart(numberToCall) + if outcome == 1: + logger.logEvent('CALLER STATUS SENT') + else: + logger.logEvent('$caller status not sent: ' + str(outcome)) + + elif message == 'TERMINATE CONNECTION' and (lastState == 5 or lastState == 3): + outcome = terminateConnection() + if outcome == 1: + logger.logEvent('TERMINATED THE CONNECTION AFTER TEST') + else: + logger.logEvent('$connection could not be terminated after the test: ' + str(outcome)) + + elif message == 'TERMINATE CONNECTION': + outcome = terminateConnection() + if outcome == 1: + logger.logEvent('TERMINATED THE CONNECTION IN MIDDLE. IN STATE: ' + str(lastState) ) + else: + logger.logEvent('$connection could not be terminated in middle: ' + str(outcome) + ' in state: ' + str(lastState)) + else: + outcome = other() + logger.logEvent('other appeared') + terminateConnection() + + + return 1 + #return 0 + +########INIT TALK PART######## +def initTalk(): + print 'init talk' + + #initialize the talk between handler and controller + global lastState + lastState = 1 + sendMessage = handlerSocket.sendData('HELLO CONTROLLER') + return sendMessage +############################## + + +########RECEIVE PART######## +def initReceiver(): + print 'initReceiver' + + #init function to initialize the receiver + global lastState + lastState = 2 + sendMessage = handlerSocket.sendData('RECEIVER READY') + return sendMessage + +def receiveStart(): + print 'receiveStart' + + #wait for a call and report if you received it and it was successfull or not + global lastState + lastState = 3 + receiveCall = gsmDevice.receiveCall() + + if receiveCall == 1: + callSuccess = 'CALL OK' + else: + callSuccess = 'CALL NOT OK' + + tryHangUp = gsmDevice.hangUp() + + sendMessage = handlerSocket.sendData(callSuccess) + return sendMessage +############################ + + +########CALL PART######## +def initCaller(): + print 'initCaller' + + #initialize caller here + global lastState + lastState = 4 + sendMessage = handlerSocket.sendData('CALLER READY') + return sendMessage + +def callStart(numberToCall): + print 'initCaller' + + #call the number here + global lastState + lastState = 5 + + callSuccess = 'CALL NOT OK' + + tryCall = gsmDevice.callNumber(numberToCall) + if tryCall != 1: + callSuccess = 'CALL NOT OK' + else: + sleep(2) + activeCall = gsmDevice.currentCall() + counter = 0 + while(activeCall!=1): + sleep(1) + activeCall = gsmDevice.currentCall() + if counter == 6: + break + counter += 1 + + if activeCall == 1: + callSuccess = 'CALL OK' + else: + callSuccess = 'CALL NOT OK' + + tryHangUp = gsmDevice.hangUp() + + return handlerSocket.sendData(callSuccess) +######################### + + +########TERMINATE PART######## +def terminateConnection(): + print 'terminate connection' + global resetState + close = handlerSocket.closeConnection() + resetState = 1 + sys.exit(0.5) + return close +############################## + +########TERMINATE PART######## +def other(): + print 'other' + global lastState + global resetState + + close = handlerSocket.closeConnection() + lastState = 8 + resetState = 1 + return 1 +############################## + + + +while 1: + test = initSystem() + if test == 1: + print 'initialized system' + receivedMessage = 0 + while receivedMessage < 4 and resetState!= 1: + receivedMessage += receiveMessage(10) + + del handlerSocket + del gsmDevice diff --git a/For Weekly Test/19-08-2011/Landline handler.log b/For Weekly Test/19-08-2011/Landline handler.log new file mode 100644 index 0000000..08456fb --- /dev/null +++ b/For Weekly Test/19-08-2011/Landline handler.log @@ -0,0 +1,210 @@ + + +------------------STARTED THE LOGGING 2011-07-29 23:26:27.189491 ------------------ +On: 2011-07-29 23:26:27.197636 Event: try to Connect to Controller + + +------------------STARTED THE LOGGING 2011-07-29 23:29:02.577881 ------------------ +On: 2011-07-29 23:29:02.588058 Event: try to Connect to Controller +On: 2011-07-29 23:29:50.425808 Event: init state +On: 2011-07-29 23:29:50.426527 Event: Register Account to SIP server + + +------------------STARTED THE LOGGING 2011-07-29 23:31:11.685264 ------------------ +On: 2011-07-29 23:31:11.693752 Event: try to Connect to Controller +On: 2011-07-29 23:31:50.356785 Event: init state +On: 2011-07-29 23:31:50.357509 Event: Register Account to SIP server + + +------------------STARTED THE LOGGING 2011-07-29 23:32:30.935401 ------------------ +On: 2011-07-29 23:32:30.944002 Event: try to Connect to Controller + + +------------------STARTED THE LOGGING 2011-07-29 23:38:34.265205 ------------------ +On: 2011-07-29 23:38:34.272929 Event: init state + + +------------------STARTED THE LOGGING 2011-07-29 23:39:05.071215 ------------------ + + +------------------STARTED THE LOGGING 2011-07-29 23:39:35.502775 ------------------ +On: 2011-07-29 23:39:35.512507 Event: Register Account to SIP server + + +------------------STARTED THE LOGGING 2011-07-29 23:41:23.875335 ------------------ +On: 2011-07-29 23:41:23.884532 Event: Register Account to SIP server + + +------------------STARTED THE LOGGING 2011-07-29 23:42:13.341609 ------------------ +On: 2011-07-29 23:42:13.350064 Event: try to Connect to Controller +On: 2011-07-29 23:42:16.203271 Event: init state +On: 2011-07-29 23:42:16.203385 Event: Register Account to SIP server +On: 2011-07-29 23:42:16.236148 Event: 100 +On: 2011-07-29 23:42:16.237396 Event: Receiver Handler Ready +On: 2011-07-29 23:42:16.237455 Event: RECEIVE START +On: 2011-07-29 23:42:24.127645 Event: {Call "anonymous" } +On: 2011-07-29 23:42:24.628790 Event: Call Connecting +On: 2011-07-29 23:42:24.628835 Event: 200 +On: 2011-07-29 23:42:24.628978 Event: Answer call +On: 2011-07-29 23:42:25.129584 Event: Hangup call +On: 2011-07-29 23:42:25.129810 Event: CALL OK +On: 2011-07-29 23:42:25.283094 Event: Call Disconnected +On: 2011-07-29 23:42:25.393821 Event: Terminate +On: 2011-07-29 23:42:25.393846 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-29 23:43:09.728877 ------------------ +On: 2011-07-29 23:43:09.736885 Event: try to Connect to Controller +On: 2011-07-29 23:43:12.619960 Event: init state +On: 2011-07-29 23:43:12.620108 Event: Register Account to SIP server +On: 2011-07-29 23:43:12.667817 Event: 100 +On: 2011-07-29 23:43:12.669071 Event: Receiver Handler Ready +On: 2011-07-29 23:43:12.669134 Event: RECEIVE START +On: 2011-07-29 23:43:22.045718 Event: {Call "anonymous" } +On: 2011-07-29 23:43:22.546823 Event: Call Connecting +On: 2011-07-29 23:43:22.546868 Event: 200 +On: 2011-07-29 23:43:22.547008 Event: Answer call +On: 2011-07-29 23:43:23.047637 Event: Hangup call +On: 2011-07-29 23:43:23.047873 Event: CALL OK +On: 2011-07-29 23:43:23.101125 Event: Terminate +On: 2011-07-29 23:43:23.101164 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:10:42.822564 ------------------ +On: 2011-07-30 00:10:42.830586 Event: try to Connect to Controller +On: 2011-07-30 00:10:45.703646 Event: init state +On: 2011-07-30 00:10:45.703811 Event: Register Account to SIP server +On: 2011-07-30 00:10:45.737799 Event: 100 +On: 2011-07-30 00:10:45.737884 Event: Receiver Handler Ready +On: 2011-07-30 00:10:45.738026 Event: RECEIVE START +On: 2011-07-30 00:10:55.229448 Event: {Call "anonymous" } +On: 2011-07-30 00:10:55.730592 Event: Call Connecting +On: 2011-07-30 00:10:55.730637 Event: 200 +On: 2011-07-30 00:10:55.730779 Event: Answer call +On: 2011-07-30 00:10:56.231365 Event: Hangup call +On: 2011-07-30 00:10:56.231546 Event: CALL OK +On: 2011-07-30 00:10:56.333503 Event: Call Disconnected +On: 2011-07-30 00:10:56.339227 Event: Terminate +On: 2011-07-30 00:10:56.339270 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:11:35.034475 ------------------ +On: 2011-07-30 00:11:35.042598 Event: try to Connect to Controller +On: 2011-07-30 00:11:37.902099 Event: init state +On: 2011-07-30 00:11:37.902275 Event: Register Account to SIP server +On: 2011-07-30 00:11:37.935993 Event: 100 +On: 2011-07-30 00:11:37.936061 Event: Receiver Handler Ready +On: 2011-07-30 00:11:37.937281 Event: RECEIVE START +On: 2011-07-30 00:12:19.237484 Event: {Call "anonymous" } +On: 2011-07-30 00:12:19.738583 Event: Call Connecting +On: 2011-07-30 00:12:19.738627 Event: 200 +On: 2011-07-30 00:12:19.738772 Event: Answer call +On: 2011-07-30 00:12:19.739148 Event: Terminate +On: 2011-07-30 00:12:19.739188 Event: Goodbye +On: 2011-07-30 00:12:20.239411 Event: Hangup call +On: 2011-07-30 00:12:20.239637 Event: CALL OK + + +------------------STARTED THE LOGGING 2011-07-30 00:26:57.303984 ------------------ +On: 2011-07-30 00:26:57.313040 Event: try to Connect to Controller +On: 2011-07-30 00:27:00.184213 Event: init state +On: 2011-07-30 00:27:00.184461 Event: Register Account to SIP server +On: 2011-07-30 00:27:00.218449 Event: 100 +On: 2011-07-30 00:27:00.218498 Event: Receiver Handler Ready +On: 2011-07-30 00:27:00.218650 Event: RECEIVE START +On: 2011-07-30 00:27:08.332497 Event: {Call "anonymous" } +On: 2011-07-30 00:27:08.833577 Event: Call Connecting +On: 2011-07-30 00:27:08.833612 Event: 200 +On: 2011-07-30 00:27:08.833737 Event: Answer call +On: 2011-07-30 00:27:09.334016 Event: Hangup call +On: 2011-07-30 00:27:09.334160 Event: CALL OK +On: 2011-07-30 00:27:09.487264 Event: Call Disconnected +On: 2011-07-30 00:27:09.642374 Event: Terminate +On: 2011-07-30 00:27:09.642418 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:28:01.427077 ------------------ +On: 2011-07-30 00:28:01.436400 Event: try to Connect to Controller +On: 2011-07-30 00:28:04.292014 Event: init state +On: 2011-07-30 00:28:04.292217 Event: Register Account to SIP server +On: 2011-07-30 00:28:04.324649 Event: 100 +On: 2011-07-30 00:28:04.325843 Event: Receiver Handler Ready +On: 2011-07-30 00:28:04.325903 Event: RECEIVE START +On: 2011-07-30 00:28:13.702346 Event: {Call "anonymous" } +On: 2011-07-30 00:28:14.203385 Event: Call Connecting +On: 2011-07-30 00:28:14.203417 Event: 200 +On: 2011-07-30 00:28:14.203537 Event: Answer call +On: 2011-07-30 00:28:14.704140 Event: Hangup call +On: 2011-07-30 00:28:14.704328 Event: CALL OK +On: 2011-07-30 00:28:14.857462 Event: Call Disconnected +On: 2011-07-30 00:28:15.222953 Event: Terminate +On: 2011-07-30 00:28:15.222995 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:29:48.744168 ------------------ +On: 2011-07-30 00:29:48.752266 Event: try to Connect to Controller +On: 2011-07-30 00:29:51.616628 Event: init state +On: 2011-07-30 00:29:51.616869 Event: Register Account to SIP server +On: 2011-07-30 00:29:51.652901 Event: 100 +On: 2011-07-30 00:29:51.654175 Event: Receiver Handler Ready +On: 2011-07-30 00:29:51.654238 Event: RECEIVE START +On: 2011-07-30 00:29:59.645670 Event: {Call "anonymous" } +On: 2011-07-30 00:30:00.146572 Event: Call Connecting +On: 2011-07-30 00:30:00.146595 Event: 200 +On: 2011-07-30 00:30:00.146639 Event: Answer call +On: 2011-07-30 00:30:01.000360 Event: Terminate +On: 2011-07-30 00:30:01.000409 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:30:56.623124 ------------------ +On: 2011-07-30 00:30:56.633526 Event: try to Connect to Controller +On: 2011-07-30 00:30:59.467030 Event: init state +On: 2011-07-30 00:30:59.467207 Event: Register Account to SIP server +On: 2011-07-30 00:30:59.514683 Event: 100 +On: 2011-07-30 00:30:59.515924 Event: Receiver Handler Ready +On: 2011-07-30 00:30:59.515989 Event: RECEIVE START +On: 2011-07-30 00:31:07.302992 Event: {Call "anonymous" } +On: 2011-07-30 00:31:07.303394 Event: Call Connecting +On: 2011-07-30 00:31:07.303420 Event: 200 +On: 2011-07-30 00:31:07.303559 Event: Answer call +On: 2011-07-30 00:31:07.303592 Event: Hangup call +On: 2011-07-30 00:31:07.303717 Event: CALL OK +On: 2011-07-30 00:31:07.456866 Event: Call Disconnected +On: 2011-07-30 00:31:08.091116 Event: Terminate +On: 2011-07-30 00:31:08.091163 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:32:36.381169 ------------------ +On: 2011-07-30 00:32:36.389505 Event: try to Connect to Controller +On: 2011-07-30 00:32:39.254557 Event: init state +On: 2011-07-30 00:32:39.254662 Event: Register Account to SIP server +On: 2011-07-30 00:32:39.302100 Event: 100 +On: 2011-07-30 00:32:39.303401 Event: Receiver Handler Ready +On: 2011-07-30 00:32:39.303465 Event: RECEIVE START +On: 2011-07-30 00:32:45.346692 Event: {Call "anonymous" } +On: 2011-07-30 00:32:45.347091 Event: Call Connecting +On: 2011-07-30 00:32:45.347129 Event: 200 +On: 2011-07-30 00:32:45.347287 Event: Answer call +On: 2011-07-30 00:32:45.347323 Event: Hangup call +On: 2011-07-30 00:32:45.347446 Event: CALL OK +On: 2011-07-30 00:32:45.500536 Event: Call Disconnected +On: 2011-07-30 00:32:46.218824 Event: Terminate +On: 2011-07-30 00:32:46.218872 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:33:35.950284 ------------------ +On: 2011-07-30 00:33:35.958817 Event: try to Connect to Controller +On: 2011-07-30 00:33:38.817673 Event: init state +On: 2011-07-30 00:33:38.817826 Event: Register Account to SIP server +On: 2011-07-30 00:33:38.865841 Event: 100 +On: 2011-07-30 00:33:38.865926 Event: Receiver Handler Ready +On: 2011-07-30 00:33:38.867128 Event: RECEIVE START +On: 2011-07-30 00:33:44.604232 Event: {Call "anonymous" } +On: 2011-07-30 00:33:44.604630 Event: Call Connecting +On: 2011-07-30 00:33:44.604652 Event: 200 +On: 2011-07-30 00:33:44.604820 Event: Answer call +On: 2011-07-30 00:33:44.604848 Event: Hangup call +On: 2011-07-30 00:33:44.604946 Event: CALL OK +On: 2011-07-30 00:33:44.757964 Event: Call Disconnected +On: 2011-07-30 00:33:45.465493 Event: Terminate +On: 2011-07-30 00:33:45.465530 Event: Goodbye diff --git a/For Weekly Test/19-08-2011/LogFileClass.py b/For Weekly Test/19-08-2011/LogFileClass.py new file mode 100644 index 0000000..cb152f4 --- /dev/null +++ b/For Weekly Test/19-08-2011/LogFileClass.py @@ -0,0 +1,21 @@ +import string +import datetime + +class Logging: + + def __init__(self, logFileName): + self.writeToFile = open(logFileName, 'a') + self.justStarted = 1 + + def logEvent(self, event): + now = str(datetime.datetime.now()) + if self.justStarted == 1: + self.writeToFile.write('\n\n------------------STARTED THE LOGGING '+ now + ' ------------------\n') + self.justStarted = 0 + else: + self.writeToFile.write('On: '+ now + '\t' + 'Event: ' +str(event) + '\n') + + def closeLogging(self): + now = str(datetime.datetime.now()) + self.writeToFile.write('------------------FINISHED THE LOGGING '+ now + ' ------------------') + self.writeToFile.close() diff --git a/For Weekly Test/19-08-2011/LogFileClass.pyc b/For Weekly Test/19-08-2011/LogFileClass.pyc new file mode 100644 index 0000000..52fd946 Binary files /dev/null and b/For Weekly Test/19-08-2011/LogFileClass.pyc differ diff --git a/For Weekly Test/19-08-2011/PingClass.py b/For Weekly Test/19-08-2011/PingClass.py new file mode 100644 index 0000000..e13b32b --- /dev/null +++ b/For Weekly Test/19-08-2011/PingClass.py @@ -0,0 +1,28 @@ +import subprocess +import string + +class Ping: + + def __init__(self, pingAddress): + self.pingAddress = pingAddress + + def ping(self,numberTries): + tried = 1 + while numberTries >= tried: + tried += 1 + #the parameter c 1 means only one ping to be sent, parameter W 3 means how many seconds the time out should be, 3 seconds + ping_cmd = subprocess.Popen(['ping', self.pingAddress, '-c', '1', '-W', '2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] + + pingAlive = int(string.find(ping_cmd, '1 received')) + unknownHost = int(string.find(ping_cmd, 'unknown host')) + + + if pingAlive != -1: + break + + if unknownHost != -1: + return 2 #unknown host + if pingAlive != -1: + return 1 #ping works fine + else: + return 0 #no ping response diff --git a/For Weekly Test/19-08-2011/PingClass.pyc b/For Weekly Test/19-08-2011/PingClass.pyc new file mode 100644 index 0000000..9ac5c4b Binary files /dev/null and b/For Weekly Test/19-08-2011/PingClass.pyc differ diff --git a/For Weekly Test/19-08-2011/SIP handler.log b/For Weekly Test/19-08-2011/SIP handler.log new file mode 100644 index 0000000..ee0220b --- /dev/null +++ b/For Weekly Test/19-08-2011/SIP handler.log @@ -0,0 +1,168 @@ + + +------------------STARTED THE LOGGING 2011-07-29 23:21:57.415823 ------------------ +On: 2011-07-29 23:21:57.425345 Event: try to Connect to Controller +On: 2011-07-29 23:22:00.306913 Event: init state +On: 2011-07-29 23:22:00.307021 Event: Register Account to SIP server + + +------------------STARTED THE LOGGING 2011-07-29 23:24:53.876724 ------------------ +On: 2011-07-29 23:24:53.884855 Event: try to Connect to Controller +On: 2011-07-29 23:24:56.739250 Event: init state +On: 2011-07-29 23:24:56.739367 Event: Register Account to SIP server + + +------------------STARTED THE LOGGING 2011-07-29 23:25:11.922247 ------------------ +On: 2011-07-29 23:25:11.930374 Event: try to Connect to Controller +On: 2011-07-29 23:25:14.776741 Event: init state +On: 2011-07-29 23:25:14.776832 Event: Register Account to SIP server + + +------------------STARTED THE LOGGING 2011-07-29 23:25:27.644319 ------------------ +On: 2011-07-29 23:25:27.654529 Event: try to Connect to Controller +On: 2011-07-29 23:25:30.488887 Event: init state +On: 2011-07-29 23:25:30.488998 Event: Register Account to SIP server + + +------------------STARTED THE LOGGING 2011-07-29 23:26:15.433339 ------------------ +On: 2011-07-29 23:26:15.444299 Event: try to Connect to Controller +On: 2011-07-29 23:26:18.276304 Event: init state +On: 2011-07-29 23:26:18.276337 Event: Register Account to SIP server + + +------------------STARTED THE LOGGING 2011-07-29 23:42:10.319903 ------------------ +On: 2011-07-29 23:42:10.328198 Event: try to Connect to Controller +On: 2011-07-29 23:42:13.196833 Event: init state +On: 2011-07-29 23:42:13.197004 Event: Register Account to SIP server +On: 2011-07-29 23:42:13.197373 Event: 100 +On: 2011-07-29 23:42:13.197448 Event: Caller Handler Ready +On: 2011-07-29 23:42:21.238138 Event: CALL START +On: 2011-07-29 23:42:21.238194 Event: Make a call to: 076145875681 +On: 2011-07-29 23:42:25.393438 Event: Call Connecting +On: 2011-07-29 23:42:25.393485 Event: 200 +On: 2011-07-29 23:42:25.394043 Event: Terminate +On: 2011-07-29 23:42:25.394074 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-29 23:43:06.750461 ------------------ +On: 2011-07-29 23:43:06.759085 Event: try to Connect to Controller +On: 2011-07-29 23:43:09.613473 Event: init state +On: 2011-07-29 23:43:09.613644 Event: Register Account to SIP server +On: 2011-07-29 23:43:09.614010 Event: 100 +On: 2011-07-29 23:43:09.614061 Event: Caller Handler Ready +On: 2011-07-29 23:43:17.673133 Event: CALL START +On: 2011-07-29 23:43:17.673190 Event: Make a call to: 076145875681 +On: 2011-07-29 23:43:23.100719 Event: Call Connecting +On: 2011-07-29 23:43:23.100753 Event: 200 +On: 2011-07-29 23:43:23.101544 Event: Terminate +On: 2011-07-29 23:43:23.101576 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:10:39.836082 ------------------ +On: 2011-07-30 00:10:39.845051 Event: try to Connect to Controller +On: 2011-07-30 00:10:42.697416 Event: init state +On: 2011-07-30 00:10:42.697558 Event: Register Account to SIP server +On: 2011-07-30 00:10:42.697908 Event: 100 +On: 2011-07-30 00:10:42.697990 Event: Caller Handler Ready +On: 2011-07-30 00:10:50.739806 Event: CALL START +On: 2011-07-30 00:10:50.739862 Event: Make a call to: 076145875681 +On: 2011-07-30 00:10:56.338263 Event: Call Connecting +On: 2011-07-30 00:10:56.338295 Event: 200 +On: 2011-07-30 00:10:56.338926 Event: Terminate +On: 2011-07-30 00:10:56.338971 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:11:32.044804 ------------------ +On: 2011-07-30 00:11:32.055384 Event: try to Connect to Controller +On: 2011-07-30 00:11:34.895786 Event: init state +On: 2011-07-30 00:11:34.895941 Event: Register Account to SIP server +On: 2011-07-30 00:11:34.896327 Event: 100 +On: 2011-07-30 00:11:34.896381 Event: Caller Handler Ready +On: 2011-07-30 00:11:42.941360 Event: CALL START +On: 2011-07-30 00:11:42.941412 Event: Make a call to: 076145875681 +On: 2011-07-30 00:12:19.738871 Event: Terminate +On: 2011-07-30 00:12:19.738916 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:26:54.311305 ------------------ +On: 2011-07-30 00:26:54.320356 Event: try to Connect to Controller +On: 2011-07-30 00:26:57.176776 Event: init state +On: 2011-07-30 00:26:57.176895 Event: Register Account to SIP server +On: 2011-07-30 00:26:57.177196 Event: 100 +On: 2011-07-30 00:26:57.177239 Event: Caller Handler Ready +On: 2011-07-30 00:27:05.219886 Event: CALL START +On: 2011-07-30 00:27:05.219948 Event: Make a call to: 076145875681 +On: 2011-07-30 00:27:09.641501 Event: Call Connecting +On: 2011-07-30 00:27:09.641557 Event: 200 +On: 2011-07-30 00:27:09.642486 Event: Terminate +On: 2011-07-30 00:27:09.642523 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:27:58.409659 ------------------ +On: 2011-07-30 00:27:58.417830 Event: try to Connect to Controller +On: 2011-07-30 00:28:01.285869 Event: init state +On: 2011-07-30 00:28:01.286077 Event: Register Account to SIP server +On: 2011-07-30 00:28:01.286389 Event: 100 +On: 2011-07-30 00:28:01.286431 Event: Caller Handler Ready +On: 2011-07-30 00:28:09.329917 Event: CALL START +On: 2011-07-30 00:28:09.329971 Event: Make a call to: 076145875681 +On: 2011-07-30 00:28:15.222548 Event: Call Connecting +On: 2011-07-30 00:28:15.222589 Event: 200 +On: 2011-07-30 00:28:15.223404 Event: Terminate +On: 2011-07-30 00:28:15.223435 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:29:45.720356 ------------------ +On: 2011-07-30 00:29:45.729640 Event: try to Connect to Controller +On: 2011-07-30 00:29:48.610439 Event: init state +On: 2011-07-30 00:29:48.610574 Event: Register Account to SIP server +On: 2011-07-30 00:29:48.610890 Event: 100 +On: 2011-07-30 00:29:48.610932 Event: Caller Handler Ready +On: 2011-07-30 00:29:56.654983 Event: CALL START +On: 2011-07-30 00:29:56.655033 Event: Make a call to: 076145875681 +On: 2011-07-30 00:30:00.999654 Event: Call Connecting +On: 2011-07-30 00:30:00.999696 Event: 200 +On: 2011-07-30 00:30:01.000381 Event: Terminate +On: 2011-07-30 00:30:01.000414 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:30:53.582445 ------------------ +On: 2011-07-30 00:30:53.591399 Event: try to Connect to Controller +On: 2011-07-30 00:30:56.463424 Event: init state +On: 2011-07-30 00:30:56.463573 Event: Register Account to SIP server +On: 2011-07-30 00:30:56.463798 Event: 100 +On: 2011-07-30 00:30:56.463820 Event: Caller Handler Ready +On: 2011-07-30 00:31:04.516608 Event: CALL START +On: 2011-07-30 00:31:04.516663 Event: Make a call to: 076145875681 +On: 2011-07-30 00:31:08.090713 Event: Call Connecting +On: 2011-07-30 00:31:08.090759 Event: 200 +On: 2011-07-30 00:31:08.091467 Event: Terminate +On: 2011-07-30 00:31:08.091499 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:32:33.354788 ------------------ +On: 2011-07-30 00:32:33.363048 Event: try to Connect to Controller +On: 2011-07-30 00:32:36.248229 Event: init state +On: 2011-07-30 00:32:36.248378 Event: Register Account to SIP server +On: 2011-07-30 00:32:36.248733 Event: 100 +On: 2011-07-30 00:32:36.248833 Event: Caller Handler Ready +On: 2011-07-30 00:32:42.303930 Event: CALL START +On: 2011-07-30 00:32:42.303983 Event: Make a call to: 076145875681 +On: 2011-07-30 00:32:46.218329 Event: Call Connecting +On: 2011-07-30 00:32:46.218374 Event: 200 +On: 2011-07-30 00:32:46.219139 Event: Terminate +On: 2011-07-30 00:32:46.219177 Event: Goodbye + + +------------------STARTED THE LOGGING 2011-07-30 00:33:32.956715 ------------------ +On: 2011-07-30 00:33:32.965479 Event: try to Connect to Controller +On: 2011-07-30 00:33:35.811340 Event: init state +On: 2011-07-30 00:33:35.811482 Event: Register Account to SIP server +On: 2011-07-30 00:33:35.811814 Event: 100 +On: 2011-07-30 00:33:35.811857 Event: Caller Handler Ready +On: 2011-07-30 00:33:41.869229 Event: CALL START +On: 2011-07-30 00:33:41.869282 Event: Make a call to: 076145875681 +On: 2011-07-30 00:33:45.465131 Event: Call Connecting +On: 2011-07-30 00:33:45.465173 Event: 200 +On: 2011-07-30 00:33:45.465887 Event: Terminate +On: 2011-07-30 00:33:45.465913 Event: Goodbye diff --git a/For Weekly Test/19-08-2011/SIPHandler.py b/For Weekly Test/19-08-2011/SIPHandler.py new file mode 100644 index 0000000..6d268a9 --- /dev/null +++ b/For Weekly Test/19-08-2011/SIPHandler.py @@ -0,0 +1,229 @@ +import sys +import string +import pjsua as pj +import ServerClass +import LogFileClass + +from time import sleep + +def log_cb(level, str, len): + print "--------starting Handler--------" + +# Receive events from incoming Call +class Account(pj.AccountCallback): + + def on_incoming_call(self, call): + global current_call + + current_call = call + call_cb = Calling(current_call) + current_call.set_callback(call_cb) + + logger.logEvent(current_call) + + call.answer(200) + logger.logEvent("Answer call") + + if current_call <> None: + logger.logEvent("Hangup call") + call.hangup() + + logger.logEvent('CALL OK') + +class Calling(pj.CallCallback): + + def __init__(self, call=None): + pj.CallCallback.__init__(self, call) + + def on_state(self): + global current_call + + if self.call.info().state <> pj.CallState.DISCONNECTED: + if self.call.info().state_text == "CONNECTING": + logger.logEvent("Call Connecting") + logger.logEvent('200') + server.sendData('CALL OK') + + if self.call.info().last_reason == "Busy Here": + logger.logEvent('Number busy or Offline') + server.sendData('CALL NOT OK') + logger.logEvent('CALL NOT OK') + + if self.call.info().state == pj.CallState.DISCONNECTED: + logger.logEvent('Call Disconnected') + current_call = None + + +def make_call(uri): + + try: + + cb=Calling() + return acc.make_call(uri, cb) + + except pj.Error, e: + print "408 " + str(e) + logger.logEvent('408') + return None + +def greeting(): + global server + global status + global port + + port = sys.argv[2] + server = None + status = None + + server = ServerClass.ServerHandler(port) + logger.logEvent('try to Connect to Controller') + conn = server.openSocket() + + if server.connected == 1: + if server.receiveData(30) == 'HELLO HANDLER': + server.sendData('HELLO CONTROLLER') + status = 'OK' + else: + status = 'NOT OK' + logger.logEvent('Cant connect to Controller') + sys.exit(1) + +def initLogFile(sipServer): + + global logger + + if sipServer == '132.230.4.8': + nameOfLogFile = 'SIP handler.log' + + elif sipServer == 'sipgate.de': + nameOfLogFile = 'Landline handler.log' + + elif sipServer == '132.230.252.228': + nameOfLogFile = 'University SIP handler.log' + + logger = LogFileClass.Logging(nameOfLogFile) + +def initState(): + global message + global state + global num + + logger.logEvent('init state') + message = server.receiveData(30) + + if message == 'RECEIVER': + state = 'RECEIVER' + + elif message[0:6] == 'CALLER': + state = 'CALLER' + num = message[7:] + +def initHandler(): + global sipServer + global username + global password + + + accConf = sys.argv[1] + username = accConf[0:accConf.find(':')] + + line = accConf[accConf.find(':')+1:] + password = line[0:line.find(':')] + + newLine = line[line.find(':')+1:] + sipServer = newLine[0:newLine.find(':')] + + +lib = pj.Lib() +stop = False + +initHandler() + +initLogFile(sipServer) + +logger.logEvent('') + +while stop <> True: + + acc_cfg = None + + lib.init(log_cfg = pj.LogConfig(level=1, callback=log_cb)) + transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0)) + + lib.start() + lib.set_null_snd_dev() + + greeting() + + + try: + initState() + acc_cfg = pj.AccountConfig(str(sipServer),str(username),str(password)) + logger.logEvent('Register Account to SIP server') + acc = lib.create_account(acc_cfg, cb=Account()) + + if acc.info().reg_status < 700: + + if state =='RECEIVER': + logger.logEvent(acc.info().reg_status) + server.sendData('RECEIVER READY') + logger.logEvent('Receiver Handler Ready') + + while 1: + + data = server.receiveData(1) + + if data == 'RECEIVE START': + logger.logEvent(data) + + if data == 'TERMINATE CONNECTION': + logger.logEvent('Terminate') + stop = True + break + + elif state =='CALLER': + logger.logEvent(acc.info().reg_status) + server.sendData('CALLER READY') + logger.logEvent('Caller Handler Ready') + + while 1: + + data = server.receiveData(1) + + if data == 'CALL START': + if num <> '': + sleep(3) + logger.logEvent(data) + logger.logEvent('Make a call to: ' + num) + number = "sip:"+num+"@"+sipServer + make_call(number) + else: + logger.logEvent('No number to call') + logger.logEvent('CALL NOT OK') + + if data == 'TERMINATE CONNECTION': + stop = True + logger.logEvent('Terminate') + break + + else: + logger.logEvent('Unknow Message') + server.sendData('Unknow Message') + server.closeConnection() + sys.exit(0.5) + + else: + logger.logEvent("488 Not Acceptable Here") + lib.destroy() + + except ValueError: + print "401 Unauthorized " + str(e) + logger.logEvent("401 Unauthorized ") + +logger.logEvent("Goodbye") +acc.delete() +lib.destroy() +server.closeConnection() +lib = None +acc = None + diff --git a/For Weekly Test/19-08-2011/ServerClass.py b/For Weekly Test/19-08-2011/ServerClass.py new file mode 100644 index 0000000..93c2f8e --- /dev/null +++ b/For Weekly Test/19-08-2011/ServerClass.py @@ -0,0 +1,152 @@ +import socket +import sys +import os +import string +import signal + +class TimeoutException(Exception): + pass + +class ServerHandler: + + def __init__(self,p): + self.port = p + self.host = None #symbolic name meaning all available interfaces + self.s = None + self.connected = 0 + self.address = "127.0.0.1" #address of the main controller + self.onceConnected = 0 + self.error = 'No error' + + self.debugMode = 0 + + def openSocket(self): + self.error = 'No error' + for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, + socket.SOCK_STREAM, 0, socket.AI_PASSIVE): + af, socktype, proto, canonname, sa = res + + try: + self.s = socket.socket(af, socktype, proto) + self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #this resolves the bug with live packets + except socket.error, msg: + self.s = None + self.connected = 0 + self.error = str(msg) + continue + + try: + self.s.bind(sa) + self.s.listen(1) + except socket.error, msg: + self.s.close() + self.s = None + self.connected = 0 + self.error = str(msg) + continue + break + + if self.s is None: + self.connected = 0 + return 0 + else: #accept the connection + self.connection, self.address = self.s.accept() + self.connected = 1 + self.onceConnected = 1 + return 1 + + def connectedTo(self): + return self.address + + def receiveData(self, timeout): + if self.connected == 1: + + def timeout_handler(signum, frame): + raise TimeoutException() + + try: + + old_handler = signal.signal(signal.SIGALRM, timeout_handler) + signal.alarm(timeout) #start the timeout alarm, for timeout seconds + + data = self.connection.recv(1024) + + #stop the timeout function + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + + if not data: + self.connected = 0 + return 'NO DATA' + else: + return data + + except TimeoutException: + #timeout happened + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + return 'TIMEOUT' + + except Exception, e: + #stop the timeout timer + signal.signal(signal.SIGALRM, old_handler) + signal.alarm(0) + + if self.debugMode == 1: + import traceback + print traceback.format_exc() + print e + self.connected = 0 + if error[0:11] == '[Errno 104]': + return 3 #the other side reset the connection,[Errno 104] Connection reset by peer + + return 2 + else: + return 0 + + def sendData(self, data): + if self.connected == 1: + try: + self.connection.send(data) + return 1 + + except Exception, e: + if self.debugMode == 1: + import traceback + print traceback.format_exc() + print e + self.connecected = 0 + return 2 + else: + return 0 + + def closeConnection(self): + if self.onceConnected == 1: + try: + self.connected = 0 + SHUT_RDWR = 2 + self.connection.shutdown(SHUT_RDWR) + self.connection.close() + return 1 + except Exception, e: + self.connected = 0 + error = str(e) + if self.debugMode == 1: + import traceback + print traceback.format_exc() + print e + if error[0:11] == '[Errno 107]': + return 3 #the other side closed the connection before us [Errno 107] Transport endpoint is not connected + return 2 + else: + return 0 + + def killPort(self): + killResult = os.popen('lsof -i tcp:' + str(self.port) + ' | grep "python " | awk -F" " ' + "'{print $2}'").read() + killResult = killResult.replace('\n','') + print killResult + if killResult!='': + print killResult + killPort = os.popen("kill -9 " + killResult).read() + return 1 + return 0 diff --git a/For Weekly Test/19-08-2011/ServerClass.pyc b/For Weekly Test/19-08-2011/ServerClass.pyc new file mode 100644 index 0000000..99bd14d Binary files /dev/null and b/For Weekly Test/19-08-2011/ServerClass.pyc differ diff --git a/For Weekly Test/19-08-2011/TestProcessLog.log b/For Weekly Test/19-08-2011/TestProcessLog.log new file mode 100644 index 0000000..4826295 --- /dev/null +++ b/For Weekly Test/19-08-2011/TestProcessLog.log @@ -0,0 +1,200 @@ + + +------------------STARTED THE LOGGING 2011-07-29 23:21:57.301030 ------------------ +On: 2011-07-29 23:21:57.301097 Event: init Caller +On: 2011-07-29 23:21:57.301117 Event: sip +On: 2011-07-29 23:22:00.306750 Event: Connected to Caller Handler +On: 2011-07-29 23:22:00.306934 Event: Caller Handler respond +On: 2011-07-29 23:22:00.330494 Event: 605 General Handler Error: caller handler no respond timeout + + +------------------STARTED THE LOGGING 2011-07-29 23:24:53.733342 ------------------ +On: 2011-07-29 23:24:53.733408 Event: init Caller +On: 2011-07-29 23:24:53.733427 Event: sip +On: 2011-07-29 23:24:56.739075 Event: Connected to Caller Handler +On: 2011-07-29 23:24:56.739283 Event: Caller Handler respond +On: 2011-07-29 23:24:56.743416 Event: 605 General Handler Error: caller handler no respond timeout + + +------------------STARTED THE LOGGING 2011-07-29 23:25:11.770967 ------------------ +On: 2011-07-29 23:25:11.771004 Event: init Caller +On: 2011-07-29 23:25:11.771011 Event: sip +On: 2011-07-29 23:25:14.776562 Event: Connected to Caller Handler +On: 2011-07-29 23:25:14.776759 Event: Caller Handler respond +On: 2011-07-29 23:25:14.778543 Event: 605 General Handler Error: caller handler no respond timeout + + +------------------STARTED THE LOGGING 2011-07-29 23:25:27.483948 ------------------ +On: 2011-07-29 23:25:27.484014 Event: init Caller +On: 2011-07-29 23:25:27.484034 Event: sip +On: 2011-07-29 23:25:30.488703 Event: Connected to Caller Handler +On: 2011-07-29 23:25:30.488907 Event: Caller Handler respond +On: 2011-07-29 23:25:30.492889 Event: 605 General Handler Error: caller handler no respond timeout + + +------------------STARTED THE LOGGING 2011-07-29 23:26:15.270712 ------------------ +On: 2011-07-29 23:26:15.270780 Event: init Caller +On: 2011-07-29 23:26:15.270799 Event: sip +On: 2011-07-29 23:26:18.276198 Event: Connected to Caller Handler +On: 2011-07-29 23:26:18.276306 Event: Caller Handler respond +On: 2011-07-29 23:26:18.279521 Event: 605 General Handler Error: caller handler no respond timeout + + +------------------STARTED THE LOGGING 2011-07-29 23:42:10.192780 ------------------ +On: 2011-07-29 23:42:10.192869 Event: init Caller +On: 2011-07-29 23:42:10.192901 Event: sip +On: 2011-07-29 23:42:13.196666 Event: Connected to Caller Handler +On: 2011-07-29 23:42:13.196857 Event: Caller Handler respond +On: 2011-07-29 23:42:13.197492 Event: Caller handler : Ready +On: 2011-07-29 23:42:13.197523 Event: init Receiver +On: 2011-07-29 23:42:13.197551 Event: landline +On: 2011-07-29 23:42:16.203095 Event: Connected to Receiver Handler +On: 2011-07-29 23:42:16.203292 Event: Receiver Handler respond +On: 2011-07-29 23:42:16.236357 Event: Receiver handler : Ready +On: 2011-07-29 23:42:16.236397 Event: Start Call +On: 2011-07-29 23:42:16.236480 Event: Waiting Feedback +On: 2011-07-29 23:42:25.393704 Event: Test Succeed + + +------------------STARTED THE LOGGING 2011-07-29 23:43:06.607570 ------------------ +On: 2011-07-29 23:43:06.607634 Event: init Caller +On: 2011-07-29 23:43:06.607654 Event: sip +On: 2011-07-29 23:43:09.613314 Event: Connected to Caller Handler +On: 2011-07-29 23:43:09.613504 Event: Caller Handler respond +On: 2011-07-29 23:43:09.614142 Event: Caller handler : Ready +On: 2011-07-29 23:43:09.614180 Event: init Receiver +On: 2011-07-29 23:43:09.614210 Event: landline +On: 2011-07-29 23:43:12.619780 Event: Connected to Receiver Handler +On: 2011-07-29 23:43:12.619981 Event: Receiver Handler respond +On: 2011-07-29 23:43:12.667920 Event: Receiver handler : Ready +On: 2011-07-29 23:43:12.667952 Event: Start Call +On: 2011-07-29 23:43:12.668021 Event: Waiting Feedback +On: 2011-07-29 23:43:23.100908 Event: Test Succeed + + +------------------STARTED THE LOGGING 2011-07-30 00:10:39.691500 ------------------ +On: 2011-07-30 00:10:39.691562 Event: init Caller +On: 2011-07-30 00:10:39.691581 Event: sip +On: 2011-07-30 00:10:42.697234 Event: Connected to Caller Handler +On: 2011-07-30 00:10:42.697433 Event: Caller Handler respond +On: 2011-07-30 00:10:42.698013 Event: Caller handler : Ready +On: 2011-07-30 00:10:42.698050 Event: init Receiver +On: 2011-07-30 00:10:42.698078 Event: landline +On: 2011-07-30 00:10:45.703491 Event: Connected to Receiver Handler +On: 2011-07-30 00:10:45.703670 Event: Receiver Handler respond +On: 2011-07-30 00:10:45.737912 Event: Receiver handler : Ready +On: 2011-07-30 00:10:45.737950 Event: Start Call +On: 2011-07-30 00:10:45.738028 Event: Waiting Feedback +On: 2011-07-30 00:10:56.338452 Event: Test Succeed + + +------------------STARTED THE LOGGING 2011-07-30 00:11:31.889910 ------------------ +On: 2011-07-30 00:11:31.889974 Event: init Caller +On: 2011-07-30 00:11:31.889994 Event: sip +On: 2011-07-30 00:11:34.895578 Event: Connected to Caller Handler +On: 2011-07-30 00:11:34.895803 Event: Caller Handler respond +On: 2011-07-30 00:11:34.896404 Event: Caller handler : Ready +On: 2011-07-30 00:11:34.896442 Event: init Receiver +On: 2011-07-30 00:11:34.896471 Event: landline +On: 2011-07-30 00:11:37.901943 Event: Connected to Receiver Handler +On: 2011-07-30 00:11:37.902124 Event: Receiver Handler respond +On: 2011-07-30 00:11:37.936091 Event: Receiver handler : Ready +On: 2011-07-30 00:11:37.936130 Event: Start Call +On: 2011-07-30 00:11:37.936214 Event: Waiting Feedback +On: 2011-07-30 00:12:19.738731 Event: Test Failed + + +------------------STARTED THE LOGGING 2011-07-30 00:26:54.171248 ------------------ +On: 2011-07-30 00:26:54.171301 Event: init Caller +On: 2011-07-30 00:26:54.171316 Event: sip +On: 2011-07-30 00:26:57.176620 Event: Connected to Caller Handler +On: 2011-07-30 00:26:57.176790 Event: Caller Handler respond +On: 2011-07-30 00:26:57.177313 Event: Caller handler : Ready +On: 2011-07-30 00:26:57.177342 Event: init Receiver +On: 2011-07-30 00:26:57.177362 Event: landline +On: 2011-07-30 00:27:00.183045 Event: Connected to Receiver Handler +On: 2011-07-30 00:27:00.184305 Event: Receiver Handler respond +On: 2011-07-30 00:27:00.218555 Event: Receiver handler : Ready +On: 2011-07-30 00:27:00.218586 Event: Start Call +On: 2011-07-30 00:27:00.218653 Event: Waiting Feedback +On: 2011-07-30 00:27:09.641743 Event: Test Succeed + + +------------------STARTED THE LOGGING 2011-07-30 00:27:58.280395 ------------------ +On: 2011-07-30 00:27:58.280448 Event: init Caller +On: 2011-07-30 00:27:58.280464 Event: sip +On: 2011-07-30 00:28:01.285723 Event: Connected to Caller Handler +On: 2011-07-30 00:28:01.285934 Event: Caller Handler respond +On: 2011-07-30 00:28:01.286508 Event: Caller handler : Ready +On: 2011-07-30 00:28:01.286540 Event: init Receiver +On: 2011-07-30 00:28:01.286565 Event: landline +On: 2011-07-30 00:28:04.291863 Event: Connected to Receiver Handler +On: 2011-07-30 00:28:04.292049 Event: Receiver Handler respond +On: 2011-07-30 00:28:04.324731 Event: Receiver handler : Ready +On: 2011-07-30 00:28:04.324758 Event: Start Call +On: 2011-07-30 00:28:04.324809 Event: Waiting Feedback +On: 2011-07-30 00:28:15.222749 Event: Test Succeed + + +------------------STARTED THE LOGGING 2011-07-30 00:29:45.604794 ------------------ +On: 2011-07-30 00:29:45.604849 Event: init Caller +On: 2011-07-30 00:29:45.604865 Event: sip +On: 2011-07-30 00:29:48.610293 Event: Connected to Caller Handler +On: 2011-07-30 00:29:48.610457 Event: Caller Handler respond +On: 2011-07-30 00:29:48.610961 Event: Caller handler : Ready +On: 2011-07-30 00:29:48.610988 Event: init Receiver +On: 2011-07-30 00:29:48.611012 Event: landline +On: 2011-07-30 00:29:51.616488 Event: Connected to Receiver Handler +On: 2011-07-30 00:29:51.616698 Event: Receiver Handler respond +On: 2011-07-30 00:29:51.653007 Event: Receiver handler : Ready +On: 2011-07-30 00:29:51.653033 Event: Start Call +On: 2011-07-30 00:29:51.653089 Event: Waiting Feedback +On: 2011-07-30 00:30:00.999843 Event: Test Succeed + + +------------------STARTED THE LOGGING 2011-07-30 00:30:53.455843 ------------------ +On: 2011-07-30 00:30:53.455927 Event: init Caller +On: 2011-07-30 00:30:53.455956 Event: sip +On: 2011-07-30 00:30:56.462075 Event: Connected to Caller Handler +On: 2011-07-30 00:30:56.463454 Event: Caller Handler respond +On: 2011-07-30 00:30:56.463833 Event: Caller handler : Ready +On: 2011-07-30 00:30:56.463851 Event: init Receiver +On: 2011-07-30 00:30:56.463864 Event: landline +On: 2011-07-30 00:30:59.466866 Event: Connected to Receiver Handler +On: 2011-07-30 00:30:59.467064 Event: Receiver Handler respond +On: 2011-07-30 00:30:59.514807 Event: Receiver handler : Ready +On: 2011-07-30 00:30:59.514840 Event: Start Call +On: 2011-07-30 00:30:59.514905 Event: Waiting Feedback +On: 2011-07-30 00:31:08.090937 Event: Test Succeed + + +------------------STARTED THE LOGGING 2011-07-30 00:32:33.242689 ------------------ +On: 2011-07-30 00:32:33.242743 Event: init Caller +On: 2011-07-30 00:32:33.242759 Event: sip +On: 2011-07-30 00:32:36.248041 Event: Connected to Caller Handler +On: 2011-07-30 00:32:36.248249 Event: Caller Handler respond +On: 2011-07-30 00:32:36.248856 Event: Caller handler : Ready +On: 2011-07-30 00:32:36.248896 Event: init Receiver +On: 2011-07-30 00:32:36.248923 Event: landline +On: 2011-07-30 00:32:39.254384 Event: Connected to Receiver Handler +On: 2011-07-30 00:32:39.254580 Event: Receiver Handler respond +On: 2011-07-30 00:32:39.302242 Event: Receiver handler : Ready +On: 2011-07-30 00:32:39.302269 Event: Start Call +On: 2011-07-30 00:32:39.302328 Event: Waiting Feedback +On: 2011-07-30 00:32:46.218668 Event: Test Succeed + + +------------------STARTED THE LOGGING 2011-07-30 00:33:32.805854 ------------------ +On: 2011-07-30 00:33:32.805907 Event: init Caller +On: 2011-07-30 00:33:32.805923 Event: sip +On: 2011-07-30 00:33:35.811199 Event: Connected to Caller Handler +On: 2011-07-30 00:33:35.811359 Event: Caller Handler respond +On: 2011-07-30 00:33:35.811924 Event: Caller handler : Ready +On: 2011-07-30 00:33:35.812014 Event: init Receiver +On: 2011-07-30 00:33:35.812040 Event: landline +On: 2011-07-30 00:33:38.817500 Event: Connected to Receiver Handler +On: 2011-07-30 00:33:38.817694 Event: Receiver Handler respond +On: 2011-07-30 00:33:38.865974 Event: Receiver handler : Ready +On: 2011-07-30 00:33:38.866013 Event: Start Call +On: 2011-07-30 00:33:38.866098 Event: Waiting Feedback +On: 2011-07-30 00:33:45.465315 Event: Test Succeed diff --git a/For Weekly Test/19-08-2011/TrueTable.py b/For Weekly Test/19-08-2011/TrueTable.py new file mode 100644 index 0000000..d47da64 --- /dev/null +++ b/For Weekly Test/19-08-2011/TrueTable.py @@ -0,0 +1,167 @@ +# check signal on rz 1, 2, and 3 to indicated test +# only have option destination to GSM RZ, such as SIP to GSM RZ not SIP to GSM RZ 1, 2 or 3! + + +#resultsList = list() +#resultsList = [['sip', 'GSMRZ1', '200'],['sip', 'GSMRZ2', '200'],['sip', 'GSMRZ3', '200']] +resultsList = [['sip', 'GSMExt.O2', '486'],['sip', 'GSMExt.Voda', '486'],['sip', 'GSMExt.Tm', '486']] +callerList = ['sip'] + +def initTrueTable(caller): + + for x in resultsList: + caller = x[0] + destination = x[1] + result = x[2] + + if caller == x[0]: + + if destination == 'GSMRZ1' and result !='200': + + for y in resultsList: + destination = y[1] + result = y[2] + + if caller == y[0]: + if destination == 'GSMRZ2': + if result == '200': + + for z in resultsList: + + destination = z[1] + result = z[2] + + if caller == z[0]: + if destination == 'GSMRZ3': + + if result == '200': + print "BTS RZ 1 Broken" + else: + print "BTS RZ 1 & 3 indicate having Problem" + else: + + for z in resultsList: + + destination = z[1] + result = z[2] + + if caller == z[0]: + if destination == 'GSMRZ3': + + if result == '200': + print "BTS RZ 1 & 2 indicate having Problem" + else: + print "OpenBSc Down" + + elif destination == 'GSMRZ1' and result =='200': + + for y in resultsList: + + destination = y[1] + result = y[2] + + if caller == y[0]: + if destination == 'GSMRZ2': + if result == '200': + + for z in resultsList: + + destination = z[1] + result = z[2] + + if caller == z[0]: + if destination == 'GSMRZ3': + + if result != '200': + print "BTS RZ 3 Broken" + else: + print "All is Fine" + else: + + for z in resultsList: + + destination = z[1] + result = z[2] + + if caller == z[0]: + if destination == 'GSMRZ3': + + if result == '200': + print "BTS RZ 2 Broken" + else: + print "BTS RZ 2 & 3 indicate having Problem" + elif destination == 'GSMExt.O2': + if result != '200': + for y in resultsList: + + destination = y[1] + result = y[2] + + if caller == y[0]: + if destination == 'GSMExt.Voda': + if result == '200': + + for z in resultsList: + + destination = z[1] + result = z[2] + + if caller == z[0]: + if destination == 'GSMExt.Tm': + + if result != '200': + print "O2 & T-Mobile indicate having Problem" + else: + print "O2 indicate broken" + + else: + for z in resultsList: + + destination = z[1] + result = z[2] + + if caller == z[0]: + if destination == 'GSMExt.Tm': + + if result == '200': + print "O2 and Vodaphone indicate having problem" + else: + print "GSM External Modem broken" + else: + for y in resultsList: + + destination = y[1] + result = y[2] + + if caller == y[0]: + if destination == 'GSMExt.Voda': + if result == '200': + + for z in resultsList: + + destination = z[1] + result = z[2] + + if caller == z[0]: + if destination == 'GSMExt.Tm': + + if result == '200': + print "GSM external modem is Fine" + else: + print "T-Mobile indicate broken" + else: + for z in resultsList: + + destination = z[1] + result = z[2] + + if caller == z[0]: + if destination == 'GSMExt.Tm': + + if result == '200': + print "Vodaphone indicate broken" + else: + print "Vodaphone and T-Mobile indicate having problem" + +for caller in callerList: + initTrueTable(caller) diff --git a/For Weekly Test/19-08-2011/TrueTable2.py b/For Weekly Test/19-08-2011/TrueTable2.py new file mode 100644 index 0000000..808cfc4 --- /dev/null +++ b/For Weekly Test/19-08-2011/TrueTable2.py @@ -0,0 +1,172 @@ +# check signal on rz 1, 2, and 3 to indicated test +# only have option destination to GSM RZ, such as SIP to GSM RZ not SIP to GSM RZ 1, 2 or 3! + + +#resultsList = list() +#resultsList = [['sip', 'GSMRZ1', '200'],['sip', 'GSMRZ2', '200'],['sip', 'GSMRZ3', '200']] +resultsList = [['sip', 'GSMExt.O2', '486'],['sip', 'GSMExt.Voda', '486'],['sip', 'GSMExt.Tm', '486']] +callerList = ['sip'] +destinationList = ['GSMRZ'] + +def initDB(): + global dbStatus + global db + + db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting') + db.connectDB() + dbStatus = db.connectDB() + +def initTest(callFrom,callTo): + global dest + global caller + global callAdd + global accCaller + global recAdd + global destNo + global accDest + global result + + initDB() + + if dbStatus != 0: + + dest = db.deviceAddress(str(callTo)) + + caller = db.deviceAddress(str(callFrom)) + + callAdd = caller[0] + accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':' + + recAdd = destination[0] + destNo = destination[1] + accDest = destination[2]+':'+destination[3]+':'+destination[4]+':' + + makeTest = ControllerClass.test(caller, callAdd, accCaller, callTo, recAdd, destNo, accDest) + makeTest.FuncTest() + + result = makeTest.testResult + +def smartTest(): + + for callFrom in callerList: + for destination in destinationList: + + if destination == 'GSMRZ': + print "make a call to GSMRZ1" + initTest('sip','GSMRZ1') + + if result == '200': + print "make a call to GSMRZ2" + initTest('sip','GSMRZ2') + + if result == '200': + print "make a call to GSMRZ3" + initTest('sip','GSMRZ3') + + if result == '200': + print "all netwrok on GSMRZ are fine" + else: + print "BTS 3 Down" + + else: + print "make a call to GSMRZ3" + + if result == '200': + print "BTS 2 Down" + else: + print "BTS 2 and 3 indicate having problem" + + if result != '200': + print "make a call to GSMRZ2" + initTest('sip','GSMRZ2') + + if result == '200': + print "make a call to GSMRZ3" + initTest('sip','GSMRZ3') + + if result == '200': + print "BTS 1 Down" + else: + print "BTS 1 & 3 indicate having problem" + + else: + print "make a call to GSMRZ3" + + if result == '200': + print "BTS 1 & 2 indicate having problem" + else: + print "OpenBSc Down" + + elif destination == 'GSMExt': + print "make a call to O2" + initTest('sip','GSMExt.O2') + + if result == '200': + print "make a call to Voda" + initTest('sip','GSMExt.Voda') + + if result == '200': + print "make a call to T-Mobile" + initTest('sip','GSMExt.Tm') + + if result == '200': + print "All netwrok on GSM external are fine" + else: + print "T-Mobile card indicate having problem" + + else: + print "make a call to T-Mobile" + initTest('sip','GSMExt.Tm') + + if result == '200': + print "Vodaphone card indicate having problem" + else: + print "Vodaphone and T-Mobile card indicate having problem" + + if result != '200': + print "make a call to Vodaphone" + initTest('sip','GSMExt.Voda') + + if result == '200': + print "make a call to T-Mobile" + initTest('sip','GSMExt.Tm') + + if result == '200': + print "O2 card indicate having problem" + else: + print "O2 and T-Mobile card indicate having problem" + + else: + print "make a call to T-Mobile" + initTest('sip','GSMExt.Tm') + + if result == '200': + print "O2 and Vodaphone card indicate having problem" + else: + print "GSM External Modem Down" + + elif destination == 'SIP': + print "make a call to Landline" + initTest('sip','Landline') + + if result == '200': + print "make a call to UNISIP" + initTest('sip','unisip') + + if result =='200': + print "All SIP network is fine" + else: + print "UNISIP indicate having problem" + + else: + print "making a call to UNISIP" + initTest('sip','unisip') + + if result == '200': + print "Landline indicate having problem" + else: + print "SIP Network Down" + + +for caller in callerList: + smartTest() diff --git a/For Weekly Test/19-08-2011/gsmselftest.py b/For Weekly Test/19-08-2011/gsmselftest.py new file mode 100755 index 0000000..f8a385c --- /dev/null +++ b/For Weekly Test/19-08-2011/gsmselftest.py @@ -0,0 +1,293 @@ +#! /usr/bin/env python +import sys +import ControllerClass +import DbClass +import PingClass +from time import sleep + +def ping(handler): + + global serverStatus + + if handler == 'landline': + server = PingClass.Ping('sipgate.de') + serverStatus = server.ping(1) + + elif handler == 'sip': + server = PingClass.Ping('132.230.4.8') + serverStatus = server.ping(1) + + elif handler == 'unisip': + server = PingClass.Ping('132.230.252.228') + serverStatus = server.ping(1) + + elif handler == 'gsmr1': + server = PingClass.Ping('localhost') + serverStatus = server.ping(1) + + elif handler == 'gsmr2': + server = PingClass.Ping('132.230.4.64') + serverStatus = server.ping(1) + else: + serverStatus = 1 + +def allPing(): + + global sipGate + global sipServer + global sipLoc + global gsmBox1 + global gsmBox2 + + server = PingClass.Ping('sipgate.de') + sipGate = server.ping(3) + + server = PingClass.Ping('132.230.4.8') + sipServer = server.ping(3) + + server = PingClass.Ping('132.230.252.228') + sipLoc = server.ping(3) + + server = PingClass.Ping('localhost') + gsmBox1 = server.ping(3) + + server = PingClass.Ping('132.230.4.64') + gsmBox2 = server.ping(3) + + +def doTest(callFrom,callTo): + + + global testRepeat + + testRepeat = None + ping(callFrom) + + db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting') + db.connectDB() + dbStatus = db.connectDB() + + + if serverStatus <> 0 and dbStatus == 1: + + ping(callTo) + if serverStatus <> 0: + destination = db.deviceAddress(str(callTo)) + caller = db.deviceAddress(str(callFrom)) + + callAdd = caller[0] + accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':' + + recAdd = destination[0] + destNo = destination[1] + accDest = destination[2]+':'+destination[3]+':'+destination[4]+':' + + print '\n' + print 'Caller :', callFrom + print 'Destination :', callTo + makeTest = ControllerClass.test(callFrom, callAdd, accCaller, callTo, recAdd, destNo, accDest) + makeTest.FuncTest() + + if makeTest.repeatTest == True: + testRepeat = True + db.errorCode(makeTest.testResult) + print 'Result : ' +str(makeTest.testResult)+ ' ' +db.errCode + sleep(5) + else: + print '[failed] 500 '+callTo+ ' Server Internal Error' + else: + print '[failed] 500 '+callFrom+ ' Server Internal Error' + +def doSipTest(): + + print '--SIP Part Test--' + #destList = ['sip', 'gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'gsmeO', 'gsmeV', 'gsmeT', 'gsmeE'] + destList = ['landline'] + for callTo in destList: + + callFrom = 'sip' + if callFrom <> callTo: + doTest(callFrom, callTo) + if testRepeat == True: + doTest(callTo,callFrom) + +def doLandlineTest(): + + print '--Landline Part Test--' + destList = ['gsmr1', 'gsmr2', 'gsmr3', 'sip'] + + for callTo in destList: + + callFrom = 'landline' + doTest(callFrom, callTo) + if testRepeat == True: + doTest(callTo,callFrom) + +def doGsmrzTest(): + + print '--GSM Part Test--' + destList = ['sip', 'gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'gsmeO', 'gsmeV', 'gsmeT', 'gsmeE'] + callList = ['gsmr1','gsmr2', 'gsmr3'] + + for callFrom in callList: + + for callTo in destList: + if callTo <> callFrom: + doTest(callFrom, callTo) + if testRepeat == True: + doTest(callTo,callFrom) + + doGsmExtTest() + +def doGsmExtTest(): + + destList = ['sip', 'gsmr1','gsmr2', 'gsmr3'] + callList = ['gsmeO', 'gsmeV', 'gsmeT', 'gsmeE'] + + for callFrom in callList: + for callTo in destList: + + doTest(callFrom, callTo) + if testRepeat == True: + doTest(callTo,callFrom) + +def initResult(i, result): + global resultsList + + + + +def doAllTest(): + + doSipTest() + doLandlineTest() + doGsmTest() + +if len(sys.argv) > 1: + + command = sys.argv[1] + print '\n' + + if command == '--all': + doAllTest() + + elif command == '--sip': + doSipTest() + + elif command == '--gsm': + doGsmTest() + + elif command == '--landline': + doLandlineTest() + + elif command == '--help': + file = open('help.txt', 'r') + print file.read() + + else: + print "command not found, Type '--help', '--credits' for more information." + print '\n' +else: + global resultList + print '\n' + db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting') + db.connectDB() + dbStatus = db.connectDB() + resultsList = list() + + if dbStatus == 1: + + if db.anyTasksToDo() == 1: + + #allPing() + i=0 + for item in db.tasksList: + print item + taskID = item[0] + taskNo = item[1] + callFrom = item[2] + callTo = item[3] + tried = item[4] + + destination = db.deviceAddress(str(callTo)) + + caller = db.deviceAddress(str(callFrom)) + + callAdd = caller[0] + accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':' + + recAdd = destination[0] + destNo = destination[1] + accDest = destination[2]+':'+destination[3]+':'+destination[4]+':' + + #if i == 0: + # db.updatePingResult(taskNo, sipServer, sipGate, sipLoc, gsmBox1, gsmBox2) + print '\n' + print 'Task ID :', taskID + print 'Calling From :', callFrom + print 'To :', callTo + print 'number :', destNo + print 'status :', tried + + ping(callFrom) + + if serverStatus <> 0: + + ping(callTo) + if serverStatus <> 0: + + makeTest = ControllerClass.test(callFrom, callAdd, accCaller, callTo, recAdd, destNo, accDest) + makeTest.FuncTest() + + db.addResult(taskID, makeTest.testResult) + resultList.append([callTo, callFrom, makeTest.testResult]) + + if makeTest.repeatTest == True and tried <> '1': + db.insertTaskIn2(callTo,callFrom,taskNo, '1') + + db.errorCode(makeTest.testResult) + print 'Result : ' +str(makeTest.testResult)+ ' ' +db.errCode + + db.deleteTempTask(taskID) + db.tasksList.remove(item) + db.tasksList.insert(i,'') + + i = i+1 + + sleep(5) + else: + db.addResult(taskID, '500') + print '[failed] 500 '+callTo+ ' Server Internal Error' + else: + db.addResult(taskID, '500') + print '[failed] 500 '+callFrom+' Server Internal Error' + db.cleanTasksList() + else: + print "No job at all" + else: + sys.exit(1) + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/For Weekly Test/19-08-2011/help.txt b/For Weekly Test/19-08-2011/help.txt new file mode 100644 index 0000000..ccbc193 --- /dev/null +++ b/For Weekly Test/19-08-2011/help.txt @@ -0,0 +1,11 @@ + + +Usage: python gsmselftest.py [option] + +Options and arguments (and corresponding environment variables): + +--all : To execute all test case +--sip : To execute ALL test case +--gsm : To execute GSM test case +--extGsm : To execute external GSM test case +--landline : To execute Landline test case diff --git a/For Weekly Test/19-08-2011/true table.txt b/For Weekly Test/19-08-2011/true table.txt new file mode 100644 index 0000000..5a5916b --- /dev/null +++ b/For Weekly Test/19-08-2011/true table.txt @@ -0,0 +1,43 @@ +if GSMRZ1 != 200: + if GSMRZ2 = 200: + if GSMRZ3 == 200: + BTS RZ 1 problem + else: + unknow problem + elif GSMRZ3 == 200: + if GSMRZ2 == 200: + BTS RZ 1 Problem + else: + unknow problem + else: + OpenBSC problem + +if GSMRZ2 != 200: + if GSMRZ1 = 200: + if GSMRZ3 == 200: + BTS RZ 2 problem + else: + unknow problem + elif GSMRZ3 == 200: + if GSMRZ1 == 200: + BTS RZ 2 Problem + else: + unknow problem + else: + OpenBSC problem + +if GSMRZ3 != 200: + if GSMRZ1 = 200: + if GSMRZ2 == 200: + BTS RZ 3 problem + else: + unknow problem + elif GSMRZ2 == 200: + if GSMRZ1 == 200: + BTS RZ 3 Problem + else: + unknow problem + else: + OpenBSC problem + + -- cgit v1.2.3-55-g7522