summaryrefslogtreecommitdiffstats
path: root/For Weekly Test/Backup/usbDetect.py
diff options
context:
space:
mode:
Diffstat (limited to 'For Weekly Test/Backup/usbDetect.py')
-rw-r--r--For Weekly Test/Backup/usbDetect.py156
1 files changed, 0 insertions, 156 deletions
diff --git a/For Weekly Test/Backup/usbDetect.py b/For Weekly Test/Backup/usbDetect.py
deleted file mode 100644
index 695b59c..0000000
--- a/For Weekly Test/Backup/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()
-
-
-
-
-