summaryrefslogtreecommitdiffstats
path: root/For Weekly Test/tricode
diff options
context:
space:
mode:
Diffstat (limited to 'For Weekly Test/tricode')
-rwxr-xr-xFor Weekly Test/tricode/SSHTunnelClass.py47
-rwxr-xr-xFor Weekly Test/tricode/ServerClassSoftware.py162
-rw-r--r--For Weekly Test/tricode/ServerClassSoftware.pycbin4802 -> 0 bytes
-rwxr-xr-xFor Weekly Test/tricode/gsmselftest-website.py480
-rwxr-xr-xFor Weekly Test/tricode/gsmselftest-website2.py13
-rwxr-xr-xFor Weekly Test/tricode/gsmselftest.py783
-rwxr-xr-xFor Weekly Test/tricode/serialTest.py38
-rwxr-xr-xFor Weekly Test/tricode/sshtest.py15
8 files changed, 6 insertions, 1532 deletions
diff --git a/For Weekly Test/tricode/SSHTunnelClass.py b/For Weekly Test/tricode/SSHTunnelClass.py
deleted file mode 100755
index 12bedeb..0000000
--- a/For Weekly Test/tricode/SSHTunnelClass.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#Here is a tutorial how to generate and copy your RSA SSH public key :)
-#>>> http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/
-import subprocess
-
-class SSHTunneling:
-
- def __init__(self, localPort, remotePort, remoteServer, username, password):
- self.lPort = localPort
- self.rPort = remotePort
- self.rServer = remoteServer
-
- self.usern = username
- self.passw = password
-
- self.__tunnelStarted = 0
- self.__sshTunnel = 1
-
- def startTunneling(self):
- if self.__tunnelStarted == 0:
- command = str(self.lPort) + ':' + self.rServer + ':' + str(self.rPort)
- uad = self.usern + '@' + self.rServer
-
- try:
- self.__sshTunnel = subprocess.Popen(['ssh','-p','7884','-N', '-L', command, uad], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- self.__tunnelStarted = 1
- return 1
- except Exception, e:
- print str(e)
- return 0
-
- def killTunneling(self):
- if self.__tunnelStarted == 1:
- try:
- self.__sshTunnel.kill()
- self.__tunnelStarted = 0
- return 1
-
- except Exception, e:
- print str(e)
- return 0
-
-x = SSHTunneling(50000, 50008, '10.4.58.241', 'lsfks', 'r')
-print x.startTunneling()
-print 'Tunnel started '
-sleep(50)
-print x.killTunneling()
-print 'kill tunnel'
diff --git a/For Weekly Test/tricode/ServerClassSoftware.py b/For Weekly Test/tricode/ServerClassSoftware.py
deleted file mode 100755
index 206411e..0000000
--- a/For Weekly Test/tricode/ServerClassSoftware.py
+++ /dev/null
@@ -1,162 +0,0 @@
-import socket
-import sys
-import os
-import string
-import signal
-
-class TimeoutException(Exception):
- pass
-
-class ServerHandlerSoftware:
-
- 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, timeoutVar):
- 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
- self.s.settimeout(timeoutVar)
-
- 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
- try:
- self.connection, self.address = self.s.accept()
- self.s.settimeout(0)
- self.connected = 1
- self.onceConnected = 1
- return 1
- except socket.timeout:
- return 'TIMEOUT'
-
- 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/tricode/ServerClassSoftware.pyc b/For Weekly Test/tricode/ServerClassSoftware.pyc
deleted file mode 100644
index 8027a64..0000000
--- a/For Weekly Test/tricode/ServerClassSoftware.pyc
+++ /dev/null
Binary files differ
diff --git a/For Weekly Test/tricode/gsmselftest-website.py b/For Weekly Test/tricode/gsmselftest-website.py
deleted file mode 100755
index d653404..0000000
--- a/For Weekly Test/tricode/gsmselftest-website.py
+++ /dev/null
@@ -1,480 +0,0 @@
-#! /usr/bin/env python
-from serial import * #serial port library
-import sys
-import ControllerClass
-import DbClass
-import PingClass
-import trueTableClass
-import initTestClass
-import usbDetectClass
-from time import sleep
-
-global resultsList
-resultsList = list()
-
-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 allPing():
-
- global sipGate
- global sipServer
- global unisip
- global gsmBox1
- global gsmBox2
-
- server = PingClass.Ping('sipgate.de')
- sipGate = server.ping(2)
-
- server = PingClass.Ping('132.230.4.8')
- sipServer = server.ping(2)
-
- server = PingClass.Ping('132.230.252.228')
- unisip = server.ping(2)
-
- server = PingClass.Ping('localhost')
- gsmBox1 = server.ping(2)
-
- server = PingClass.Ping('10.4.58.241')
- gsmBox2 = server.ping(2)
-
-def initDB():
- global dbStatus
- global db
-
- db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
- db.connectDB()
- dbStatus = db.connectDB()
-
-
-def initTrueTable(x):
- initResult = trueTableClass.trueTable(x)
- initResult.initTrueTable()
- print '\n'
- openBSC = None
-
- for x in initResult.nanoBts:
- name = x[0]
- if x[1] == True:
- openBSC = True
- asterikServer = True
- else:
- if int(x[1]) == 486:
- print name+ ' not Working'
- elif int(x[1]) == 200:
- print name+ ' Working'
- else:
- print name+ ' not Working, handler error'
- print ''
- if openBSC != None:
- if openBSC == True:
- print 'openBSC working'
- else:
- print 'openBSC doesnt work'
- print ''
-
- if initResult.asteriskServer == True:
- print 'asterik server is working'
- print '\n'
-
- if initResult.outGoingRZ == True:
- print 'Outgoing call from RZ is working'
- elif initResult.outGoingRZ == False:
- print 'Outgoing call from RZ is not working'
-
- if initResult.incomingRZ == True:
- print 'incoming call from outside RZ to GSM RZ is working'
- elif initResult.incomingRZ == False:
- print 'incoming call from outside RZ to GSM RZ is not working'
- print '\n'
-
-
-def doSipTest():
-
- #destList = ['gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm' ]
- destList = ['landline']
- print "test"
- doTest = initTestClass.doTest()
- print 'iam here'
- for callTo in destList:
-
- callFrom = 'sip'
- doTest.initTest(callFrom,callTo)
- resultsList.append([callFrom, callTo, doTest.result])
-
-def doLandlineTest():
-
- destList = ['GSMRZ1','unisip', 'GSMRZ2','GSMRZ3']
- doTest = initTestClass.doTest()
- for callTo in destList:
-
- callFrom = 'landline'
- doTest.initTest(callFrom,callTo)
- resultsList.append([callFrom, callTo, doTest.result])
- initTrueTable(resultsList)
-
-def doGsmrzTest():
-
- destList = ['GSMRZ1','GSMRZ2', 'GSMRZ3']
- callList = ['sip']
- doTest = initTestClass.doTest()
-
- for callFrom in callList:
-
- for callTo in destList:
- doTest.initTest(callFrom,callTo)
- resultsList.append([callFrom, callTo, doTest.result])
- initTrueTable(resultsList)
-
-def doGsmExtTest():
-
- destList = ['GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm']
- callList = ['sip']
-
- doTest = initTestClass.doTest()
-
- for callFrom in callList:
- for callTo in destList:
- doTest.initTest(callFrom,callTo)
- resultsList.append([callFrom, callTo, doTest.result])
- initTrueTable(resultsList)
-
-def doAllTest():
-
- doSipTest()
- doLandlineTest()
- doGsmrzTest()
- doGsmExtTest()
-
-def regularTest():
- regulartest = initTestClass.doTest()
- regulartest.smartTest()
- initTrueTable(regulartest.smartResultList)
-
-def withDB():
-
- initDB()
- resultsList = list()
- if dbStatus == 1: # Checking connection to database
- if db.anyTasksToDo() == 1: # Checking task on the table
-
- 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)
-
- resultsList.append([callFrom, callTo, makeTest.result])
-
- db.errorCode(makeTest.result)
- print 'Result : ' +makeTest.result+ ' ' +db.errCode
-
- db.deleteTempTask(taskID)
- i = i+1
-
- db.cleanTasksList()
-
- print '\n'
-
- initTrueTable(resultsList) # fetch result list and make adjustment about the result
- db.closeDBConn()
- else:
- print "--- No job at all ---"
- db.closeDBConn()
- else:
- print 'Cant connect to database'
- sys.exit(1)
-
-def findPort(portName): # take information in existing usb port
- global connect
- global prefix
- global num
- global IMEI
- global portClass
- sleep(0.5)
- portLog = os.popen('dmesg | grep \'pl2303 converter now attached to '+portName+'\'').read()
- sleep(0.5)
- if portLog != '':
- connect = 1
- portClass = usbDetectClass.serialPort(portName)
- portClass.findNumber()
- portClass.findIMEI()
- IMEI = portClass.IMEI
- num = portClass.number
- number = portClass.number
- prefix = number[0:4]
- else:
- connect = 0
-
-def initDevice(deviceName):
- print 'Device Name :',deviceName
- print ' Device IMEI : ',
- imei = sys.stdin.readline().rstrip("\r\n")
- print 'Phone number : ',
- number = sys.stdin.readline().rstrip("\r\n")
- 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 =='
- else:
- findPort(portName)
- if connect == 1:
- if str(IMEI) != str(imei) and str(num) != str(number):
- print '== error, device not found =='
- elif str(IMEI) == str(imei):
- portClass.initUpdate(deviceName, portName, number)
- print '== Device succeced added =='
- elif str(num) == str(number) and str(IMEI) != str(imei):
- portClass.initUpdate(deviceName, portName, number)
- print '== Device succeced added, but have different IMEI =='
- else:
- print '== error, no device connected =='
-
-
-def updateDevice(): #update port name list of device on DB
- quit = False
- while quit != True:
- print ''
- print "USB Mobile device configuration"
- print "Menu: a = automatic device configuration, m = Manual configuration, q = quit : ",
- input = sys.stdin.readline().rstrip("\r\n")
- print ''
- if input == 'm': # manual configuration
-
- while True:
- print ''
- print "Mobile device name: "
- print " 1. GSM O2"
- print " 2. GSM Vodafone"
- print " 3. GSM Eplus"
- print " 4. GSM T-Mobile"
- print " 5. GSM RZ 1"
- print " 6. Back to menu"
- print ""
- print "your choise : ",
- input = sys.stdin.readline().rstrip("\r\n")
-
- if input == '8':
- break
- elif input == '1':
- initDevice('GSMExt.O2')
- elif input == '2':
- initDevice('GSMExt.Voda')
- elif input == '3':
- initDevice('GSMExt.Eplus')
- elif input == '4':
- initDevice('GSMExt.Tm')
- elif input == '5':
- initDevice('GSMRZ1')
- else:
- print 'please choose between 1-6'
- if input == 'a': #automatic configuration
- i = 0
- x = 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'
-
- print '== FINISH =='
- print 'Found '+str(x)+' devices'
-
- 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':
- resultsList = list()
- doAllTest()
-
- elif command == '--sip':
- resultsList = list()
- doSipTest()
-
- elif command == '--gsmrz':
- resultsList = list()
- doGsmrzTest()
-
- elif command == '--gsmext':
- resultsList = list()
- doGsmExtTest()
-
- elif command == '--landline':
- resultsList = list()
- doLandlineTest()
-
- elif command == '--smart':
- resultsList = list()
- regularTest()
-
- elif command == '--devconf':
- updateDevice()
-
- elif command == '--db':
- resultsList = list()
- withDB()
-
- 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:
-
- initDB()
- resultsList = list()
- if dbStatus == 1:
- server = ServerClassSoftware.ServerHandlerSoftware(34500) #define the port
- tried = server.openSocket(3)
-
- if tried == 'TIMEOUT':
- closeFunction(db,server)
-
- test = server.receiveData(2)
- if test == 'TIMEOUT':
- closeFunction(db,server)
-
- print test
- if test == 'START TEST':
- server.sendData('CONFIRM\n')
- print 'TEST STARTED'
- else:
- sys.exit('WE DIDN\'T RECEIVE THE CONFIRMATION')
-
- 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)
-
- resultsList.append([callFrom, callTo, makeTest.result])
-
- db.errorCode(makeTest.result)
- print 'Result : ' +makeTest.result+ ' ' +db.errCode
-
- message = '|' + str(callFrom) + '|' + str(callTo) + '|' + str(makeTest.result) + '|' + str(db.errCode)
-
- if server.sendData(message+ chr(10)) == 1:
- print 'data sent successfully'
- test = server.receiveData(2)
- if test == 'TIMEOUT':
- closeFunction(db,server)
- print test
- if test == 'CONTINUE':
- print 'continue test'
-
- db.deleteTempTask(taskID)
- i = i+1
-
- db.cleanTasksList()
-
- if server.connected == 1:
- server.sendData('TEST DONE\n')
- test = server.receiveData(2)
-
- 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()
- print '\n'
-
- #initTrueTable(resultsList) # fetch result list and make adjustment about the result
- else:
- print "--- No job at all ---"
- else:
- sys.exit(1)
-
-print db.closeDBConn()
-del db
-del server
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/For Weekly Test/tricode/gsmselftest-website2.py b/For Weekly Test/tricode/gsmselftest-website2.py
index 2e9ecea..7689e53 100755
--- a/For Weekly Test/tricode/gsmselftest-website2.py
+++ b/For Weekly Test/tricode/gsmselftest-website2.py
@@ -7,7 +7,8 @@ import PingClass
import trueTableClass
import initTestClass
import usbDetectClass
-import ServerClassSoftware
+#import ServerClassSoftware
+import ServerClass
from time import sleep
global resultsList
@@ -97,15 +98,13 @@ def doSipTest():
#destList = ['gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm' ]
destList = ['landline', 'unisip']
- print "test"
doTest = initTestClass.doTest()
- print 'iam here'
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
destList = ['GSMRZ1','unisip', 'GSMRZ2','GSMRZ3']
@@ -158,7 +157,7 @@ def regularTest():
def sendResultWebsite(message):
if server.sendData(message+ chr(10)) == 1:
print 'data sent successfully'
- test = server.receiveData(2)
+ test = server.receiveData(5)
if test == 'TIMEOUT':
closeFunction(db,server)
@@ -168,7 +167,7 @@ def sendResultWebsite(message):
def sendFinishMessage():
if server.connected == 1:
server.sendData('TEST DONE\n')
- test = server.receiveData(2)
+ test = server.receiveData(5)
if test == 'TIMEOUT':
closeFunction(db,server)
if test == 'DISCONNECT':
@@ -406,7 +405,7 @@ else:
global tried
initDB() # should put db condition
- server = ServerClassSoftware.ServerHandlerSoftware(34500) #define the port
+ server = ServerClass.ServerHandlerSoftware(34500) #define the port
tried = server.openSocket(10)
if tried == 'TIMEOUT':
diff --git a/For Weekly Test/tricode/gsmselftest.py b/For Weekly Test/tricode/gsmselftest.py
deleted file mode 100755
index 3e82b27..0000000
--- a/For Weekly Test/tricode/gsmselftest.py
+++ /dev/null
@@ -1,783 +0,0 @@
-#! /usr/bin/env python
-import sys
-import ControllerClass
-import DbClass
-import PingClass
-from time import sleep
-
-global resultsList
-resultsList = list()
-
-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 == 'GSMRZ3':
- server = PingClass.Ping('localhost')
- serverStatus = server.ping(1)
-
- elif handler == 'GSMRZ2':
- server = PingClass.Ping('10.4.58.241')
- serverStatus = server.ping(1)
- else:
- serverStatus = 1
-
-def allPing():
-
- global sipGate
- global sipServer
- global unisip
- global gsmBox1
- global gsmBox2
-
- server = PingClass.Ping('sipgate.de')
- sipGate = server.ping(1)
-
- server = PingClass.Ping('132.230.4.8')
- sipServer = server.ping(1)
-
- server = PingClass.Ping('132.230.252.228')
- unisip = server.ping(1)
-
- server = PingClass.Ping('localhost')
- gsmBox1 = server.ping(1)
-
- server = PingClass.Ping('10.4.58.241')
- gsmBox2 = server.ping(1)
-
-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
- global repeatTest
-
- initDB()
-
- if dbStatus != 0:
-
- dest = db.deviceAddress(str(callTo))
-
- caller = db.deviceAddress(str(callFrom))
-
- callAdd = caller[0]
- accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':'
-
- destAdd = dest[0]
- destNo = dest[1]
- accDest = dest[2]+':'+dest[3]+':'+dest[4]+':'
-
- makeTest = ControllerClass.doTheTest(callFrom, callAdd, accCaller, callTo, destAdd, destNo, accDest)
- makeTest.FuncTest()
-
- result = str(makeTest.testResult)
-
- else:
- print "No connection to Database"
-
- return result
-
-def initTrueTable():
- nanoBTS1 = None
- nanoBTS2 = None
- nanoBTS3 = None
- o2Card = None
- eplusCard = None
- vodaCard = None
- tmobileCard = None
- outgoingLandline = None
- asteriskServer = None
-
- for x in resultsList:
-
- destination = x[1]
- result = x[2]
- caller = x[0]
-
- if destination == 'GSMRZ1':
- if result =='486':
- nanoBTS1 = False
- for y in resultsList:
- call = y[0]
- destination = y[1]
- result = y[2]
- if call == 'GSMRZ1':
- if result == '200':
- nanoBTS1 = True
-
- if destination == 'GSMRZ1':
- if result == '200':
- nanoBTS1 = True
- elif result =='200':
- nanoBTS1 = True
-
- elif destination == 'GSMRZ2':
- if result =='486':
- nanoBTS2 = False
- for y in resultsList:
- call = y[0]
- destination = y[1]
- result = y[2]
- if call == 'GSMRZ2':
- if result == '200':
- nanoBTS2 = True
-
- if destination == 'GSMRZ2':
- if result == '200':
- nanoBTS2 = True
- elif result =='200':
- nanoBTS2 = True
-
- elif destination == 'GSMRZ3':
- if result =='486':
- nanoBTS3 = False
- for y in resultsList:
- call = y[0]
- destination = y[1]
- result = y[2]
- if call == 'GSMRZ3':
- if result == '200':
- nanoBTS3 = True
-
- if destination == 'GSMRZ2':
- if result == '200':
- nanoBTS3 = True
- elif result =='200':
- nanoBTS3 = True
-
- elif destination == 'GSMExt.O2':
- if result =='486':
- o2Card = False
- for y in resultsList:
- call = y[0]
- destination = y[1]
- result = y[2]
- if call == 'GSMExt.O2':
- if result == '200':
- o2Card = True
-
- if destination == 'GSMExt.O2':
- if result == '200':
- o2Card = True
- elif result =='200':
- o2Card = True
-
- elif destination == 'GSMExt.Voda':
- if result =='486':
- vodaCard = False
- for y in resultsList:
- call = y[0]
- destination = y[1]
- result = y[2]
- if call == 'GSMExt.Voda':
- if result == '200':
- vodaCard = True
-
- if destination == 'GSMExt.Voda':
- if result == '200':
- vodaCard = True
- elif result =='200':
- vodaCard = True
-
- elif destination == 'GSMExt.Eplus':
- if result =='486':
- eplusCard = False
- for y in resultsList:
- call = y[0]
- destination = y[1]
- result = y[2]
- if call == 'GSMExt.Eplus':
- if result == '200':
- eplusCard = True
-
- if destination == 'GSMExt.Eplus':
- if result == '200':
- eplusCard = True
- elif result =='200':
- eplusCard = True
-
- elif destination == 'GSMExt.Tm':
- if result =='486':
- tmobileCard = False
- for y in resultsList:
- call = y[0]
- destination = y[1]
- result = y[2]
- if call == 'GSMExt.Tm':
- if result == '200':
- tmobileCard = True
-
- if destination == 'GSMExt.Tm':
- if result == '200':
- tmobileCard = True
- elif result =='200':
- tmobileCard = True
-
- elif destination == 'sip':
- if result =='486':
- asteriskServer = False
- for y in resultsList:
- call = y[0]
- destination = y[1]
- result = y[2]
- if call == 'sip':
- if result == '200':
- asteriskServer = True
-
- if destination == 'sip':
- if result == '200':
- asteriskServer = True
-
- elif result =='200':
- asteriskServer = True
-
- if caller == 'GSMRZ1' or caller == 'GSMRZ2' or caller == 'GSMRZ3':
-
- if destination == 'landline':
- if result =='486':
- outgoingLandline = False
- for y in resultsList:
- call = y[0]
- destination = y[1]
- result = y[2]
- if caller == 'GSMRZ1' or caller == 'GSMRZ2' or caller == 'GSMRZ3':
- if destination == 'landline':
- if result == '200':
- outgoingLandline = True
-
- print '\n'
- if o2Card == False and eplusCard == False and vodaCard == False and tmobileCard == False:
- print 'GSM BOX Modem down'
- else:
- if o2Card == False:
- print "O2 card indicate having problem"
- if eplusCard == False:
- print "eplus card indicate having problem"
- if vodaCard == False:
- print "vodaphone card indicate having problem"
- if tmobileCard == False:
- print "T-Mobile card indicate having problem"
- print '\n'
-
- if nanoBTS1 == False and nanoBTS2 == False and nanoBTS3 == False:
- print 'openBSC down'
- else:
- if nanoBTS1 == False:
- print "nanoBTS 1 indicate having problem"
- if nanoBTS2 == False:
- print "nanoBTS 2 indicate having problem"
- if nanoBTS3 == False:
- print "nanoBTS 3 indicate having problem"
-
- if outgoingLandline == False:
- print 'outgoing from GSM RZ to landline having problem'
- print '\n'
-
- if asteriskServer == False:
- print "Asterisk server indicate having problem"
- elif asteriskServer == True:
- print 'Asterisk server working good'
- print '\n'
-
-
-def doTest(callFrom,callTo):
- ping(callFrom)
-
- if serverStatus <> 0:
-
- ping(callTo)
- if serverStatus <> 0:
- print 'Call From : ', callFrom
- print 'Call Destination : ', callTo
- initTest(callFrom,callTo)
- resultsList.append([callFrom, callTo, result])
- db.errorCode(result)
- print 'Result : ' +result+ ' ' +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 = ['gsmr1','gsmr2', 'gsmr3', 'landline', 'unisip', 'GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm' ]
- for callTo in destList:
-
- callFrom = 'sip'
- doTest(callFrom, callTo)
-
-def doLandlineTest():
-
- print '--Landline Part Test--'
- destList = ['GSMRZ1','unisip', 'sip']
-
- for callTo in destList:
-
- callFrom = 'landline'
- doTest(callFrom, callTo)
-
-def doGsmrzTest():
-
- print '--GSM Part Test--'
- destList = ['GSMRZ1','GSMRZ2', 'GSMRZ3']
- callList = ['sip']
-
- for callFrom in callList:
-
- for callTo in destList:
- doTest(callFrom, callTo)
- resultsList.append([callFrom, callTo, result])
- initTrueTable()
-
-def doGsmExtTest():
-
- destList = ['GSMExt.O2', 'GSMExt.Voda', 'GSMExt.Eplus', 'GSMExt.Tm']
- callList = ['sip']
-
- for callFrom in callList:
- for callTo in destList:
- doTest(callFrom, callTo)
- resultsList.append([callFrom, callTo, result])
- initTrueTable()
-
-def doAllTest():
-
- doSipTest()
- doLandlineTest()
- doGsmrzTest()
- doGsmExtTest()
-
-def smartTest():
- ping('sip')
- if serverStatus == 0:
- print "Dont have connection to SIP Asterisk server, can't make a test"
- sys.exit(1)
-
- callerList = ['sip']
- destinationList = ['SIP', 'GSMExt']
- #destinationList = ['GSMExt', 'GSMRZ', 'SIP', 'RZOutgoing', 'RZincoming']
- for callFrom in callerList:
- for destination in destinationList:
-
- if destination == 'GSMRZ':
- print "make a call to GSMRZ1"
- initTest(callFrom,'GSMRZ1')
-
- if result == '200':
- print "make a call to GSMRZ2"
- initTest(callFrom,'GSMRZ2')
-
- if result == '200':
- print "make a call to GSMRZ3"
- initTest(callFrom,'GSMRZ3')
-
- if result == '200':
- print "all network on GSMRZ are working"
- elif result == '486':
- print "BTS 3 Down"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
- print "make a call to GSMRZ3"
- initTest(callFrom,'GSMRZ3')
-
- if result == '200':
- print "BTS 2 Down"
- elif result == '486':
- print "BTS 2 and 3 indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
- print "make a call to GSMRZ2"
- initTest(callFrom,'GSMRZ2')
-
- if result == '200':
- print "make a call to GSMRZ3"
- initTest(callFrom,'GSMRZ3')
-
- if result == '200':
- print "BTS 1 Down"
- elif result == '486':
- print "BTS 1 & 3 indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
- print "make a call to GSMRZ3"
-
- if result == '200':
- print "BTS 1 & 2 indicate having problem"
- elif result == '486':
- print "OpenBSc Down"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
-
- elif destination == 'GSMExt':
-
- initTest(callFrom,'GSMExt.O2')
- if result == '200':
-
- initTest(callFrom,'GSMExt.Voda')
- if result == '200':
-
- initTest(callFrom,'GSMExt.Eplus')
- if result == '200':
-
- initTest(callFrom,'GSMExt.Tm')
- if result == '200':
- print "All network on GSM external are working"
- elif result == '486':
- print "T-Mobile card indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
-
- initTest(callFrom,'GSMExt.Tm')
- if result == '200':
- print "E-Plus card indicate having problem"
- elif result == '486':
- print "T-Mobile and E-Plus card indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
-
- initTest(callFrom,'GSMExt.Eplus')
- if result == '200':
-
- initTest(callFrom,'GSMExt.Tm')
- if result == '200':
- print "Vodaphone card indicate having problem"
- elif result == '486':
- print "T-Mobile and Vodaphone cards indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
-
- initTest(callFrom,'GSMExt.Tm')
- if result == '200':
- print "Vodaphone and E-Plus card indicate having problem"
- elif result == '486':
- print "T-Mobile, E-Plus and Vodaphone cards indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "Incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
-
- initTest(callFrom,'GSMExt.Voda')
- if result == '200':
-
- initTest(callFrom,'GSMExt.Eplus')
- if result == '200':
-
- initTest(callFrom,'GSMExt.Tm')
- if result == '200':
- print "O2 card indicate having problem"
- elif result == '486':
- print "T-Mobile and O2 cards indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
-
- initTest(callFrom,'GSMExt.Tm')
- if result == '200':
- print "O2 and E-Plus cards indicate having problem"
- elif result == '486':
- print "T-Mobile, E-Plus and O2 cards indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
-
- initTest(callFrom,'GSMExt.Eplus')
- if result == '200':
-
- initTest(callFrom,'GSMExt.Tm')
- if result == '200':
- print "O2 and Vodaphone cards indicate having problem"
- elif result == '486':
- print "T-Mobile, O2 and Vodaphone cards indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '486':
-
- initTest(callFrom,'GSMExt.Tm')
- if result == '200':
- print "O2, E-Plus and Vodaphone cards indicate having problem"
- elif result == '486':
- print "GSM External Modem Down"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif destination == 'SIP':
-
- ping('landline')
- if serverStatus <> 0:
- initTest(callFrom,'landline')
-
- if result == '200':
- ping('unisip')
- if serverStatus <> 0:
- initTest(callFrom,'unisip')
-
- if result =='200':
- print "All SIP network are working"
- elif result == '486':
- print "University telephone network indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "No connection to University telephone network server, check your connection"
-
- elif result == '486':
- ping('unisip')
- if serverStatus <> 0:
- initTest(callFrom,'unisip')
-
- if result == '200':
- print "Landline indicate having problem"
- elif result == '486':
- print "SIP Network Down"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "No connection to University telephone network server, check your connection"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "No connection to SIP Gate server, check your connection"
-
- elif destination == 'RZOutgoing':
-
- ping('landline')
- if serverStatus <> 0:
- initTest('GSMRZ1','landline')
-
- if result == '200':
- ping('unisip')
- if serverStatus <> 0:
- initTest('GSMRZ1','unisip')
-
- if result =='200':
- print "Outgoing call from GSM RZ is working"
-
- elif result == '486':
- print "Outgoing call from GSM RZ to UTN indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "No connection to University telephone network server, check your connection"
-
- elif result == '486':
- ping('unisip')
- if serverStatus <> 0:
- initTest('GSMRZ1','unisip')
-
- if result == '200':
- print "Outgoing call from GSM RZ to Landline indicate having problem"
-
- elif result == '486':
- print "Outgoing call from GSM RZ to Landline and UTN indicate having problem"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "No connection to University telephone network server, check your connection"
- else:
- print "incomplete test, Handler having error, please do one more test"
- else:
- print "No connection to SIP Gate server, check your connection"
-
- elif destination == 'RZincoming':
-
- ping('landline')
- if serverStatus <> 0:
- initTest('landline', 'GSMRZ1')
-
- if result == '486':
-
- initTest('GSMExt.O2','GSMRZ1')
-
- if result =='200':
- print "incoming call to GSM RZ working"
-
- elif result == '486':
-
- initTest('GSMExt.Voda','GSMRZ1')
- if result =='200':
- print "incoming call to GSM RZ working"
- elif result == '486':
- print "incoming call to GSM RZ notworking"
- else:
- print "incomplete test, GSM Handler having error, please do one more test"
- else:
- print "incomplete test, Handler having error, please do one more test"
-
- elif result == '200':
- print "incoming call to GSM RZ working"
- else:
- print "No connection to SIP Gate server, check your connection"
-
-
-if len(sys.argv) > 1:
-
- command = sys.argv[1]
- print ' '
-
- if command == '--all':
- doAllTest()
-
- elif command == '--sip':
- doSipTest()
-
- elif command == '--gsmrz':
- doGsmrzTest()
-
- elif command == '--gsmext':
- doGsmExtTest()
-
- elif command == '--landline':
- doLandlineTest()
-
- elif command == '--smart':
- smartTest()
-
- 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:
-
- initDB()
- if dbStatus == 1:
-
- if db.anyTasksToDo() == 1:
-
- #allPing()
- i=0
- 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
-
- ping(callFrom)
-
- if serverStatus <> 0:
-
- ping(callTo)
- if serverStatus <> 0:
-
- initTest(callFrom,callTo)
-
- db.addResult(taskID, result)
-
- resultsList.append([callFrom, callTo, result])
-
- db.errorCode(result)
- print 'Result : ' +result+ ' ' +db.errCode
-
- db.deleteTempTask(taskID)
- 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()
-
- # fetch result list and make adjustment about the result
- print '\n'
- initTrueTable()
- else:
- print "--- No job at all ---"
- else:
- sys.exit(1)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/For Weekly Test/tricode/serialTest.py b/For Weekly Test/tricode/serialTest.py
deleted file mode 100755
index c39c80d..0000000
--- a/For Weekly Test/tricode/serialTest.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import time
-from serial import *
-
-# configure the serial connections (the parameters differs on the device you are connecting to)
-ser = Serial(
- port='/dev/ttyUSB1',
- baudrate=19200,
- bytesize=EIGHTBITS,
- parity=PARITY_NONE,
- stopbits=STOPBITS_ONE
-)
-
-ser.open()
-ser.isOpen()
-
-print 'Enter your commands below.\r\nInsert "exit" to leave the application.'
-
-input=1
-while 1 :
- # get keyboard input
- input = raw_input(">> ")
- # Python 3 users
- # input = input(">> ")
- if input == 'exit':
- ser.close()
- exit()
- else:
- # send the character to the device
- # (note that I happend a \r\n carriage return and line feed to the characters - this is requested by my device)
- ser.write(input + '\r\n')
- out = ''
- # let's wait one second before reading output (let's give device time to answer)
- time.sleep(1)
- while ser.inWaiting() > 0:
- out += ser.read(1)
-
- if out != '':
- print ">>" + out
diff --git a/For Weekly Test/tricode/sshtest.py b/For Weekly Test/tricode/sshtest.py
deleted file mode 100755
index f18139e..0000000
--- a/For Weekly Test/tricode/sshtest.py
+++ /dev/null
@@ -1,15 +0,0 @@
-import sys
-import os
-import subprocess
-import SSHTunnelBox1Class
-import SSHTunnelBox2Class
-import ClientClass
-from time import sleep
-
-portDest = 46000#should be 9
-box2 = SSHTunnelBox2Class.SSHTunneling(portDest, 50008, '132.230.4.67', 'lsfks', 'r')#ip??
-print box2.startTunneling()
-#sleep(2)
-receiver = ClientClass.Connection('localhost', portDest)
-print receiver.connect()
-box2.killTunneling()