From 310e98501ed13c8fae7bdc53b8c96b8d326c34e9 Mon Sep 17 00:00:00 2001 From: tt41 Date: Mon, 5 Sep 2011 01:34:27 +0200 Subject: add gsm device detecting feature --- For Weekly Test/12-09-2011/ClientClass.pyc | Bin 3655 -> 3601 bytes For Weekly Test/12-09-2011/ControllerClass.py | 55 +++--- For Weekly Test/12-09-2011/ControllerClass.pyc | Bin 7773 -> 7701 bytes For Weekly Test/12-09-2011/DbClass.py | 15 +- For Weekly Test/12-09-2011/DbClass.pyc | Bin 5743 -> 6209 bytes For Weekly Test/12-09-2011/LogFileClass.pyc | Bin 1524 -> 1494 bytes For Weekly Test/12-09-2011/PingClass.pyc | Bin 1275 -> 1251 bytes For Weekly Test/12-09-2011/SSHTunnelBox1Class.pyc | Bin 1786 -> 1756 bytes For Weekly Test/12-09-2011/SSHTunnelBox2Class.pyc | Bin 1786 -> 1756 bytes For Weekly Test/12-09-2011/devicePortList.log | 4 - For Weekly Test/12-09-2011/dmesg.log | 60 ------ For Weekly Test/12-09-2011/gsmselftest1.py | 62 ++++++- For Weekly Test/12-09-2011/help.txt | 3 + For Weekly Test/12-09-2011/initTestClass.py | 9 +- For Weekly Test/12-09-2011/initTestClass.pyc | Bin 7836 -> 7794 bytes For Weekly Test/12-09-2011/inserttest.py | 28 --- For Weekly Test/12-09-2011/trueTableClass.pyc | Bin 3344 -> 3320 bytes For Weekly Test/12-09-2011/truetable.py | 211 ---------------------- For Weekly Test/12-09-2011/usbDetect.py | 156 ---------------- For Weekly Test/12-09-2011/usbDetectClass.py | 78 ++++++++ For Weekly Test/12-09-2011/usbDetectClass.pyc | Bin 0 -> 3128 bytes 21 files changed, 186 insertions(+), 495 deletions(-) delete mode 100644 For Weekly Test/12-09-2011/devicePortList.log delete mode 100644 For Weekly Test/12-09-2011/dmesg.log delete mode 100644 For Weekly Test/12-09-2011/inserttest.py delete mode 100644 For Weekly Test/12-09-2011/truetable.py delete mode 100644 For Weekly Test/12-09-2011/usbDetect.py create mode 100644 For Weekly Test/12-09-2011/usbDetectClass.py create mode 100644 For Weekly Test/12-09-2011/usbDetectClass.pyc (limited to 'For Weekly Test') diff --git a/For Weekly Test/12-09-2011/ClientClass.pyc b/For Weekly Test/12-09-2011/ClientClass.pyc index 6dcbc7f..accb309 100644 Binary files a/For Weekly Test/12-09-2011/ClientClass.pyc and b/For Weekly Test/12-09-2011/ClientClass.pyc differ diff --git a/For Weekly Test/12-09-2011/ControllerClass.py b/For Weekly Test/12-09-2011/ControllerClass.py index 3b9ca62..67356ff 100644 --- a/For Weekly Test/12-09-2011/ControllerClass.py +++ b/For Weekly Test/12-09-2011/ControllerClass.py @@ -13,25 +13,20 @@ from time import sleep class doTheTest: - def __init__(self, callFrom, callAdd, accCaller, callTo, destAdd, destNo, accDest): + def __init__(self, callFrom, callPortName, accCaller, callTo, destPortName, destNo, accDest): self.callFrom = callFrom self.dest = callTo self.destNo = destNo self.accDest = accDest self.accCaller = accCaller - self.portAdd = None + self.callPortName = callPortName + self.destPortName = destPortName self.portCaller = None self.portDest = None self.resultCaller = None self.resultDest = None self.testResult = None - self.callAdd = callAdd - self.recAdd = destAdd - self.receiver = None - self.caller = None - self.connected = None - def FuncTest(self): @@ -117,8 +112,8 @@ class doTheTest: if self.callFrom =="GSMRZ1": self.portCaller = 50007 - self.portAdd = '/dev/ttyUSB4' - self.initGSM(self.portCaller, self.portAdd) + #self.portAdd = '/dev/ttyUSB4' + self.initGSM(self.portCaller, self.callPortName) elif self.callFrom =="GSMRZ2": self.portCaller = 40000 @@ -132,23 +127,23 @@ class doTheTest: elif self.callFrom =="GSMExt.O2": self.portCaller = 50010 - self.portAdd = '/dev/ttyUSB0' - self.initGSM(self.portCaller, self.portAdd) + #self.portAdd = '/dev/ttyUSB0' + self.initGSM(self.portCaller, self.callPortName) elif self.callFrom =="GSMExt.Voda": self.portCaller = 50011 - self.portAdd = '/dev/ttyUSB1' - self.initGSM(self.portCaller, self.portAdd) + #self.portAdd = '/dev/ttyUSB1' + self.initGSM(self.portCaller, self.callPortName) elif self.callFrom =="GSMExt.Tm": self.portCaller = 50012 - self.portAdd = '/dev/ttyUSB3' - self.initGSM(self.portCaller, self.portAdd) + #self.portAdd = '/dev/ttyUSB3' + self.initGSM(self.portCaller, self.callPortName) elif self.callFrom =="GSMExt.Eplus": self.portCaller = 50013 - self.portAdd = '/dev/ttyUSB2' - self.initGSM(self.portCaller, self.portAdd) + #self.portAdd = '/dev/ttyUSB2' + self.initGSM(self.portCaller, self.callPortName) else: self.portCaller = 50099 @@ -160,8 +155,8 @@ class doTheTest: if self.dest =="GSMRZ1": self.portDest = 50007 - self.portAdd = '/dev/ttyUSB4' - self.initGSM(self.portDest, self.portAdd) + #self.portAdd = '/dev/ttyUSB4' + self.initGSM(self.portDest, self.destPortName) elif self.dest =="GSMRZ2": self.portDest = 40000 @@ -176,23 +171,23 @@ class doTheTest: elif self.dest =="GSMExt.O2": self.portDest = 50010 - self.portAdd = '/dev/ttyUSB0' - self.initGSM(self.portDest, self.portAdd) + #self.portAdd = '/dev/ttyUSB0' + self.initGSM(self.portDest, self.destPortName) elif self.dest =="GSMExt.Voda": self.portDest = 50011 - self.portAdd = '/dev/ttyUSB1' - self.initGSM(self.portDest, self.portAdd) + #self.portAdd = '/dev/ttyUSB1' + self.initGSM(self.portDest, self.destPortName) elif self.dest =="GSMExt.Tm": self.portDest = 50012 - self.portAdd = '/dev/ttyUSB3' - self.initGSM(self.portDest, self.portAdd) + #self.portAdd = '/dev/ttyUSB3' + self.initGSM(self.portDest, self.destPortName) elif self.dest =="GSMExt.Eplus": self.portDest = 50013 - self.portAdd = '/dev/ttyUSB2' - self.initGSM(self.portDest, self.portAdd) + #self.portAdd = '/dev/ttyUSB2' + self.initGSM(self.portDest, self.destPortName) else: self.portDest = 50100 @@ -208,7 +203,7 @@ class doTheTest: def callerGreeting(self): self.connected = None - self.caller = ClientClass.Connection(self.callAdd,self.portCaller) + self.caller = ClientClass.Connection('localhost',self.portCaller) self.caller.connect() if self.caller.connected == 1: @@ -223,7 +218,7 @@ class doTheTest: def receiverGreeting(self): self.connected = None - self.receiver = ClientClass.Connection(self.recAdd, self.portDest) + self.receiver = ClientClass.Connection('localhost', self.portDest) self.receiver.connect() if self.receiver.connected == 1: diff --git a/For Weekly Test/12-09-2011/ControllerClass.pyc b/For Weekly Test/12-09-2011/ControllerClass.pyc index d9a57de..c82c11c 100644 Binary files a/For Weekly Test/12-09-2011/ControllerClass.pyc and b/For Weekly Test/12-09-2011/ControllerClass.pyc differ diff --git a/For Weekly Test/12-09-2011/DbClass.py b/For Weekly Test/12-09-2011/DbClass.py index d312b63..3e4a610 100644 --- a/For Weekly Test/12-09-2011/DbClass.py +++ b/For Weekly Test/12-09-2011/DbClass.py @@ -12,6 +12,7 @@ class DBMySQLConnection: self.tasksList = list() self.callerLists = list() self.errCode = None + self.deviceUpdate = None global debugMode debugMode = 0 @@ -97,7 +98,7 @@ class DBMySQLConnection: 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) + successful = self.cur.execute("SELECT `portName`,`number`, `username`, `password`, `server` FROM DeviceAddressTable where `deviceName`=%s", deviceName) output = self.cur.fetchall() deviceAddr = '' for record in output: @@ -117,6 +118,18 @@ class DBMySQLConnection: else: return 0 #I am not connected + def updateGSMDevice(self, deviceName, newPortName, newNumber): + if self.connectionCreated == 1: + try: + stmt = "UPDATE DeviceAddressTable SET portName = '"+ newPortName + "', number = '"+ newNumber+ "' WHERE deviceName = '" + deviceName+ "'" + self.cur.execute(stmt) + + except MySQLdb.Error, e: + if debugMode == 1: + print str(e) + return 3 + else: + return 0 def updatePingResult(self, taskNo, sipServer, sipGate, unisip, gsmBox1, gsmBox2): if self.connectionCreated == 1: diff --git a/For Weekly Test/12-09-2011/DbClass.pyc b/For Weekly Test/12-09-2011/DbClass.pyc index 080f612..c11920d 100644 Binary files a/For Weekly Test/12-09-2011/DbClass.pyc and b/For Weekly Test/12-09-2011/DbClass.pyc differ diff --git a/For Weekly Test/12-09-2011/LogFileClass.pyc b/For Weekly Test/12-09-2011/LogFileClass.pyc index 697f94a..a6c449f 100644 Binary files a/For Weekly Test/12-09-2011/LogFileClass.pyc and b/For Weekly Test/12-09-2011/LogFileClass.pyc differ diff --git a/For Weekly Test/12-09-2011/PingClass.pyc b/For Weekly Test/12-09-2011/PingClass.pyc index c611576..b9e0427 100644 Binary files a/For Weekly Test/12-09-2011/PingClass.pyc and b/For Weekly Test/12-09-2011/PingClass.pyc differ diff --git a/For Weekly Test/12-09-2011/SSHTunnelBox1Class.pyc b/For Weekly Test/12-09-2011/SSHTunnelBox1Class.pyc index 4512f04..ca1f91d 100644 Binary files a/For Weekly Test/12-09-2011/SSHTunnelBox1Class.pyc and b/For Weekly Test/12-09-2011/SSHTunnelBox1Class.pyc differ diff --git a/For Weekly Test/12-09-2011/SSHTunnelBox2Class.pyc b/For Weekly Test/12-09-2011/SSHTunnelBox2Class.pyc index 6afa570..3ea6058 100644 Binary files a/For Weekly Test/12-09-2011/SSHTunnelBox2Class.pyc and b/For Weekly Test/12-09-2011/SSHTunnelBox2Class.pyc differ diff --git a/For Weekly Test/12-09-2011/devicePortList.log b/For Weekly Test/12-09-2011/devicePortList.log deleted file mode 100644 index 984e53e..0000000 --- a/For Weekly Test/12-09-2011/devicePortList.log +++ /dev/null @@ -1,4 +0,0 @@ - -[O2] [/dev/ttyUSB0][015782677224] - -[Voda] [/dev/ttyUSB1][015128040906] diff --git a/For Weekly Test/12-09-2011/dmesg.log b/For Weekly Test/12-09-2011/dmesg.log deleted file mode 100644 index e2055e9..0000000 --- a/For Weekly Test/12-09-2011/dmesg.log +++ /dev/null @@ -1,60 +0,0 @@ -[ 5587.149816] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[ 5700.233641] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[ 5736.494612] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[ 6294.456248] usb 2-1.1: pl2303 converter now attached to ttyUSB0 -[ 7701.796802] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[ 8875.087711] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[ 9604.128581] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[19245.501608] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[28935.537926] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[29468.049557] usb 2-1.2: pl2303 converter now attached to ttyUSB1 -[53001.536734] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[53492.965185] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[54654.354061] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[54700.573748] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[54793.269884] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[54879.326084] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[54946.740773] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[54991.776299] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[55003.275043] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55023.959080] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55083.715582] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55236.634679] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[55261.778953] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55387.169610] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[55394.566623] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55532.205311] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[55541.653714] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55625.337125] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[55629.754681] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55729.322986] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[55738.791674] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55786.543594] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[55797.525001] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55800.077695] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[55884.223141] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[55946.398959] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[56053.650388] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[56059.014012] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[56128.765774] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[56209.894827] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[56221.896790] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[56253.560921] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[56304.888132] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[56358.518151] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[56367.452069] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[56585.720263] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[56621.554815] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[56634.019998] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[56727.181276] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[56747.247817] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[58487.933271] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[58542.572335] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[58552.088611] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[58586.138617] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[58592.578748] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[58613.454682] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[58621.430555] usb 2-1.4: pl2303 converter now attached to ttyUSB1 -[58655.469278] usb 2-1.4: pl2303 converter now attached to ttyUSB0 -[58853.604655] usb 2-1.2: pl2303 converter now attached to ttyUSB0 -[58861.712086] usb 2-1.4: pl2303 converter now attached to ttyUSB1 diff --git a/For Weekly Test/12-09-2011/gsmselftest1.py b/For Weekly Test/12-09-2011/gsmselftest1.py index aa72974..81d23cf 100644 --- a/For Weekly Test/12-09-2011/gsmselftest1.py +++ b/For Weekly Test/12-09-2011/gsmselftest1.py @@ -1,15 +1,19 @@ #! /usr/bin/env python -import sys +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']] + def allPing(): @@ -138,6 +142,59 @@ def regularTest(): regulartest = initTestClass.doTheTest() regulartest.smartTest() +def findPort(portName): + 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 updateDevice(): + + while True: + print "Mobile device configuration" + print "Menu: s = start device configuration, q = quit" + + input = sys.stdin.readline().rstrip("\r\n") + print '' + if input == 's': + i = 0 + while i !=10: + portName ='ttyUSB'+str(i) + findPort(portName) + i=i+1 + if connect == 1: + for listNum in GSMListPrefix: + if prefix == listNum[1]: + print 'Device Name :', listNum[0] + print 'IME :',IMEI + print 'Phone Number :',num + print 'Port Name : /dev/'+portName + + newPortName = '/dev/'+portName + portClass.initUpdate(listNum[0], newPortName, num) + print '\n' + + + + if input == "q": + break + sys.exit() + if len(sys.argv) > 1: command = sys.argv[1] @@ -161,6 +218,9 @@ if len(sys.argv) > 1: elif command == '--smart': regularTest() + elif command == '--devconf': + updateDevice() + elif command == '--help': file = open('help.txt', 'r') print file.read() diff --git a/For Weekly Test/12-09-2011/help.txt b/For Weekly Test/12-09-2011/help.txt index b059180..5a9062e 100644 --- a/For Weekly Test/12-09-2011/help.txt +++ b/For Weekly Test/12-09-2011/help.txt @@ -10,3 +10,6 @@ Options and arguments (and corresponding environment variables): --gsmext : To check whether GSM BOX modem having problem or not --landline : To check incoming call from Landline --smart : To test only important point in the network and identify which part having problem. +--devconf : To configuration USB device + + example : gsmselftest.py --devconf diff --git a/For Weekly Test/12-09-2011/initTestClass.py b/For Weekly Test/12-09-2011/initTestClass.py index 97fdfee..1846cd6 100644 --- a/For Weekly Test/12-09-2011/initTestClass.py +++ b/For Weekly Test/12-09-2011/initTestClass.py @@ -65,14 +65,14 @@ class doTheTest: if self.status == 1: self.initaccount(dest,callTo) if self.status == 1: - callAdd = caller[0] + callPortAdd = caller[0] accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':' - destAdd = dest[0] + destPortAdd = dest[0] destNo = dest[1] accDest = dest[2]+':'+dest[3]+':'+dest[4]+':' - makeTest = ControllerClass.doTheTest(callFrom, callAdd, accCaller, callTo, destAdd, destNo, accDest) + makeTest = ControllerClass.doTheTest(callFrom, callPortAdd, accCaller, callTo, destPortAdd, destNo, accDest) makeTest.FuncTest() self.result = str(makeTest.testResult) else: @@ -298,7 +298,8 @@ class doTheTest: if self.serverStatus <> 0: self.initTest('GSMRZ1','unisip') if self.result =='200': - print "Outgoing call from GSM RZ is working" elif self.result == '486': + print "Outgoing call from GSM RZ is working" + elif self.result == '486': print "Outgoing call from GSM RZ to UTN indicate having problem" else: print handlerError diff --git a/For Weekly Test/12-09-2011/initTestClass.pyc b/For Weekly Test/12-09-2011/initTestClass.pyc index 5ef4246..38b537f 100644 Binary files a/For Weekly Test/12-09-2011/initTestClass.pyc and b/For Weekly Test/12-09-2011/initTestClass.pyc differ diff --git a/For Weekly Test/12-09-2011/inserttest.py b/For Weekly Test/12-09-2011/inserttest.py deleted file mode 100644 index 4987242..0000000 --- a/For Weekly Test/12-09-2011/inserttest.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -import MySQLdb as mdb -import sys - -try: - conn = mdb.connect('localhost', 'root', 'randompasswordSQL', 'gsmselftesting') - - cursor = conn.cursor() - - cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('1', '2', 'sip', 'GSMExt.O2', '0')") - cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('2', '2', 'sip', 'GSMExt.Voda', '0')") - cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('3', '2', 'sip', 'GSMExt.Tm', '0')") - cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('4', '2', 'sip', 'GSMExt.Eplus', '0')") - cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('5', '2', 'sip', 'landline', '0')") - #cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('6', '2', 'sip', 'unisip', '0')") - #cursor.execute("INSERT INTO TempTaskTable(`taskID`, `taskNo`, `from`, `to`,`status` ) VALUES('7', '2', 'unisip', 'sip', '0')") - - conn.commit() - - cursor.close() - conn.close() - -except mdb.Error, e: - - print "Error %d: %s" % (e.args[0],e.args[1]) - sys.exit(1) diff --git a/For Weekly Test/12-09-2011/trueTableClass.pyc b/For Weekly Test/12-09-2011/trueTableClass.pyc index 7e8d751..94dea9d 100644 Binary files a/For Weekly Test/12-09-2011/trueTableClass.pyc and b/For Weekly Test/12-09-2011/trueTableClass.pyc differ diff --git a/For Weekly Test/12-09-2011/truetable.py b/For Weekly Test/12-09-2011/truetable.py deleted file mode 100644 index 6675ccd..0000000 --- a/For Weekly Test/12-09-2011/truetable.py +++ /dev/null @@ -1,211 +0,0 @@ -def initTrueTable(): - - resultsList = [['sip', 'GSMExt.Eplus', '486'], ['unisip', 'GSMExt.Tm', '486'], ['sip', 'GSMExt.O2', '200'], ['landline', 'GSMExt.Voda', '486'], ['sip', 'landline', '486'], ['sip', 'unisip', '200'], ['unisip', 'sip', '486'], ['GSMRZ1','landline', '486'], ['GSMRZ2','landline' ,'486'], ['GSMRZ3','landline', '486']] - #resultsList = [['GSMExt.Eplus', 'GSMRZ1', '486'], ['unisip', 'sip', '486'], ['landline', 'sip', '200'], ['unisip', 'sip', '486']] - - nanoBTS1 = None - nanoBTS2 = None - nanoBTS3 = None - o2Card = None - eplusCard = None - vodaCard = None - tmobileCard = None - outgoingLandline = 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' - -initTrueTable() - - - - - diff --git a/For Weekly Test/12-09-2011/usbDetect.py b/For Weekly Test/12-09-2011/usbDetect.py deleted file mode 100644 index 695b59c..0000000 --- a/For Weekly Test/12-09-2011/usbDetect.py +++ /dev/null @@ -1,156 +0,0 @@ -from serial import * #serial port library -from time import sleep -import sys -import checkingNumberClass - -def initLog(): - sleep(0.5) - portLog = os.popen('dmesg | grep \'pl2303 converter now attached to ttyUSB\'').read() - sleep(0.5) - dmesgfile = open('dmesg.log', 'w') - dmesgfile.write(portLog) - dmesgfile.close() - -def initLine(): - global i - logfile = open('dmesg.log') - i = 0 - while 1: - line = logfile.readline() - if not line: - break - i = i+1 - logfile.close() - -def initPort(): - global lines - x = 0 - logfile = open('dmesg.log') - while 1: - line = logfile.readline() - x = x+1 - if not line: - break - if x == i: - lines = line - logfile.close() - print lines - -def newConf(device): - x = checkingNumberClass.serialPort(port) - x.findNumber() - number = x.number - - portDev = '[/dev/'+port+']' - file.write('\n['+device+'] ') - file.writelines(portDev) - file.writelines('['+number+']\n') - -def searchList(): - global found - for item in portList: - if item[1] == port: - found = 1 - else: - found = 0 -def initO2(): - - print "pluged in, O2 Mobile Device [then Enter]" - input = sys.stdin.readline().rstrip("\r\n") - scanPort() - portList.append(['O2', port]) - newConf('O2') - -def initVoda(): - - print "pluged in, Vodaphone Mobile Device [then Enter]" - input = sys.stdin.readline().rstrip("\r\n") - scanPort() - searchList() - if found == 1: - initRepeat() - elif found == 0: - portList.append(['Voda', port]) - newConf('Voda') - elif repeat == True: - initVoda() - -def initEplus(): - print "pluged in, Eplus Mobile Device [then Enter]" - input = sys.stdin.readline().rstrip("\r\n") - scanPort() - searchList() - if found == 1: - initRepeat() - elif found == 0: - portList.append(['Eplus', port]) - newConf('Eplus') - elif repeat == True: - initEplus() - -def initTmobile(): - - print "pluged in, T-Mobile Mobile Device [then Enter]" - input = sys.stdin.readline().rstrip("\r\n") - scanPort() - searchList() - if found == 1: - initRepeat() - if found == 0: - portList.append(['Tm', port]) - newConf('Tm') - if repeat == True: - initTmobile() - -def initRepeat(): - global repeat - while True: - print 'No new device has pluged in' - print 't = try again, i = ignore, q = quit' - input = sys.stdin.readline().rstrip("\r\n") - if input == 'i': - repeat = False - break - elif input == 'q': - file.close() - sys.exit() - elif input == 't': - repeat = True - break - -def scanPort(): - global port - initLog() - initLine() - initPort() - port = str(lines[59:66]) - - -global file -global portList -portList = list() -while True: - print "Mobile device port configuration" - print "Menu: n = make new configuration, q = quit" - - input = sys.stdin.readline().rstrip("\r\n") - if input == "n": - file = open('devicePortList.log', 'w') - print "== Pluged Out all mobile devices [then Enter] ==" - input = sys.stdin.readline().rstrip("\r\n") - - initO2() - initVoda() - initEplus() - initTmobile() - - file.close() - - if input == "q": - break -sys.exit() - - - - - diff --git a/For Weekly Test/12-09-2011/usbDetectClass.py b/For Weekly Test/12-09-2011/usbDetectClass.py new file mode 100644 index 0000000..af438c7 --- /dev/null +++ b/For Weekly Test/12-09-2011/usbDetectClass.py @@ -0,0 +1,78 @@ +from serial import * #serial port library +import sys +from time import sleep +import DbClass + + +class serialPort: + + def __init__(self, portAddress): + self.portAddress = portAddress + self.portExist = 0 + self.IMEI = 'IME not found' + self.number = 'number not found' + self.updateStatus = None + + def initDB(self): + self.db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting') + self.db.connectDB() + self.dbStatus = self.db.connectDB() + + def initUpdate(self, deviceName, newPortName, newNumber): + self.initDB() + + if self.dbStatus != 0: + self.db.updateGSMDevice(deviceName, newPortName, newNumber) + else: + print 'No connection to database' + + def portInit(self): + self.portExist = 0 + try: + self.ser = Serial( + port='/dev/'+self.portAddress, + baudrate=19200, + bytesize=EIGHTBITS, + parity=PARITY_NONE, + stopbits=STOPBITS_ONE) + self.ser.open() + self.ser.isOpen() + self.portExist = 1 + + except Exception, e: + print 'error' + return 0 + + def findIMEI(self): + self.portInit() + if self.portExist == 1: + self.ser.flushInput() #clean the input buffer for serial port + self.ser.write('AT+GSN\r') + sleep(0.5) + self.IMEI = int(self.ser.read(20)) + else: + self.IMEI = 'port not found' + return 0 + def findNumber(self): + self.portInit() + + if self.portExist == 1: + self.ser.flushInput() #clean the input buffer for serial port + self.ser.write('AT+CNUM\r') + sleep(0.5) + readNum = self.ser.read(35) + + self.ser.close() + firstQuote = readNum.find('"') + cutString = readNum [firstQuote:] + secondQuote = cutString.find(',') + number = cutString[1:secondQuote-1] + + if number != '': + self.number = number + else: + self.number = 'number not found' + + else: + self.number = 'port not found' + return 0 diff --git a/For Weekly Test/12-09-2011/usbDetectClass.pyc b/For Weekly Test/12-09-2011/usbDetectClass.pyc new file mode 100644 index 0000000..6952586 Binary files /dev/null and b/For Weekly Test/12-09-2011/usbDetectClass.pyc differ -- cgit v1.2.3-55-g7522