run_test_op.py 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469
  1. #!/usr/bin/python
  2. #_*_ coding: utf-8 _*_
  3. from Tkinter import *
  4. import sys
  5. import os
  6. import subprocess
  7. import time
  8. import ttk
  9. import tkMessageBox
  10. import threading
  11. import csv
  12. import subprocess
  13. from datetime import datetime
  14. # declaring global variables
  15. script_ver='C180-C-C7-v1.2'
  16. log_file='./Logs/temp.txt'
  17. log1_buffer = ""
  18. step_status = ['x', 'ns', 'ns']
  19. result_msg = []
  20. # 'x' = don't care
  21. # 'ns' = not started
  22. # 'p' = passed
  23. # 'f' = failed
  24. # 'r' = running
  25. test_channel = ['1', '6', '11']
  26. device_info={}
  27. params_dict = {}
  28. params_dict['path_loss'] = '25'
  29. params_dict['wave_file'] = './11b_waveforms/wave11rc_1000.mod'
  30. params_dict['per_limit'] = '92'
  31. params_dict['SA_RSSI'] = '-80'
  32. params_dict['BTOn_RSSI']='-30'
  33. ###########################################################################
  34. class IO_process:
  35. def __init__(self, log_file_path):
  36. # log_file_path is the absolute path of the log file
  37. self.log_file = log_file_path
  38. self.line_count = 0
  39. def read_file(self):
  40. try:
  41. f = open(self.log_file,'r') # open file to read
  42. flag = 0
  43. for i, line in enumerate(f):
  44. if i == self.line_count: # if reached the correct line
  45. self.line_count += 1
  46. flag = 1
  47. #print self.line_count
  48. break
  49. f.close()
  50. if flag == 1:
  51. return line.rstrip('\r') # get rid of the newline character
  52. else:
  53. return ""
  54. except:
  55. return ""
  56. def empty_file(self):
  57. f = open(self.log_file,'w')
  58. f.close()
  59. def reset_counter(self):
  60. self.line_count = 0
  61. ###########################################################################
  62. def write_log_to_file(content):
  63. curr_time=time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
  64. log_dir = "./Logs/"
  65. log_file = "log_" + curr_time + ".txt"
  66. log_file_location = log_dir + log_file
  67. file = open(log_file_location,'a') # open file to append
  68. file.write(str(content) + '\n')
  69. file.close()
  70. ###########################################################################
  71. def print1(string,newline=0):
  72. global log1_buffer
  73. if newline == 0: # if user doesn't want to insert a line feed
  74. log1_buffer += "\n" + str(string)
  75. elif newline == 1: # if user wants to insert a line feed
  76. log1_buffer += "\n" + str(string) + "\n"
  77. ###########################################################################
  78. def step1_routine():
  79. # bios_version
  80. global step_status
  81. global result_msg
  82. step_num = 1
  83. step_status[step_num] = 'r' # running
  84. print1("\nstep1----------------------------------------------------")
  85. print1("Step " + str(step_num) + " Started...")
  86. time.sleep(1)
  87. a = os.popen("sh os-ver.sh bios").read()
  88. a = a.replace('\n','')
  89. a = a.replace('\r','')
  90. a = a.strip()
  91. if len(a) == 0:
  92. print1("Error! No Device found!")
  93. print1(a)
  94. step_status[step_num] = 'f' # failed
  95. else:
  96. print1("Success! Device found! Rsync completed!")
  97. print1(a)
  98. step_status[step_num] = 'p' # passed
  99. result_msg[step_num] = a
  100. ###########################################################################
  101. def step2_routine():
  102. # bios release date
  103. global step_status
  104. global device_info
  105. global result_msg
  106. step_num = 2
  107. step_status[step_num] = 'r' # running
  108. print1("\nstep2----------------------------------------------------")
  109. print1("Step " + str(step_num) + " Started...")
  110. #tkMessageBox.showinfo("Message Box", "PS2 keyboard/mouse test! Make sure PS2 keyboard and mouse are connected.")
  111. # read the data and analysis it.
  112. #a = os.popen('sh bios-release-date.sh').read()
  113. a = os.popen('sh os-ver.sh ec').read()
  114. a = a.replace('\n','')
  115. a = a.replace('\r','')
  116. a = a.strip()
  117. #a = os.system(r'./usb-location.sh')
  118. #a = subprocess.call(['./usb-location.sh'])
  119. print1("Step " + str(a) + " End...")
  120. if len(a) == 0:
  121. print1("Error! Standalone Sensitivity Fails!")
  122. print1("Please check the cable and antenna connection and try again!")
  123. step_status[step_num] = 'f' # failed
  124. else:
  125. step_status[step_num] = 'p'
  126. result_msg[step_num] = a
  127. ###########################################################################
  128. def step3_routine():
  129. # CPU type
  130. global step_status
  131. global result_msg
  132. step_num = 3
  133. step_status[step_num] = 'r' # running
  134. print1("\n----------------------------------------------------")
  135. print1("Step " + str(step_num) + " Started...")
  136. #step_status[step_num] = 'p' # passed
  137. #result_msg[step_num] = 'AAPASS'
  138. #return;
  139. a = os.popen("cat /proc/cpuinfo | grep \"model name\" | awk '{print $5}' | head -1").read()
  140. a = a.replace('\n','')
  141. a = a.replace('\r','')
  142. a = a.strip()
  143. if len(a) == 0:
  144. print1("Error! No Device found!")
  145. print1(a)
  146. step_status[step_num] = 'f' # failed
  147. else:
  148. print1("Error! No Device found!")
  149. print1(a)
  150. step_status[step_num] = 'p' # passed
  151. result_msg[step_num] = a
  152. ###########################################################################
  153. def step4_routine():
  154. # memory_version
  155. global step_status
  156. global result_msg
  157. step_num = 4
  158. step_status[step_num] = 'r' # running
  159. print1("\nFT----------------------------------------------------")
  160. print1("Step " + str(step_num) + " Started...")
  161. a = os.popen("sh mem-ver.sh").read()
  162. a = a.replace('\n','')
  163. a = a.replace('\r','')
  164. a = a.strip()
  165. if len(a) == 0:
  166. print1("Error! No Device found!")
  167. print1(a)
  168. step_status[step_num] = 'f' # failed
  169. else:
  170. step_status[step_num] = 'p' # passed
  171. result_msg[step_num] = a
  172. ###########################################################################
  173. def step5_routine():
  174. # hdd_version
  175. global step_status
  176. global result_msg
  177. step_num = 5
  178. step_status[step_num] = 'r' # running
  179. print1("\n----------------------------------------------------")
  180. print1("Step " + str(step_num) + " Started...")
  181. a = os.popen("sh hdd-ver.sh").read()
  182. a = a.replace('\n','')
  183. a = a.replace('\r','')
  184. a = a.strip()
  185. if len(a) == 0:
  186. print1("Error! No Device found!")
  187. print1(a)
  188. step_status[step_num] = 'f' # failed
  189. else:
  190. step_status[step_num] = 'p' # passed
  191. result_msg[step_num] = a
  192. ###########################################################################
  193. def step6_routine():
  194. # os_version
  195. global step_status
  196. global result_msg
  197. step_num = 6
  198. step_status[step_num] = 'r' # running
  199. time.sleep(3)
  200. print1("\n----------------------------------------------------")
  201. print1("Step " + str(step_num) + " Started...")
  202. a = os.popen("sh os-ver.sh os").read()
  203. if str == "os":
  204. a = os.popen("sh os-ver.sh os").read()
  205. if str == "tpm":
  206. a = os.popen("sh os-ver.sh tpm").read()
  207. a = a.replace('\n','')
  208. a = a.replace('\r','')
  209. a = a.strip()
  210. if len(a) == 0:
  211. print1("Error! No Device found!")
  212. print1(a)
  213. step_status[step_num] = 'f' # failed
  214. else:
  215. print1(a)
  216. step_status[step_num] = 'p' # passed
  217. result_msg[step_num] = a
  218. ###########################################################################
  219. def step7_routine():
  220. # cpu_version
  221. global step_status
  222. global result_msg
  223. step_num = 7
  224. step_status[step_num] = 'r' # running
  225. print1("\n----------------------------------------------------")
  226. print1("Step " + str(step_num) + " Started...")
  227. tkMessageBox.showinfo("Message Box", "HDMI test! HDMI测试,如果没有插上HDMI cable,请插上HDMI查看显示器及edp显示状况.")
  228. #a = os.popen("sh cpu-ver.sh").read()
  229. a = os.popen('sh os-ver.sh HDMI').read()
  230. if tkMessageBox.askokcancel("PASS?", "确定HDMI及edp显示是否正常?"):
  231. step_status[step_num] = 'p' # passed
  232. result_msg[step_num] = 'PASS'
  233. return;
  234. a = a.replace('\n','')
  235. a = a.replace('\r','')
  236. a = a.strip()
  237. print1("Error! No Device found!")
  238. print1(a)
  239. step_status[step_num] = 'f' # failed
  240. ###########################################################################
  241. def step8_routine():
  242. # camera function
  243. global step_status
  244. global result_msg
  245. step_num = 8
  246. step_status[step_num] = 'r' # running
  247. #step_status[step_num] = 'p' # passed
  248. #result_msg[step_num] = 'AAPASS'
  249. #return;
  250. tkMessageBox.showinfo("Message Box", "camera test! 相机测试,将弹出相机软件guvcview,手动测试相机是否正常.")
  251. print1("\n----------------------------------------------------")
  252. print1("Step " + str(step_num) + " Started...")
  253. a = os.popen("/usr/bin/guvcview &").read()
  254. if tkMessageBox.askokcancel("PASS?", "确定测试相机是否正常?"):
  255. print1("camera Test! device test pass!")
  256. step_status[step_num] = 'p' # passed
  257. result_msg[step_num] = 'PASS'
  258. return;
  259. a = a.replace('\n','')
  260. a = a.replace('\r','')
  261. a = a.strip()
  262. print1("camera Test Error! No Device found!")
  263. print1(a)
  264. step_status[step_num] = 'f' # failed
  265. def step9_routine():
  266. # speaker-test
  267. global step_status
  268. global result_msg
  269. #tkMessageBox.showinfo("Message Box", "Error on Step " + str(i) + "! See Log for details.")
  270. step_num = 9
  271. step_status[step_num] = 'r' # running
  272. #step_status[step_num] = 'p' # passed
  273. #result_msg[step_num] = 'AAPASS'
  274. #return;
  275. tkMessageBox.showinfo("Message Box", "test speaker test! 喇叭测试,如果没有喇叭,请插上耳机确定是否有声音.")
  276. print1("\n----------------------------------------------------")
  277. print1("Step " + str(step_num) + " Started...")
  278. a = os.popen("sh os-ver.sh speaker").read()
  279. if tkMessageBox.askokcancel("PASS?", "确定测试机器是否有声音?"):
  280. step_status[step_num] = 'p' # passed
  281. result_msg[step_num] = 'PASS'
  282. return;
  283. a = a.replace('\n','')
  284. a = a.replace('\r','')
  285. a = a.strip()
  286. print1("Error! No Device found!")
  287. print1(a)
  288. step_status[step_num] = 'f' # failed
  289. def step10_routine():
  290. # arecord
  291. global step_status
  292. global result_msg
  293. step_num = 10
  294. step_status[step_num] = 'r' # running
  295. #step_status[step_num] = 'p' # passed
  296. #result_msg[step_num] = 'AAPASS'
  297. #return;
  298. tkMessageBox.showinfo("Message Box", "arecord test! 录音测试,将弹出录音软件Audacity,手动测试录音是否正常.")
  299. print1("\n----------------------------------------------------")
  300. print1("Step " + str(step_num) + " Started...")
  301. a = os.popen("sh os-ver.sh arecord").read()
  302. if tkMessageBox.askokcancel("PASS?", "确定测试机器录音是否正常?"):
  303. step_status[step_num] = 'p' # passed
  304. result_msg[step_num] = 'PASS'
  305. return;
  306. a = a.replace('\n','')
  307. a = a.replace('\r','')
  308. a = a.strip()
  309. #print1("Error! No Device found!")
  310. print1(a)
  311. step_status[step_num] = 'f' # failed
  312. def step11_routine():
  313. global step_status
  314. global result_msg
  315. step_num = 11
  316. step_status[step_num] = 'r' # running
  317. step_status[step_num] = 'p' # passed
  318. result_msg[step_num] = 'AAPASS'
  319. return;
  320. os.system("sh os-ver.sh USB211 &")
  321. time.sleep(1)
  322. tkMessageBox.showinfo("Message Box", "USB2.0 test! 请插入U盘到后端usb2.0接口1号位置.")
  323. print1("\n----------------------------------------------------")
  324. print1("Step " + str(step_num) + " Started...")
  325. a = os.popen("sh os-ver.sh USB21").read()
  326. print1(a)
  327. a = a.replace('\n','')
  328. a = a.replace('\r','')
  329. a = a.strip()
  330. if a == "0":
  331. print1("Error! No Device found!")
  332. print1(a)
  333. step_status[step_num] = 'f' # failed
  334. result_msg[step_num] = a
  335. else:
  336. print1(a)
  337. step_status[step_num] = 'p' # passed
  338. result_msg[step_num] = a
  339. def step12_routine():
  340. global step_status
  341. global result_msg
  342. step_num = 12
  343. step_status[step_num] = 'r' # running
  344. step_status[step_num] = 'p' # passed
  345. result_msg[step_num] = 'AAPASS'
  346. return;
  347. os.system("sh os-ver.sh USB211 &")
  348. time.sleep(1)
  349. tkMessageBox.showinfo("Message Box", "USB2.0 test! 请插入U盘到后端usb2.0接口2号位置.")
  350. print1("\n----------------------------------------------------")
  351. print1("Step " + str(step_num) + " Started...")
  352. a = os.popen("sh os-ver.sh USB22").read()
  353. a = a.replace('\n','')
  354. a = a.replace('\r','')
  355. a = a.strip()
  356. if a == "0":
  357. print1("Error! No Device found!")
  358. print1(a)
  359. step_status[step_num] = 'f' # failed
  360. result_msg[step_num] = a
  361. else:
  362. print1(a)
  363. step_status[step_num] = 'p' # passed
  364. result_msg[step_num] = a
  365. def step13_routine():
  366. global step_status
  367. global result_msg
  368. step_num = 13
  369. step_status[step_num] = 'r' # running
  370. print1("\n----------------------------------------------------")
  371. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  372. os.system("sh os-ver.sh USB211 &")
  373. time.sleep(1)
  374. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到整个hub全usb3.0接口1号位置-靠近主板.")
  375. a = os.popen("sh os-ver.sh USB391").read()
  376. a = a.replace('\n','')
  377. a = a.replace('\r','')
  378. a = a.strip()
  379. print1("\n----------------------------------------------------")
  380. #tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到后端usb3.0接口4号指定位置.")
  381. if a == "0":
  382. print1("Error! No Device found!")
  383. print1(a)
  384. step_status[step_num] = 'f' # failed
  385. result_msg[step_num] = a
  386. else:
  387. print1(a)
  388. step_status[step_num] = 'p' # passed
  389. result_msg[step_num] = a
  390. def step14_routine():
  391. global step_status
  392. global result_msg
  393. step_num = 14
  394. step_status[step_num] = 'r' # running
  395. print1("\n----------------------------------------------------")
  396. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  397. os.system("sh os-ver.sh USB211 &")
  398. time.sleep(1)
  399. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到整个hub全usb3.0接口2号位置-靠近主板.")
  400. a = os.popen("sh os-ver.sh USB392").read()
  401. a = a.replace('\n','')
  402. a = a.replace('\r','')
  403. a = a.strip()
  404. print1("\n----------------------------------------------------")
  405. if a == "0":
  406. print1("Error! No Device found!")
  407. print1(a)
  408. step_status[step_num] = 'f' # failed
  409. result_msg[step_num] = a
  410. else:
  411. print1(a)
  412. step_status[step_num] = 'p' # passed
  413. result_msg[step_num] = a
  414. def step15_routine():
  415. global step_status
  416. global result_msg
  417. step_num = 15
  418. step_status[step_num] = 'r' # running
  419. print1("\n----------------------------------------------------")
  420. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  421. os.system("sh os-ver.sh USB211 &")
  422. time.sleep(1)
  423. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到整个hub全usb3.0接口3号位置-靠近主板.")
  424. a = os.popen("sh os-ver.sh USB393").read()
  425. a = a.replace('\n','')
  426. a = a.replace('\r','')
  427. a = a.strip()
  428. print1("\n----------------------------------------------------")
  429. if a == "0":
  430. print1("Error! No Device found!")
  431. print1(a)
  432. step_status[step_num] = 'f' # failed
  433. result_msg[step_num] = a
  434. else:
  435. print1(a)
  436. step_status[step_num] = 'p' # passed
  437. result_msg[step_num] = a
  438. def step16_routine():
  439. global step_status
  440. global result_msg
  441. step_num = 16
  442. step_status[step_num] = 'r' # running
  443. print1("\n----------------------------------------------------")
  444. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  445. os.system("sh os-ver.sh USB211 &")
  446. time.sleep(1)
  447. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到整个hub全usb3.0接口4号位置-靠近主板.")
  448. a = os.popen("sh os-ver.sh USB394").read()
  449. a = a.replace('\n','')
  450. a = a.replace('\r','')
  451. a = a.strip()
  452. print1("\n----------------------------------------------------")
  453. if a == "0":
  454. print1("Error! No Device found!")
  455. print1(a)
  456. step_status[step_num] = 'f' # failed
  457. result_msg[step_num] = a
  458. else:
  459. print1(a)
  460. step_status[step_num] = 'p' # passed
  461. result_msg[step_num] = a
  462. def step17_routine():
  463. # network speed cli
  464. global step_status
  465. global result_msg
  466. step_num = 17
  467. step_status[step_num] = 'r' # running
  468. step_status[step_num] = 'p' # passed
  469. result_msg[step_num] = 'AAPASS'
  470. return;
  471. tkMessageBox.showinfo("Message Box", "RJ45网口 test! 请插入网线到指定RJ45网口中,再点确定开始测试!.")
  472. print1("\n----------------------------------------------------")
  473. print1("Step " + str(step_num) + " Started...")
  474. step_status[step_num] = 'p' # passed
  475. result_msg[step_num] = 'AAPASS'
  476. return;
  477. a = os.popen("sh os-ver.sh speedcliDownload").read()
  478. a = a.replace('\n','')
  479. a = a.replace('\r','')
  480. a = a.strip()
  481. if len(a) == 0:
  482. print1("Error! No Device found!")
  483. print1(a)
  484. step_status[step_num] = 'f' # failed
  485. elif a == "Download: Upload:":
  486. print1("Error! no ethernet!")
  487. print1(a)
  488. step_status[step_num] = 'f' # failed
  489. result_msg[step_num] = a
  490. else:
  491. print1(a)
  492. step_status[step_num] = 'p' # passed
  493. result_msg[step_num] = a
  494. def step18_routine():
  495. # serial
  496. global step_status
  497. global result_msg
  498. step_num = 18
  499. step_status[step_num] = 'r' # running
  500. #tkMessageBox.showinfo("Message Box", "Serial test! 串口基本功能测试是否AAPASS.")
  501. print1("\n----------------------------------------------------")
  502. print1("Step " + str(step_num) + " Started...")
  503. if tkMessageBox.askokcancel("PASS?", "串口基本功能测试是否AAPASS."):
  504. step_status[step_num] = 'p' # passed
  505. result_msg[step_num] = 'PASS'
  506. return;
  507. a = os.popen("sh os-ver.sh tpm").read()
  508. a = a.replace('\n','')
  509. a = a.replace('\r','')
  510. a = a.strip()
  511. if len(a) == 0:
  512. print1("Error! No Device found!")
  513. print1(a)
  514. step_status[step_num] = 'f' # failed
  515. else:
  516. print1(a)
  517. step_status[step_num] = 'p' # passed
  518. result_msg[step_num] = a
  519. def step19_routine():
  520. # battery
  521. global step_status
  522. global result_msg
  523. step_num = 19
  524. step_status[step_num] = 'r' # running
  525. #tkMessageBox.showinfo("Message Box", "battery test! 电池包测试(C180)是否AAPASS.")
  526. print1("\n----------------------------------------------------")
  527. print1("Step " + str(step_num) + " Started...")
  528. step_status[step_num] = 'p' # passed
  529. result_msg[step_num] = 'AAPASS'
  530. return;
  531. tkMessageBox.showinfo("Message Box", "battery test! 电池包测试(C180)是否能正常工作!")
  532. a = os.popen("sh os-ver.sh ps2").read()
  533. if tkMessageBox.askokcancel("PASS?", "电池包测试(C180)是否正常."):
  534. step_status[step_num] = 'p' # passed
  535. result_msg[step_num] = 'PASS'
  536. return;
  537. a = a.replace('\n','')
  538. a = a.replace('\r','')
  539. a = a.strip()
  540. print1("Error! No Device found!")
  541. print1(a)
  542. step_status[step_num] = 'f' # failed
  543. def step20_routine():
  544. global step_status
  545. global result_msg
  546. step_num = 20
  547. step_status[step_num] = 'r' # running
  548. #step_status[step_num] = 'p' # passed
  549. #result_msg[step_num] = 'AAPASS'
  550. #return;
  551. #tkMessageBox.showinfo("Message Box", "play video test! 视频测试,播放720p视频.")
  552. print1("\n----------------------------------------------------")
  553. print1("Step " + str(step_num) + " Started...")
  554. print1("Step " + str(step_num) + " 开始播放720p视频")
  555. #a = os.popen("sh os-ver.sh 720p").read()
  556. #subprocess.run('sh os-ver.sh 720p',stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  557. #os.system("sudo setenforce 0")
  558. time.sleep(1)
  559. os.system("sh os-ver.sh 720p &")
  560. time.sleep(2)
  561. #os.system("sudo setenforce 1")
  562. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-确定测试机器播放720p视频正常吗?"):
  563. os.system("sh os-ver.sh exit &")
  564. time.sleep(1)
  565. print1("Error! No Device found!")
  566. print1("The video is playing abnormally! - 720p video")
  567. step_status[step_num] = 'f' # failed
  568. return;
  569. """
  570. #os.system("systemctl suspend &")
  571. #os.system("sh os-ver.sh suspend &")
  572. os.system("sh os-ver.sh sudo &")
  573. time.sleep(10)
  574. if not tkMessageBox.askokcancel("PASS?", "视频播放器不要关-睡眠之后再确定测试机器播放720p视频正常吗?"):
  575. print1("Error! No Device found!")
  576. print1("The video is playing abnormally! - 720p suspend")
  577. step_status[step_num] = 'f' # failed
  578. return;
  579. print1("Step " + str(step_num) + " 开始是休眠再播放720p视频")
  580. #os.system("systemctl hibernate &")
  581. #os.system("sh os-ver.sh hibernate &")
  582. #os.system("sh os-ver.sh sudo &")
  583. #time.sleep(30)
  584. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-休眠之后再确定测试机器播放720p视频正常吗?"):
  585. os.system("sh os-ver.sh exit &")
  586. time.sleep(1)
  587. print1("Error! No Device found!")
  588. print1("The video is playing abnormally! - 720p hibernate")
  589. step_status[step_num] = 'f' # failed
  590. return;
  591. """
  592. os.system("sh os-ver.sh exit &")
  593. time.sleep(1)
  594. print1("The video is playing normally! - 720p")
  595. step_status[step_num] = 'p' # passed
  596. result_msg[step_num] = 'PASS'
  597. def step21_routine():
  598. global step_status
  599. global result_msg
  600. #tkMessageBox.showinfo("Message Box", "Error on Step " + str(i) + "! See Log for details.")
  601. step_num = 21
  602. step_status[step_num] = 'r' # running
  603. #step_status[step_num] = 'p' # passed
  604. #result_msg[step_num] = 'AAPASS'
  605. #return;
  606. #tkMessageBox.showinfo("Message Box", "play video test! 视频测试,播放1080p视频.")
  607. print1("\n----------------------------------------------------")
  608. print1("Step " + str(step_num) + " Started...")
  609. print1("Step " + str(step_num) + " 开始播放1080p视频")
  610. #a = os.popen("sh os-ver.sh 720p").read()
  611. #subprocess.run('sh os-ver.sh 720p',stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  612. time.sleep(1)
  613. os.system("sh os-ver.sh 1080p &")
  614. time.sleep(2)
  615. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-确定测试机器播放1080p视频正常吗?"):
  616. os.system("sh os-ver.sh exit &")
  617. time.sleep(1)
  618. print1("Error! No Device found!")
  619. print1("The video is playing abnormally! - 1080p video")
  620. step_status[step_num] = 'f' # failed
  621. return;
  622. """
  623. #os.system("sh os-ver.sh suspend &")
  624. os.system("sh os-ver.sh sudo &")
  625. time.sleep(10)
  626. if not tkMessageBox.askokcancel("PASS?", "视频播放器不要关-睡眠之后再确定测试机器播放1080p视频正常吗?"):
  627. print1("Error! No Device found!")
  628. print1("The video is playing abnormally! - 1080p suspend")
  629. step_status[step_num] = 'f' # failed
  630. return;
  631. print1("Step " + str(step_num) + " 开始是休眠再播放1080p视频")
  632. #os.system("sh os-ver.sh hibernate &")
  633. #os.system("sh os-ver.sh sudo &")
  634. #time.sleep(30)
  635. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-休眠之后再确定测试机器播放1080p视频正常吗?"):
  636. os.system("sh os-ver.sh exit &")
  637. time.sleep(1)
  638. print1("Error! No Device found!")
  639. print1("The video is playing abnormally! - 1080p hibernate")
  640. step_status[step_num] = 'f' # failed
  641. return;
  642. """
  643. os.system("sh os-ver.sh exit &")
  644. time.sleep(1)
  645. print1("The video is playing normally! - 1080p")
  646. step_status[step_num] = 'p' # passed
  647. result_msg[step_num] = 'PASS'
  648. def step22_routine():
  649. global step_status
  650. global result_msg
  651. #tkMessageBox.showinfo("Message Box", "Error on Step " + str(i) + "! See Log for details.")
  652. step_num = 22
  653. step_status[step_num] = 'r' # running
  654. #step_status[step_num] = 'p' # passed
  655. #result_msg[step_num] = 'AAPASS'
  656. #return;
  657. #tkMessageBox.showinfo("Message Box", "play video test! 视频测试,播放4K视频.")
  658. print1("\n----------------------------------------------------")
  659. print1("Step " + str(step_num) + " Started...")
  660. print1("Step " + str(step_num) + " 开始播放4K视频")
  661. #a = os.popen("sh os-ver.sh 720p").read()
  662. #subprocess.run('sh os-ver.sh 720p',stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  663. time.sleep(1)
  664. os.system("sh os-ver.sh 4K &")
  665. time.sleep(1)
  666. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-确定测试机器播放4K视频正常吗?"):
  667. os.system("sh os-ver.sh exit &")
  668. time.sleep(1)
  669. print1("Error! No Device found!")
  670. print1("The video is playing abnormally! - 4K suspend")
  671. step_status[step_num] = 'f' # failed
  672. return;
  673. """
  674. #os.system("sh os-ver.sh suspend &")
  675. os.system("sh os-ver.sh sudo &")
  676. #a = os.popen("sh os-ver.sh suspend").read()
  677. time.sleep(10)
  678. if not tkMessageBox.askokcancel("PASS?", "视频播放器不要关-睡眠之后再确定测试机器播放4K视频正常吗?"):
  679. print1("Error! No Device found!")
  680. print1("The video is playing abnormally! - 4K hibernate")
  681. step_status[step_num] = 'f' # failed
  682. return;
  683. print1("Step " + str(step_num) + " 开始是休眠再播放4K视频")
  684. #os.system("sh os-ver.sh hibernate &")
  685. #os.system("sh os-ver.sh sudo &")
  686. #time.sleep(30)
  687. #a = os.popen("sh os-ver.sh hibernate").read()
  688. if not tkMessageBox.askokcancel("PASS?", "视频播放器要关-休眠之后再确定测试机器播放4K视频正常吗?"):
  689. os.system("sh os-ver.sh exit &")
  690. time.sleep(1)
  691. print1("Error! No Device found!")
  692. print1("The video is playing abnormally! - 4K hibernate")
  693. step_status[step_num] = 'f' # failed
  694. return;
  695. """
  696. os.system("sh os-ver.sh exit &")
  697. time.sleep(1)
  698. print1("The video is playing normally! - 4K")
  699. step_status[step_num] = 'p' # passed
  700. result_msg[step_num] = 'PASS'
  701. #########################################################################
  702. def step23_routine():
  703. global step_status
  704. global result_msg
  705. step_num = 23
  706. step_status[step_num] = 'r' # running
  707. os.system("sh os-ver.sh USB211 &")
  708. time.sleep(1)
  709. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到带网口hub的usb3.0接口1号位置-靠近主板.")
  710. print1("\n----------------------------------------------------")
  711. print1("Step " + str(step_num) + " Started...")
  712. a = os.popen("sh os-ver.sh USB381").read()
  713. print1(a)
  714. a = a.replace('\n','')
  715. a = a.replace('\r','')
  716. a = a.strip()
  717. if a == "0":
  718. print1("Error! No Device found!")
  719. print1(a)
  720. step_status[step_num] = 'f' # failed
  721. result_msg[step_num] = a
  722. else:
  723. print1(a)
  724. step_status[step_num] = 'p' # passed
  725. result_msg[step_num] = a
  726. def step24_routine():
  727. global step_status
  728. global result_msg
  729. step_num = 24
  730. step_status[step_num] = 'r' # running
  731. os.system("sh os-ver.sh USB211 &")
  732. time.sleep(1)
  733. tkMessageBox.showinfo("Message Box", "USB3.0 test! 请插入U盘到带网口hub的usb3.0接口2号位置-靠近主板.")
  734. print1("\n----------------------------------------------------")
  735. print1("Step " + str(step_num) + " Started...")
  736. a = os.popen("sh os-ver.sh USB382").read()
  737. a = a.replace('\n','')
  738. a = a.replace('\r','')
  739. a = a.strip()
  740. if a == "0":
  741. print1("Error! No Device found!")
  742. print1(a)
  743. step_status[step_num] = 'f' # failed
  744. result_msg[step_num] = a
  745. else:
  746. print1(a)
  747. step_status[step_num] = 'p' # passed
  748. result_msg[step_num] = a
  749. def step25_routine():
  750. global step_status
  751. global result_msg
  752. step_num = 25
  753. step_status[step_num] = 'r' # running
  754. print1("\n----------------------------------------------------")
  755. print1("Step " + str(step_num) + " Started USB3.0 test 1...")
  756. #step_status[step_num] = 'p' # passed
  757. #result_msg[step_num] = 'AAPASS'
  758. #return;
  759. tkMessageBox.showinfo("Message Box", "LED test! 电池健康指示灯/充电指示灯/心跳灯.")
  760. time.sleep(1)
  761. #os.system("sh os-ver.sh 4K &")
  762. time.sleep(1)
  763. if not tkMessageBox.askokcancel("PASS?", "LED test-确定电池健康指示灯/充电指示灯/心跳灯正常吗?"):
  764. time.sleep(1)
  765. print1("Error! No Device found!")
  766. print1("The video is playing abnormally! - 4K suspend")
  767. step_status[step_num] = 'f' # failed
  768. return;
  769. time.sleep(1)
  770. print1("Battery health indicator/charging indicator/heartbeat light test normally!")
  771. step_status[step_num] = 'p' # passed
  772. result_msg[step_num] = 'PASS'
  773. def step26_routine():
  774. global step_status
  775. global result_msg
  776. step_num = 26
  777. step_status[step_num] = 'r' # running
  778. print1("\n----------------------------------------------------")
  779. print1("Step " + str(step_num) + " Started keyboard test...")
  780. step_status[step_num] = 'p' # passed
  781. result_msg[step_num] = 'AAPASS'
  782. return;
  783. #os.system("sh os-ver.sh keyboard")
  784. #time.sleep(1)
  785. a = os.popen('sh os-ver.sh keyboard').read()
  786. if tkMessageBox.askokcancel("PASS?", "确定键盘测试是否正常?"):
  787. step_status[step_num] = 'p' # passed
  788. result_msg[step_num] = 'PASS'
  789. return;
  790. a = a.replace('\n','')
  791. a = a.replace('\r','')
  792. a = a.strip()
  793. print1("Error! No Device found!")
  794. print1(a)
  795. step_status[step_num] = 'f' # failed
  796. def step27_routine():
  797. global step_status
  798. global result_msg
  799. step_num = 27
  800. step_status[step_num] = 'r' # running
  801. print1("\n----------------------------------------------------")
  802. print1("Step " + str(step_num) + " Started touchpad test 1...")
  803. step_status[step_num] = 'p' # passed
  804. result_msg[step_num] = 'AAPASS'
  805. return;
  806. a = os.popen('sh os-ver.sh TP').read()
  807. if tkMessageBox.askokcancel("PASS?", "确定触摸板测试是否正常?"):
  808. step_status[step_num] = 'p' # passed
  809. result_msg[step_num] = 'PASS'
  810. return;
  811. a = a.replace('\n','')
  812. a = a.replace('\r','')
  813. a = a.strip()
  814. print1("Error! No Device found!")
  815. print1(a)
  816. step_status[step_num] = 'f' # failed
  817. def step28_routine():
  818. global step_status
  819. global result_msg
  820. step_num = 28
  821. step_status[step_num] = 'r' # running
  822. print1("\n----------------------------------------------------")
  823. print1("Step " + str(step_num) + " Started RTC test 1...")
  824. #step_status[step_num] = 'p' # passed
  825. #result_msg[step_num] = 'AAPASS'
  826. #return;
  827. time.sleep(1)
  828. #tkMessageBox.showinfo("Message Box", "RTC test! RTC电池测试.")
  829. a = os.popen("sh os-ver.sh RTCBATTERY").read()
  830. a = a.replace('\n','')
  831. a = a.replace('\r','')
  832. a = a.strip()
  833. print1("\n----------------------------------------------------")
  834. try:
  835. a_int = int(a)
  836. if 3000 <= a_int <= 4000:
  837. #print1("Error! No Device found!")
  838. print1(a)
  839. step_status[step_num] = 'p' # passed
  840. result_msg[step_num] = a
  841. else:
  842. print1(a)
  843. print1("Error! No Device found!")
  844. step_status[step_num] = 'f' # failed
  845. result_msg[step_num] = a
  846. except ValueError:
  847. step_status[step_num] = 'f' # failed
  848. result_msg[step_num] = "Invalid output: {a}"
  849. #else:
  850. # print1("Error! No Device found!")
  851. # print1(a)
  852. # step_status[step_num] = 'f' # failed
  853. # result_msg[step_num] = a
  854. #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  855. class MasterThread(threading.Thread):
  856. def __init__(self, guiobj):
  857. super(MasterThread, self).__init__()
  858. def run(self):
  859. global step_status
  860. global script_ver
  861. print1("X86 C180####################################################",1)
  862. print1(script_ver)
  863. step1_routine()
  864. if step_status[1] == 'p' or step_status[1] == 'f': # if step 1 passed
  865. step2_routine()
  866. if step_status[2] == 'p' or step_status[2] == 'f':
  867. step3_routine()
  868. if step_status[3] == 'p' or step_status[3] == 'f':
  869. step4_routine()
  870. if step_status[4] == 'p' or step_status[4] == 'f':
  871. step5_routine()
  872. if step_status[5] == 'p' or step_status[5] == 'f':
  873. step6_routine()
  874. if step_status[6] == 'p' or step_status[6] == 'f':
  875. step7_routine()
  876. if step_status[7] == 'p' or step_status[7] == 'f':
  877. step8_routine()
  878. if step_status[8] == 'p' or step_status[8] == 'f':
  879. step9_routine()
  880. if step_status[9] == 'p' or step_status[9] == 'f':
  881. step10_routine()
  882. if step_status[10] == 'p' or step_status[10] == 'f':
  883. step11_routine()
  884. if step_status[11] == 'p' or step_status[11] == 'f':
  885. step12_routine()
  886. if step_status[12] == 'p' or step_status[12] == 'f':
  887. step13_routine()
  888. if step_status[13] == 'p' or step_status[13] == 'f':
  889. step14_routine()
  890. if step_status[14] == 'p' or step_status[14] == 'f':
  891. step15_routine()
  892. if step_status[15] == 'p' or step_status[15] == 'f':
  893. step16_routine()
  894. if step_status[16] == 'p' or step_status[16] == 'f':
  895. step17_routine()
  896. if step_status[17] == 'p' or step_status[17] == 'f':
  897. step18_routine()
  898. if step_status[18] == 'p' or step_status[18] == 'f':
  899. step19_routine()
  900. if step_status[19] == 'p' or step_status[19] == 'f':
  901. step20_routine()
  902. if step_status[20] == 'p' or step_status[20] == 'f':
  903. step21_routine()
  904. if step_status[21] == 'p' or step_status[21] == 'f':
  905. step22_routine()
  906. if step_status[22] == 'p' or step_status[22] == 'f':
  907. step23_routine()
  908. if step_status[23] == 'p' or step_status[23] == 'f':
  909. step24_routine()
  910. if step_status[24] == 'p' or step_status[24] == 'f':
  911. step25_routine()
  912. if step_status[25] == 'p' or step_status[25] == 'f':
  913. step26_routine()
  914. if step_status[26] == 'p' or step_status[26] == 'f':
  915. step27_routine()
  916. if step_status[27] == 'p' or step_status[27] == 'f':
  917. step28_routine()
  918. print1("\n----------------------------------------------------")
  919. print1("Test concluded!")
  920. #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  921. class GuiThread(object):
  922. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  923. def __init__(self):
  924. global log_file
  925. global result_msg
  926. self.thread_list = {}
  927. self.running=False
  928. self.counter=0
  929. self.root = Tk()
  930. self.root.geometry("1800x1200")
  931. self.root.protocol("WM_DELETE_WINDOW", self.destroy) # when user closes the window
  932. self.root.title("WiPER: FT Simular Test")
  933. self.note1 = Label(self.root, text="Please press 'Start Test' to begin...", fg='blue')
  934. self.button1 = Button(self.root, text="Start Test", command=self.start)
  935. self.lbl = Label(self.root, text="NOT STARTED", width=15, bg='gray')
  936. self.lbl2 = Label(self.root, text="Device: ",width=20,bg="#C6EBFF")
  937. self.nb = ttk.Notebook(self.root, name='notebook')
  938. self.textframe1 = Frame(self.root)
  939. self.text1 = Text(self.textframe1)
  940. self.scrollbar1 = Scrollbar(self.textframe1)
  941. self.paramframe = Frame(self.root)
  942. self.lblframe = Frame(self.root)
  943. #self.step1_lbl1 = Label(self.lblframe, text="Step1: Check BIOS Version ", width=50)
  944. self.step1_lbl1 = Label(self.lblframe, text="Step1: 检查BIOS版本号 ", width=50)
  945. self.step2_lbl1 = Label(self.lblframe, text="Step2: 检查EC版本号 ", width=50)
  946. self.step3_lbl1 = Label(self.lblframe, text="Step3: 检查CPU测试 ", width=50)
  947. self.step4_lbl1 = Label(self.lblframe, text="Step4: 检查Memory内存版本号 ", width=50)
  948. self.step5_lbl1 = Label(self.lblframe, text="Step5: 检查HDD硬盘版本号 ", width=50)
  949. self.step6_lbl1 = Label(self.lblframe, text="Step6: 检查OS操作系统版本号 ", width=50)
  950. self.step7_lbl1 = Label(self.lblframe, text="Step7: HDMI功能测试 ", width=50)
  951. self.step8_lbl1 = Label(self.lblframe, text="Step8: 相机功能测试 ", width=50)
  952. self.step9_lbl1 = Label(self.lblframe, text="Step9: 检查SPEAKER耳机测试 ", width=50)
  953. self.step10_lbl1 = Label(self.lblframe, text="Step10: 检查耳机录音测试 ", width=50)
  954. self.step11_lbl1 = Label(self.lblframe, text="Step11: 检查usb2.0后接口1U盘基本功能测试 ", width=50)
  955. self.step12_lbl1 = Label(self.lblframe, text="Step12: 检查usb2.0后接口2U盘基本功能测试 ", width=50)
  956. self.step13_lbl1 = Label(self.lblframe, text="Step13: 检查整个hub全usb3.0接口1号位置基本功能测试 ", width=50)
  957. self.step14_lbl1 = Label(self.lblframe, text="Step14: 检查整个hub全usb3.0接口2号位置基本功能测试 ", width=50)
  958. self.step15_lbl1 = Label(self.lblframe, text="Step15: 检查整个hub全usb3.0接口3号位置基本功能测试 ", width=50)
  959. self.step16_lbl1 = Label(self.lblframe, text="Step16: 检查整个hub全usb3.0接口4号位置基本功能测试 ", width=50)
  960. self.step17_lbl1 = Label(self.lblframe, text="Step17: 检查网络在线速度测试 ", width=50)
  961. self.step18_lbl1 = Label(self.lblframe, text="Step18: 串口基本功能测试 ", width=50)
  962. self.step19_lbl1 = Label(self.lblframe, text="Step19: 电池包测试 ", width=50)
  963. self.step20_lbl1 = Label(self.lblframe, text="Step20: 720p视频测试 ", width=50)
  964. self.step21_lbl1 = Label(self.lblframe, text="Step21: 1080p视频测试 检查HDD硬盘版本号 ", width=50)
  965. self.step22_lbl1 = Label(self.lblframe, text="Step22: 4K视频测试 检查Memory内存版本号 ", width=50)
  966. self.step23_lbl1 = Label(self.lblframe, text="Step23: 检查带网口hub的usb3.0接口1号基本功能测试 ", width=50)
  967. self.step24_lbl1 = Label(self.lblframe, text="Step24: 检查带网口hub的usb3.0接口2号基本功能测试 ", width=50)
  968. self.step25_lbl1 = Label(self.lblframe, text="Step25: 电池健康指示灯/充电指示灯/心跳灯 ", width=50)
  969. self.step26_lbl1 = Label(self.lblframe, text="Step26: 外置键盘测试C180 ", width=50)
  970. self.step27_lbl1 = Label(self.lblframe, text="Step27: 触摸板测试C180 ", width=50)
  971. self.step28_lbl1 = Label(self.lblframe, text="Step28: RTC电池 ", width=50)
  972. self.step1_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  973. self.step2_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  974. self.step3_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  975. self.step4_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  976. self.step5_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  977. self.step6_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  978. self.step7_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  979. self.step8_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  980. self.step9_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  981. self.step10_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  982. self.step11_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  983. self.step12_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  984. self.step13_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  985. self.step14_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  986. self.step15_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  987. self.step16_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  988. self.step17_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  989. self.step18_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  990. self.step19_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  991. self.step20_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  992. self.step21_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  993. self.step22_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  994. self.step23_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  995. self.step24_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  996. self.step25_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  997. self.step26_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  998. self.step27_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  999. self.step28_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1000. self.step_lbl_list = []
  1001. self.step_lbl_list.append('x') # don't care
  1002. self.step_lbl_list.append(self.step1_lbl2)
  1003. self.step_lbl_list.append(self.step2_lbl2)
  1004. self.step_lbl_list.append(self.step3_lbl2)
  1005. self.step_lbl_list.append(self.step4_lbl2)
  1006. self.step_lbl_list.append(self.step5_lbl2)
  1007. self.step_lbl_list.append(self.step6_lbl2)
  1008. self.step_lbl_list.append(self.step7_lbl2)
  1009. self.step_lbl_list.append(self.step8_lbl2)
  1010. self.step_lbl_list.append(self.step9_lbl2)
  1011. self.step_lbl_list.append(self.step10_lbl2)
  1012. self.step_lbl_list.append(self.step11_lbl2)
  1013. self.step_lbl_list.append(self.step12_lbl2)
  1014. self.step_lbl_list.append(self.step13_lbl2)
  1015. self.step_lbl_list.append(self.step14_lbl2)
  1016. self.step_lbl_list.append(self.step15_lbl2)
  1017. self.step_lbl_list.append(self.step16_lbl2)
  1018. self.step_lbl_list.append(self.step17_lbl2)
  1019. self.step_lbl_list.append(self.step18_lbl2)
  1020. self.step_lbl_list.append(self.step19_lbl2)
  1021. self.step_lbl_list.append(self.step20_lbl2)
  1022. self.step_lbl_list.append(self.step21_lbl2)
  1023. self.step_lbl_list.append(self.step22_lbl2)
  1024. self.step_lbl_list.append(self.step23_lbl2)
  1025. self.step_lbl_list.append(self.step24_lbl2)
  1026. self.step_lbl_list.append(self.step25_lbl2)
  1027. self.step_lbl_list.append(self.step26_lbl2)
  1028. self.step_lbl_list.append(self.step27_lbl2)
  1029. self.step_lbl_list.append(self.step28_lbl2)
  1030. result_msg.append('P')
  1031. result_msg.append('P')
  1032. result_msg.append('P')
  1033. result_msg.append('P')
  1034. result_msg.append('P')
  1035. result_msg.append('P')
  1036. result_msg.append('P')
  1037. result_msg.append('P')
  1038. result_msg.append('P')
  1039. result_msg.append('P')
  1040. result_msg.append('P')
  1041. result_msg.append('P')
  1042. result_msg.append('P')
  1043. result_msg.append('P')
  1044. result_msg.append('P')
  1045. result_msg.append('P')
  1046. result_msg.append('P')
  1047. result_msg.append('P')
  1048. result_msg.append('P')
  1049. result_msg.append('P')
  1050. result_msg.append('P')
  1051. result_msg.append('P')
  1052. result_msg.append('P')
  1053. result_msg.append('P')
  1054. result_msg.append('P')
  1055. result_msg.append('P')
  1056. result_msg.append('P')
  1057. result_msg.append('P')
  1058. result_msg.append('P')
  1059. self.my_io_process = IO_process(log_file)
  1060. self.readLog1()
  1061. self.set_param_frame()
  1062. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1063. def destroy(self):
  1064. if tkMessageBox.askokcancel("Quit?", "Are you sure you want to quit?"):
  1065. self.root.quit()
  1066. def counter_label(self):
  1067. def count():
  1068. if self.running:
  1069. global counter
  1070. if self.counter==0: #66600
  1071. display="Starting..."
  1072. else:
  1073. tt=datetime.fromtimestamp(self.counter)
  1074. string=tt.strftime("%H:%M:%S")
  1075. display=string
  1076. self.note1.config(text=display)
  1077. self.note1.after(1000, count)
  1078. self.counter+=1
  1079. count()
  1080. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1081. def run(self):
  1082. self.note1.pack()
  1083. self.button1.pack(side=TOP, padx = 10, pady = 3)
  1084. self.lbl.pack()
  1085. self.lbl2.pack(fill=BOTH,expand=Y)
  1086. self.scrollbar1.config(command=self.text1.yview)
  1087. self.text1.config(yscrollcommand=self.scrollbar1.set)
  1088. self.text1.pack(side=LEFT, fill=Y)
  1089. self.scrollbar1.pack(side=RIGHT, fill=Y)
  1090. self.step1_lbl1.grid(row=0,column=0,sticky=W)
  1091. self.step2_lbl1.grid(row=1,column=0,sticky=W)
  1092. self.step3_lbl1.grid(row=2,column=0,sticky=W)
  1093. self.step4_lbl1.grid(row=3,column=0,sticky=W)
  1094. self.step5_lbl1.grid(row=4,column=0,sticky=W)
  1095. self.step6_lbl1.grid(row=5,column=0,sticky=W)
  1096. self.step7_lbl1.grid(row=6,column=0,sticky=W)
  1097. self.step8_lbl1.grid(row=7,column=0,sticky=W)
  1098. self.step9_lbl1.grid(row=8,column=0,sticky=W)
  1099. self.step10_lbl1.grid(row=9,column=0,sticky=W)
  1100. self.step11_lbl1.grid(row=10,column=0,sticky=W)
  1101. self.step12_lbl1.grid(row=11,column=0,sticky=W)
  1102. self.step13_lbl1.grid(row=12,column=0,sticky=W)
  1103. self.step14_lbl1.grid(row=13,column=0,sticky=W)
  1104. self.step15_lbl1.grid(row=14,column=0,sticky=W)
  1105. self.step16_lbl1.grid(row=15,column=0,sticky=W)
  1106. self.step17_lbl1.grid(row=16,column=0,sticky=W)
  1107. self.step18_lbl1.grid(row=17,column=0,sticky=W)
  1108. self.step19_lbl1.grid(row=18,column=0,sticky=W)
  1109. self.step20_lbl1.grid(row=19,column=0,sticky=W)
  1110. self.step21_lbl1.grid(row=20,column=0,sticky=W)
  1111. self.step22_lbl1.grid(row=21,column=0,sticky=W)
  1112. self.step23_lbl1.grid(row=22,column=0,sticky=W)
  1113. self.step24_lbl1.grid(row=23,column=0,sticky=W)
  1114. self.step25_lbl1.grid(row=24,column=0,sticky=W)
  1115. self.step26_lbl1.grid(row=25,column=0,sticky=W)
  1116. self.step27_lbl1.grid(row=26,column=0,sticky=W)
  1117. self.step28_lbl1.grid(row=27,column=0,sticky=W)
  1118. self.step1_lbl2.grid(row=0,column=1,sticky=W)
  1119. self.step2_lbl2.grid(row=1,column=1,sticky=W)
  1120. self.step3_lbl2.grid(row=2,column=1,sticky=W)
  1121. self.step4_lbl2.grid(row=3,column=1,sticky=W)
  1122. self.step5_lbl2.grid(row=4,column=1,sticky=W)
  1123. self.step6_lbl2.grid(row=5,column=1,sticky=W)
  1124. self.step7_lbl2.grid(row=6,column=1,sticky=W)
  1125. self.step8_lbl2.grid(row=7,column=1,sticky=W)
  1126. self.step9_lbl2.grid(row=8,column=1,sticky=W)
  1127. self.step10_lbl2.grid(row=9,column=1,sticky=W)
  1128. self.step11_lbl2.grid(row=10,column=1,sticky=W)
  1129. self.step12_lbl2.grid(row=11,column=1,sticky=W)
  1130. self.step13_lbl2.grid(row=12,column=1,sticky=W)
  1131. self.step14_lbl2.grid(row=13,column=1,sticky=W)
  1132. self.step15_lbl2.grid(row=14,column=1,sticky=W)
  1133. self.step16_lbl2.grid(row=15,column=1,sticky=W)
  1134. self.step17_lbl2.grid(row=16,column=1,sticky=W)
  1135. self.step18_lbl2.grid(row=17,column=1,sticky=W)
  1136. self.step19_lbl2.grid(row=18,column=1,sticky=W)
  1137. self.step20_lbl2.grid(row=19,column=1,sticky=W)
  1138. self.step21_lbl2.grid(row=20,column=1,sticky=W)
  1139. self.step22_lbl2.grid(row=21,column=1,sticky=W)
  1140. self.step23_lbl2.grid(row=22,column=1,sticky=W)
  1141. self.step24_lbl2.grid(row=23,column=1,sticky=W)
  1142. self.step25_lbl2.grid(row=24,column=1,sticky=W)
  1143. self.step26_lbl2.grid(row=25,column=1,sticky=W)
  1144. self.step27_lbl2.grid(row=26,column=1,sticky=W)
  1145. self.step28_lbl2.grid(row=27,column=1,sticky=W)
  1146. self.lblframe.pack()
  1147. self.textframe1.pack()
  1148. self.paramframe.pack()
  1149. self.nb.add(self.lblframe, text='Status')
  1150. self.nb.add(self.textframe1, text='Log')
  1151. self.nb.add(self.paramframe, text='Parameters')
  1152. self.nb.enable_traversal() # enable keyboard traversal using Ctrl+Tab
  1153. self.nb.pack(fill=BOTH, expand="true", padx=5, pady=1)
  1154. self.root.mainloop()
  1155. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1156. def readLog1(self):
  1157. # This function periodically reads and empties the log buffer
  1158. global log1_buffer
  1159. if log1_buffer != "":
  1160. self.text1.insert(END, log1_buffer)
  1161. text = self.my_io_process.read_file()
  1162. if text != "":
  1163. self.text1.insert(END, text)
  1164. if log1_buffer != "" or text != "": # if log buffer was populated
  1165. self.text1.yview_pickplace("end") # move the scrollbar to the bottom
  1166. log1_buffer = "" # empty the log buffer
  1167. self.root.update() # update the screen
  1168. self.root.after(100, self.readLog1)
  1169. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1170. def set_param_frame(self):
  1171. global params_dict
  1172. self.L = []
  1173. self.E = []
  1174. count = 1
  1175. for key,value in params_dict.iteritems():
  1176. lbl = Label(self.paramframe, text=key)
  1177. enty = Entry(self.paramframe, bd = 4)
  1178. enty.delete(0, END)
  1179. enty.insert(0,value)
  1180. enty.config(state=DISABLED)
  1181. lbl.grid(row=count, sticky=W)
  1182. enty.grid(row=count, column=1)
  1183. self.L.append(lbl)
  1184. self.E.append(enty)
  1185. count = count + 1
  1186. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1187. def start(self):
  1188. global step_status
  1189. running=True
  1190. #self.counter_label()
  1191. #step_status = ['x', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns'] #
  1192. step_status = ['x', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns', 'ns'] #
  1193. self.button1.config(state=DISABLED) # disable the start button
  1194. self.text1.delete('1.0', 'end') # delete the log
  1195. self.my_io_process.reset_counter()
  1196. self.thread_list['thread'] = MasterThread(self)
  1197. self.thread_list['thread'].start()
  1198. self.manage()
  1199. self.manage_lblframe()
  1200. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1201. def manage(self):
  1202. # manage the pop-up dialog boxes
  1203. global step_status
  1204. total_no_of_steps = len(step_status) - 1
  1205. flag = 0
  1206. count = 0
  1207. for i in range(1,total_no_of_steps+1):
  1208. if step_status[i] == 'f': # if failed
  1209. #tkMessageBox.showinfo("Message Box", "Error on Step " + str(i) + "! See Log for details.")
  1210. print1("Error on Step " + str(i) + "! See Log for details.")
  1211. flag = 1
  1212. time.sleep(1)
  1213. write_log_to_file(self.text1.get('1.0', 'end'))
  1214. print1("Log written to the external txt file under ./Logs/")
  1215. if step_status[i] == 'p' or step_status[i] == 'f': # if passed
  1216. count = count + 1
  1217. if count == total_no_of_steps: # if all the steps were successful
  1218. flag = 1
  1219. tkMessageBox.showinfo("Message Box", "Test succesfully done!") #Please safely remove the device from the chamber.
  1220. print1("Test succesfully done! Please safely remove the device from the chamber.")
  1221. time.sleep(1)
  1222. write_log_to_file(self.text1.get('1.0', 'end'))
  1223. print1("Log written to the external txt file under ./Logs/")
  1224. self.running=False
  1225. self.counter=0
  1226. if flag == 0: # if not(any step failed or all steps passed)
  1227. self.root.after(500, self.manage)
  1228. else: # if any step has failed or if all the steps have passed
  1229. self.button1.config(state=NORMAL) # enable the start button
  1230. self.my_io_process.empty_file()
  1231. return 0
  1232. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1233. def manage_lblframe(self):
  1234. # manage the frame that displays the step-by-step status
  1235. # manage the top-level status Label
  1236. global step_status
  1237. global device_info
  1238. global result_msg
  1239. total_no_of_steps = len(step_status) - 1
  1240. try:
  1241. SrNo = device_info['SrNo']
  1242. string = "Device: " + SrNo
  1243. self.lbl2.config(text=string)
  1244. except:
  1245. string = "Device: "
  1246. self.lbl2.config(text=string)
  1247. flag = 0
  1248. count1 = 0
  1249. count2 = 0
  1250. count3 = 0
  1251. #self.counter_label()
  1252. for i in range (1,total_no_of_steps + 1):
  1253. if step_status[i] == 'r': # if running
  1254. self.step_lbl_list[i]["text"] = "RUNNING..."
  1255. self.step_lbl_list[i]["bg"] = 'yellow'
  1256. self.lbl.config(bg='yellow')
  1257. self.lbl.config(text='RUNNING...')
  1258. self.running=True
  1259. #self.counter_label()
  1260. if step_status[i] == 'p': # if passed
  1261. self.step_lbl_list[i]["text"] = result_msg[i]
  1262. self.step_lbl_list[i]["bg"] = 'green'
  1263. count2 = count2 + 1
  1264. if step_status[i] == 'f': # if failed
  1265. self.step_lbl_list[i]["text"] = "ERROR!"
  1266. self.step_lbl_list[i]["bg"] = 'red'
  1267. self.lbl.config(bg='red')
  1268. self.lbl.config(text='ERROR!')
  1269. #flag = 1
  1270. count3 = count3 + 1
  1271. if step_status[i] == 'ns': # if not started
  1272. self.step_lbl_list[i]["text"] = "NOT STARTED"
  1273. self.step_lbl_list[i]["bg"] = 'gray'
  1274. count1 = count1 + 1
  1275. if count1 == total_no_of_steps: # if none of the steps have started
  1276. self.lbl.config(bg='gray')
  1277. self.lbl.config(text='NOT STARTED')
  1278. if count2 == total_no_of_steps: # if all the steps are done
  1279. self.lbl.config(bg='green')
  1280. self.lbl.config(text='DONE!')
  1281. flag = 1
  1282. if flag == 0: # if there is no error and all the steps aren't done yet
  1283. self.root.after(200, self.manage_lblframe)
  1284. else: # if there is an error or if all the steps are done already
  1285. device_info['SrNo'] = ""
  1286. return 0
  1287. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1288. #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  1289. if __name__ == "__main__":
  1290. g = GuiThread()
  1291. g.run()