From 6a1abfac914ad28486ff468b4c63f305e49858e5 Mon Sep 17 00:00:00 2001 From: tt41 Date: Mon, 5 Sep 2011 01:35:23 +0200 Subject: moving file. --- For Weekly Test/Backup/checkingNumberClass.py | 79 ++++++++++ For Weekly Test/Backup/inserttest.py | 28 ++++ For Weekly Test/Backup/truetable.py | 211 ++++++++++++++++++++++++++ For Weekly Test/Backup/usbDetect.py | 156 +++++++++++++++++++ 4 files changed, 474 insertions(+) create mode 100644 For Weekly Test/Backup/checkingNumberClass.py create mode 100644 For Weekly Test/Backup/inserttest.py create mode 100644 For Weekly Test/Backup/truetable.py create mode 100644 For Weekly Test/Backup/usbDetect.py (limited to 'For Weekly Test/Backup') diff --git a/For Weekly Test/Backup/checkingNumberClass.py b/For Weekly Test/Backup/checkingNumberClass.py new file mode 100644 index 0000000..c5f9fc3 --- /dev/null +++ b/For Weekly Test/Backup/checkingNumberClass.py @@ -0,0 +1,79 @@ +from serial import * #serial port library +import sys +from time import sleep + +class serialPort: + + def __init__(self, portAddress): + self.portAddress = portAddress + self.number = 'number not found' + + 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.ser.flushInput() + self.portExist = 1 + + except Exception, e: + 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.ser.flushInput() + self.portExist = 1 + + except Exception, e: + 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 + + def findIME(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.IME = int(self.ser.read(20)) + + if self.IME = '': + self.IME = 'IME Error, not found' + else: + self.IME = 'port not found' + return 0 + + diff --git a/For Weekly Test/Backup/inserttest.py b/For Weekly Test/Backup/inserttest.py new file mode 100644 index 0000000..4987242 --- /dev/null +++ b/For Weekly Test/Backup/inserttest.py @@ -0,0 +1,28 @@ +#!/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/Backup/truetable.py b/For Weekly Test/Backup/truetable.py new file mode 100644 index 0000000..6675ccd --- /dev/null +++ b/For Weekly Test/Backup/truetable.py @@ -0,0 +1,211 @@ +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/Backup/usbDetect.py b/For Weekly Test/Backup/usbDetect.py new file mode 100644 index 0000000..695b59c --- /dev/null +++ b/For Weekly Test/Backup/usbDetect.py @@ -0,0 +1,156 @@ +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() + + + + + -- cgit v1.2.3-55-g7522