run_test (back).py 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046
  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. b = os.popen("sh hdd-ver.sh").read().strip()
  182. a = os.popen("cat /sys/block/nvme0n1/device/firmware_rev").read()
  183. a = a.replace('\n','')
  184. a = a.replace('\r','')
  185. a = a.strip()
  186. if len(a) == 0:
  187. print1("Error! No Device found!")
  188. print1(a)
  189. step_status[step_num] = 'f' # failed
  190. else:
  191. print1(a)
  192. print1(b)
  193. step_status[step_num] = 'p' # passed
  194. result_msg[step_num] = a+b
  195. ###########################################################################
  196. def step6_routine():
  197. # os_version
  198. global step_status
  199. global result_msg
  200. step_num = 6
  201. step_status[step_num] = 'r' # running
  202. time.sleep(3)
  203. print1("\n----------------------------------------------------")
  204. print1("Step " + str(step_num) + " Started...")
  205. a = os.popen("lsb_release -rs").read().strip()
  206. print1("")
  207. if a == "22.04":
  208. print1(a)
  209. step_status[step_num] = 'p' # passed
  210. result_msg[step_num] = a
  211. else:
  212. print1("Error! No Device found!")
  213. print1(a)
  214. step_status[step_num] = 'f' # failed
  215. ###########################################################################
  216. def step7_routine():
  217. global step_status
  218. global result_msg
  219. step_num = 7
  220. step_status[step_num] = 'r' # running
  221. print1("\n----------------------------------------------------")
  222. print1("Step " + str(step_num) + " Started RTC test 1...")
  223. #step_status[step_num] = 'p' # passed
  224. #result_msg[step_num] = 'AAPASS'
  225. #return;
  226. time.sleep(1)
  227. #tkMessageBox.showinfo("Message Box", "RTC test! RTC电池测试.")
  228. a = os.popen("sh os-ver.sh RTCBATTERY").read()
  229. a = a.replace('\n','')
  230. a = a.replace('\r','')
  231. a = a.strip()
  232. print1("\n----------------------------------------------------")
  233. try:
  234. a_int = int(a)
  235. if 3000 <= a_int <= 4000:
  236. #print1("Error! No Device found!")
  237. print1(a)
  238. step_status[step_num] = 'p' # passed
  239. result_msg[step_num] = a
  240. else:
  241. print1(a)
  242. print1("Error! No Device found!")
  243. step_status[step_num] = 'f' # failed
  244. result_msg[step_num] = a
  245. except ValueError:
  246. step_status[step_num] = 'f' # failed
  247. result_msg[step_num] = "Invalid output: {a}"
  248. #else:
  249. # print1("Error! No Device found!")
  250. # print1(a)
  251. # step_status[step_num] = 'f' # failed
  252. # result_msg[step_num] = a
  253. ###########################################################################
  254. def step8_routine():
  255. global step_status
  256. global result_msg
  257. step_num = 8
  258. step_status[step_num] = 'r' # running
  259. print1("\n----------------------------------------------------")
  260. print1("Step " + str(step_num) + " Started USB test 1...")
  261. #step_status[step_num] = 'p' # passed
  262. #result_msg[step_num] = 'AAPASS'
  263. #return;
  264. time.sleep(1)
  265. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  266. a = a.replace('\n','')
  267. a = a.replace('\r','')
  268. a = a.strip()
  269. print1("\n----------------------------------------------------")
  270. try:
  271. a_int = int(a)
  272. if a_int == 1:
  273. #print1("Error! No Device found!")
  274. print1(a)
  275. step_status[step_num] = 'p' # passed
  276. result_msg[step_num] = a
  277. else:
  278. print1(a)
  279. print1("Error! No Device found!")
  280. step_status[step_num] = 'f' # failed
  281. result_msg[step_num] = a
  282. except ValueError:
  283. print1(a)
  284. print1("ValueError! No Device found!")
  285. step_status[step_num] = 'f' # failed
  286. result_msg[step_num] = "Invalid output: {a}"
  287. ###########################################################################
  288. def step9_routine():
  289. # network speed cli
  290. global step_status
  291. global result_msg
  292. step_num = 9
  293. step_status[step_num] = 'r' # running
  294. #step_status[step_num] = 'p' # passed
  295. #result_msg[step_num] = 'AAPASS'
  296. #return;
  297. #tkMessageBox.showinfo("Message Box", "RJ45网口 test! 请插入网线到指定RJ45网口中,再点确定开始测试!.")
  298. print1("\n----------------------------------------------------")
  299. print1("Step " + str(step_num) + " Started...")
  300. c = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
  301. try:
  302. c_int = int(c)
  303. if c_int == 2:
  304. #print1("Error! No Device found!")
  305. print1(c)
  306. else:
  307. print1(c)
  308. print1("Error! No Device found!")
  309. step_status[step_num] = 'f' # failed
  310. result_msg[step_num] = c
  311. return;
  312. except ValueError:
  313. print1(c)
  314. print1("ValueError! No Device found!")
  315. step_status[step_num] = 'f' # failed
  316. result_msg[step_num] = "Invalid output: {c}"
  317. return;
  318. a = os.popen("sh os-ver.sh speedcliDownload").read()
  319. a = a.replace('\n','')
  320. a = a.replace('\r','')
  321. a = a.strip()
  322. if len(a) == 0:
  323. print1("Error! No Device found!")
  324. print1(a)
  325. step_status[step_num] = 'f' # failed
  326. elif a == "Download: Upload:":
  327. print1("Error! no ethernet!")
  328. print1(a)
  329. step_status[step_num] = 'f' # failed
  330. result_msg[step_num] = a
  331. else:
  332. b = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
  333. try:
  334. b_int = int(b)
  335. if b_int == 2:
  336. #print1("Error! No Device found!")
  337. print1(b)
  338. step_status[step_num] = 'p' # passed
  339. result_msg[step_num] = a
  340. else:
  341. print1(a)
  342. print1("Error! No Device found!")
  343. step_status[step_num] = 'f' # failed
  344. result_msg[step_num] = a
  345. except ValueError:
  346. print1(a)
  347. print1("ValueError! No Device found!")
  348. step_status[step_num] = 'f' # failed
  349. result_msg[step_num] = "Invalid output: {a}"
  350. #print1(a)
  351. #step_status[step_num] = 'p' # passed
  352. #result_msg[step_num] = a
  353. ###########################################################################
  354. def step10_routine():
  355. #serialA
  356. global step_status
  357. global result_msg
  358. step_num = 10
  359. step_status[step_num] = 'r' # running
  360. print1("\n----------------------------------------------------")
  361. print1("Step " + str(step_num) + " Started serialA test 1...")
  362. #step_status[step_num] = 'p' # passed
  363. #result_msg[step_num] = 'AAPASS'
  364. #return;
  365. a = os.popen("sh pcie.sh").read().strip()
  366. #time.sleep(1)
  367. time.sleep(1)
  368. a = os.popen("sh serialport-test.sh /dev/ttyWCH0").read().strip()
  369. print1("\nsh sh serialport-test.sh /dev/ttyWCH0")
  370. try:
  371. a_int = int(a)
  372. if a_int == 1:
  373. print1(a)
  374. else:
  375. print1(a)
  376. print1("Error! No Device found!")
  377. step_status[step_num] = 'f' # failed
  378. result_msg[step_num] = a
  379. return;
  380. except ValueError:
  381. print1(a)
  382. print1("ValueError! No Device found!")
  383. step_status[step_num] = 'f' # failed
  384. result_msg[step_num] = "Invalid output: {a}"
  385. return;
  386. a = os.popen("sh serialport-test.sh /dev/ttyWCH1").read().strip()
  387. print1("\nsh sh serialport-test.sh /dev/ttyWCH1")
  388. try:
  389. a_int = int(a)
  390. if a_int == 1:
  391. print1(a)
  392. else:
  393. print1(a)
  394. print1("Error! No Device found!")
  395. step_status[step_num] = 'f' # failed
  396. result_msg[step_num] = a
  397. return;
  398. except ValueError:
  399. print1(a)
  400. print1("ValueError! No Device found!")
  401. step_status[step_num] = 'f' # failed
  402. result_msg[step_num] = "Invalid output: {a}"
  403. return;
  404. a = os.popen("sh serialport-test.sh /dev/ttyWCH2").read().strip()
  405. print1("\nsh sh serialport-test.sh /dev/ttyWCH2")
  406. try:
  407. a_int = int(a)
  408. if a_int == 1:
  409. print1(a)
  410. else:
  411. print1(a)
  412. print1("Error! No Device found!")
  413. step_status[step_num] = 'f' # failed
  414. result_msg[step_num] = a
  415. return;
  416. except ValueError:
  417. print1(a)
  418. print1("ValueError! No Device found!")
  419. step_status[step_num] = 'f' # failed
  420. result_msg[step_num] = "Invalid output: {a}"
  421. return;
  422. a = os.popen("sh serialport-test.sh /dev/ttyWCH3").read().strip()
  423. print1("\nsh serialport-test.sh /dev/ttyWCH3")
  424. try:
  425. a_int = int(a)
  426. if a_int == 1:
  427. print1(a)
  428. else:
  429. print1(a)
  430. print1("Error! No Device found!")
  431. step_status[step_num] = 'f' # failed
  432. result_msg[step_num] = a
  433. return;
  434. except ValueError:
  435. print1(a)
  436. print1("ValueError! No Device found!")
  437. step_status[step_num] = 'f' # failed
  438. result_msg[step_num] = "Invalid output: {a}"
  439. return;
  440. a = os.popen("sh serialport-test.sh /dev/ttyWCH4").read().strip()
  441. print1("\nsh serialport-test.sh /dev/ttyWCH4")
  442. try:
  443. a_int = int(a)
  444. if a_int == 1:
  445. print1(a)
  446. else:
  447. print1(a)
  448. print1("Error! No Device found!")
  449. step_status[step_num] = 'f' # failed
  450. result_msg[step_num] = a
  451. return;
  452. except ValueError:
  453. print1(a)
  454. print1("ValueError! No Device found!")
  455. step_status[step_num] = 'f' # failed
  456. result_msg[step_num] = "Invalid output: {a}"
  457. return;
  458. a = os.popen("sh serialport-test.sh /dev/ttyWCH5").read().strip()
  459. print1("\nsh serialport-test.sh /dev/ttyWCH5")
  460. try:
  461. a_int = int(a)
  462. if a_int == 1:
  463. print1(a)
  464. else:
  465. print1(a)
  466. print1("Error! No Device found!")
  467. step_status[step_num] = 'f' # failed
  468. result_msg[step_num] = a
  469. return;
  470. except ValueError:
  471. print1(a)
  472. print1("ValueError! No Device found!")
  473. step_status[step_num] = 'f' # failed
  474. result_msg[step_num] = "Invalid output: {a}"
  475. return;
  476. a = os.popen("sh serialport-test.sh /dev/ttyWCH6").read().strip()
  477. print1("\nsh serialport-test.sh /dev/ttyWCH6")
  478. try:
  479. a_int = int(a)
  480. if a_int == 1:
  481. print1(a)
  482. else:
  483. print1(a)
  484. print1("Error! No Device found!")
  485. step_status[step_num] = 'f' # failed
  486. result_msg[step_num] = a
  487. return;
  488. except ValueError:
  489. print1(a)
  490. print1("ValueError! No Device found!")
  491. step_status[step_num] = 'f' # failed
  492. result_msg[step_num] = "Invalid output: {a}"
  493. return;
  494. a = os.popen("sh serialport-test.sh /dev/ttyWCH7").read().strip()
  495. print1("\nsh serialport-test.sh /dev/ttyWCH7")
  496. try:
  497. a_int = int(a)
  498. if a_int == 1:
  499. print1(a)
  500. step_status[step_num] = 'p' # passed
  501. result_msg[step_num] = a
  502. else:
  503. print1(a)
  504. print1("Error! No Device found!")
  505. step_status[step_num] = 'f' # failed
  506. result_msg[step_num] = a
  507. return;
  508. except ValueError:
  509. print1(a)
  510. print1("ValueError! No Device found!")
  511. step_status[step_num] = 'f' # failed
  512. result_msg[step_num] = "Invalid output: {a}"
  513. return;
  514. ###########################################################################
  515. def step11_routine():
  516. #serialB
  517. global step_status
  518. global result_msg
  519. step_num = 11
  520. step_status[step_num] = 'r' # running
  521. print1("\n----------------------------------------------------")
  522. print1("Step " + str(step_num) + " Started serialA test 1...")
  523. #step_status[step_num] = 'p' # passed
  524. #result_msg[step_num] = 'AAPASS'
  525. #return;
  526. a = os.popen("sh pcie.sh").read().strip()
  527. #time.sleep(1)
  528. time.sleep(1)
  529. a = os.popen("sh serialport-test.sh /dev/ttyWCH8").read().strip()
  530. print1("\nsh sh serialport-test.sh /dev/ttyWCH8")
  531. try:
  532. a_int = int(a)
  533. if a_int == 1:
  534. print1(a)
  535. else:
  536. print1(a)
  537. print1("Error! No Device found!")
  538. step_status[step_num] = 'f' # failed
  539. result_msg[step_num] = a
  540. return;
  541. except ValueError:
  542. print1(a)
  543. print1("ValueError! No Device found!")
  544. step_status[step_num] = 'f' # failed
  545. result_msg[step_num] = "Invalid output: {a}"
  546. return;
  547. a = os.popen("sh serialport-test.sh /dev/ttyWCH9").read().strip()
  548. print1("\nsh sh serialport-test.sh /dev/ttyWCH9")
  549. try:
  550. a_int = int(a)
  551. if a_int == 1:
  552. print1(a)
  553. else:
  554. print1(a)
  555. print1("Error! No Device found!")
  556. step_status[step_num] = 'f' # failed
  557. result_msg[step_num] = a
  558. return;
  559. except ValueError:
  560. print1(a)
  561. print1("ValueError! No Device found!")
  562. step_status[step_num] = 'f' # failed
  563. result_msg[step_num] = "Invalid output: {a}"
  564. return;
  565. a = os.popen("sh serialport-test.sh /dev/ttyWCH10").read().strip()
  566. print1("\nsh sh serialport-test.sh /dev/ttyWCH10")
  567. try:
  568. a_int = int(a)
  569. if a_int == 1:
  570. print1(a)
  571. else:
  572. print1(a)
  573. print1("Error! No Device found!")
  574. step_status[step_num] = 'f' # failed
  575. result_msg[step_num] = a
  576. return;
  577. except ValueError:
  578. print1(a)
  579. print1("ValueError! No Device found!")
  580. step_status[step_num] = 'f' # failed
  581. result_msg[step_num] = "Invalid output: {a}"
  582. return;
  583. a = os.popen("sh serialport-test.sh /dev/ttyWCH11").read().strip()
  584. print1("\nsh serialport-test.sh /dev/ttyWCH11")
  585. try:
  586. a_int = int(a)
  587. if a_int == 1:
  588. print1(a)
  589. else:
  590. print1(a)
  591. print1("Error! No Device found!")
  592. step_status[step_num] = 'f' # failed
  593. result_msg[step_num] = a
  594. return;
  595. except ValueError:
  596. print1(a)
  597. print1("ValueError! No Device found!")
  598. step_status[step_num] = 'f' # failed
  599. result_msg[step_num] = "Invalid output: {a}"
  600. return;
  601. a = os.popen("sh serialport-test.sh /dev/ttyWCH12").read().strip()
  602. print1("\nsh serialport-test.sh /dev/ttyWCH12")
  603. try:
  604. a_int = int(a)
  605. if a_int == 1:
  606. print1(a)
  607. else:
  608. print1(a)
  609. print1("Error! No Device found!")
  610. step_status[step_num] = 'f' # failed
  611. result_msg[step_num] = a
  612. return;
  613. except ValueError:
  614. print1(a)
  615. print1("ValueError! No Device found!")
  616. step_status[step_num] = 'f' # failed
  617. result_msg[step_num] = "Invalid output: {a}"
  618. return;
  619. a = os.popen("sh serialport-test.sh /dev/ttyWCH13").read().strip()
  620. print1("\nsh serialport-test.sh /dev/ttyWCH13")
  621. try:
  622. a_int = int(a)
  623. if a_int == 1:
  624. print1(a)
  625. else:
  626. print1(a)
  627. print1("Error! No Device found!")
  628. step_status[step_num] = 'f' # failed
  629. result_msg[step_num] = a
  630. return;
  631. except ValueError:
  632. print1(a)
  633. print1("ValueError! No Device found!")
  634. step_status[step_num] = 'f' # failed
  635. result_msg[step_num] = "Invalid output: {a}"
  636. return;
  637. a = os.popen("sh serialport-test.sh /dev/ttyWCH14").read().strip()
  638. print1("\nsh serialport-test.sh /dev/ttyWCH14")
  639. try:
  640. a_int = int(a)
  641. if a_int == 1:
  642. print1(a)
  643. else:
  644. print1(a)
  645. print1("Error! No Device found!")
  646. step_status[step_num] = 'f' # failed
  647. result_msg[step_num] = a
  648. return;
  649. except ValueError:
  650. print1(a)
  651. print1("ValueError! No Device found!")
  652. step_status[step_num] = 'f' # failed
  653. result_msg[step_num] = "Invalid output: {a}"
  654. return;
  655. a = os.popen("sh serialport-test.sh /dev/ttyWCH15").read().strip()
  656. print1("\nsh serialport-test.sh /dev/ttyWCH15")
  657. try:
  658. a_int = int(a)
  659. if a_int == 1:
  660. print1(a)
  661. step_status[step_num] = 'p' # passed
  662. result_msg[step_num] = a
  663. else:
  664. print1(a)
  665. print1("Error! No Device found!")
  666. step_status[step_num] = 'f' # failed
  667. result_msg[step_num] = a
  668. return;
  669. except ValueError:
  670. print1(a)
  671. print1("ValueError! No Device found!")
  672. step_status[step_num] = 'f' # failed
  673. result_msg[step_num] = "Invalid output: {a}"
  674. return;
  675. ###########################################################################
  676. def step12_routine():
  677. #serialC
  678. global step_status
  679. global result_msg
  680. step_num = 12
  681. step_status[step_num] = 'r' # running
  682. print1("\n----------------------------------------------------")
  683. print1("Step " + str(step_num) + " Started serialA test 1...")
  684. #step_status[step_num] = 'p' # passed
  685. #result_msg[step_num] = 'AAPASS'
  686. #return;
  687. time.sleep(1)
  688. a = os.popen("sh serialport-test.sh /dev/ttyS0").read().strip()
  689. print1("\nsh sh serialport-test.sh /dev/ttyS0")
  690. try:
  691. a_int = int(a)
  692. if a_int == 1:
  693. print1(a)
  694. else:
  695. print1(a)
  696. print1("Error! No Device found!")
  697. step_status[step_num] = 'f' # failed
  698. result_msg[step_num] = a
  699. return;
  700. except ValueError:
  701. print1(a)
  702. print1("ValueError! No Device found!")
  703. step_status[step_num] = 'f' # failed
  704. result_msg[step_num] = "Invalid output: {a}"
  705. return;
  706. a = os.popen("sh serialport-test.sh /dev/ttyS1").read().strip()
  707. print1("\nsh sh serialport-test.sh /dev/ttyS1")
  708. try:
  709. a_int = int(a)
  710. if a_int == 1:
  711. print1(a)
  712. else:
  713. print1(a)
  714. print1("Error! No Device found!")
  715. step_status[step_num] = 'f' # failed
  716. result_msg[step_num] = a
  717. return;
  718. except ValueError:
  719. print1(a)
  720. print1("ValueError! No Device found!")
  721. step_status[step_num] = 'f' # failed
  722. result_msg[step_num] = "Invalid output: {a}"
  723. return;
  724. a = os.popen("sh serialport-test.sh /dev/ttyS2").read().strip()
  725. print1("\nsh sh serialport-test.sh /dev/ttyS2")
  726. try:
  727. a_int = int(a)
  728. if a_int == 1:
  729. print1(a)
  730. else:
  731. print1(a)
  732. print1("Error! No Device found!")
  733. step_status[step_num] = 'f' # failed
  734. result_msg[step_num] = a
  735. return;
  736. except ValueError:
  737. print1(a)
  738. print1("ValueError! No Device found!")
  739. step_status[step_num] = 'f' # failed
  740. result_msg[step_num] = "Invalid output: {a}"
  741. return;
  742. a = os.popen("sh serialport-test.sh /dev/ttyS3").read().strip()
  743. print1("\nsh serialport-test.sh /dev/ttyS3")
  744. try:
  745. a_int = int(a)
  746. if a_int == 1:
  747. print1(a)
  748. else:
  749. print1(a)
  750. print1("Error! No Device found!")
  751. step_status[step_num] = 'f' # failed
  752. result_msg[step_num] = a
  753. return;
  754. except ValueError:
  755. print1(a)
  756. print1("ValueError! No Device found!")
  757. step_status[step_num] = 'f' # failed
  758. result_msg[step_num] = "Invalid output: {a}"
  759. return;
  760. a = os.popen("sh serialport-test.sh /dev/ttyS4").read().strip()
  761. print1("\nsh serialport-test.sh /dev/ttyS4")
  762. try:
  763. a_int = int(a)
  764. if a_int == 1:
  765. print1(a)
  766. else:
  767. print1(a)
  768. print1("Error! No Device found!")
  769. step_status[step_num] = 'f' # failed
  770. result_msg[step_num] = a
  771. return;
  772. except ValueError:
  773. print1(a)
  774. print1("ValueError! No Device found!")
  775. step_status[step_num] = 'f' # failed
  776. result_msg[step_num] = "Invalid output: {a}"
  777. return;
  778. a = os.popen("sh serialport-test.sh /dev/ttyS5").read().strip()
  779. print1("\nsh serialport-test.sh /dev/ttyS5")
  780. try:
  781. a_int = int(a)
  782. if a_int == 1:
  783. print1(a)
  784. else:
  785. print1(a)
  786. print1("Error! No Device found!")
  787. step_status[step_num] = 'f' # failed
  788. result_msg[step_num] = a
  789. return;
  790. except ValueError:
  791. print1(a)
  792. print1("ValueError! No Device found!")
  793. step_status[step_num] = 'f' # failed
  794. result_msg[step_num] = "Invalid output: {a}"
  795. return;
  796. a = os.popen("sh serialport-test.sh /dev/ttyS6").read().strip()
  797. print1("\nsh serialport-test.sh /dev/ttyS6")
  798. try:
  799. a_int = int(a)
  800. if a_int == 1:
  801. print1(a)
  802. else:
  803. print1(a)
  804. print1("Error! No Device found!")
  805. step_status[step_num] = 'f' # failed
  806. result_msg[step_num] = a
  807. return;
  808. except ValueError:
  809. print1(a)
  810. print1("ValueError! No Device found!")
  811. step_status[step_num] = 'f' # failed
  812. result_msg[step_num] = "Invalid output: {a}"
  813. return;
  814. a = os.popen("sh serialport-test.sh /dev/ttyS7").read().strip()
  815. print1("\nsh serialport-test.sh /dev/ttyS7")
  816. try:
  817. a_int = int(a)
  818. if a_int == 1:
  819. print1(a)
  820. step_status[step_num] = 'p' # passed
  821. result_msg[step_num] = a
  822. else:
  823. print1(a)
  824. print1("Error! No Device found!")
  825. step_status[step_num] = 'f' # failed
  826. result_msg[step_num] = a
  827. return;
  828. except ValueError:
  829. print1(a)
  830. print1("ValueError! No Device found!")
  831. step_status[step_num] = 'f' # failed
  832. result_msg[step_num] = "Invalid output: {a}"
  833. return;
  834. ###########################################################################
  835. def step13_routine():
  836. #LCD Test
  837. global step_status
  838. global result_msg
  839. step_num = 13
  840. step_status[step_num] = 'r' # running
  841. print1("\n----------------------------------------------------")
  842. print1("Step " + str(step_num) + " Started lcd test 1...")
  843. #step_status[step_num] = 'p' # passed
  844. #result_msg[step_num] = 'AAPASS'
  845. #return;
  846. time.sleep(1)
  847. a = os.popen("./lcd/lcd/lcd_app | grep -c \"LCD test completed\"").read()
  848. a = a.replace('\n','')
  849. a = a.replace('\r','')
  850. a = a.strip()
  851. print1("\n----------------------------------------------------")
  852. try:
  853. a_int = int(a)
  854. if a_int == 1:
  855. #print1("Error! No Device found!")
  856. print1(a)
  857. step_status[step_num] = 'p' # passed
  858. result_msg[step_num] = a
  859. else:
  860. print1(a)
  861. print1("Error! No Device found!")
  862. step_status[step_num] = 'f' # failed
  863. result_msg[step_num] = a
  864. except ValueError:
  865. print1(a)
  866. print1("ValueError! No Device found!")
  867. step_status[step_num] = 'f' # failed
  868. result_msg[step_num] = "Invalid output: {a}"
  869. ###########################################################################
  870. def step14_routine():
  871. #LED Test
  872. global step_status
  873. global result_msg
  874. step_num = 14
  875. step_status[step_num] = 'r' # running
  876. print1("\n----------------------------------------------------")
  877. print1("Step " + str(step_num) + " Started LED test 1...")
  878. #step_status[step_num] = 'p' # passed
  879. #result_msg[step_num] = 'AAPASS'
  880. #return;
  881. time.sleep(1)
  882. a = os.popen("sh led-test.sh | tail -1").read()
  883. a = a.replace('\n','')
  884. a = a.replace('\r','')
  885. a = a.strip()
  886. print1("\n----------------------------------------------------")
  887. try:
  888. a_int = int(a)
  889. if a_int == 1:
  890. #print1("Error! No Device found!")
  891. print1(a)
  892. step_status[step_num] = 'p' # passed
  893. result_msg[step_num] = a
  894. else:
  895. print1(a)
  896. print1("Error! No Device found!")
  897. step_status[step_num] = 'f' # failed
  898. result_msg[step_num] = a
  899. except ValueError:
  900. print1(a)
  901. print1("ValueError! No Device found!")
  902. step_status[step_num] = 'f' # failed
  903. result_msg[step_num] = "Invalid output: {a}"
  904. ###########################################################################
  905. def step15_routine():
  906. global step_status
  907. global result_msg
  908. step_num = 15
  909. step_status[step_num] = 'r' # running
  910. print1("\n----------------------------------------------------")
  911. print1("Step " + str(step_num) + " Started 检查电池健康指示灯功能测试 test 1...")
  912. #step_status[step_num] = 'p' # passed
  913. #result_msg[step_num] = 'AAPASS'
  914. #return;
  915. time.sleep(1)
  916. a = os.popen("sh led-test.sh | tail -1").read()
  917. a = a.replace('\n','')
  918. a = a.replace('\r','')
  919. a = a.strip()
  920. print1("\n----------------------------------------------------")
  921. try:
  922. a_int = int(a)
  923. if a_int == 1:
  924. #print1("Error! No Device found!")
  925. print1(a)
  926. step_status[step_num] = 'p' # passed
  927. result_msg[step_num] = a
  928. else:
  929. print1(a)
  930. print1("Error! No Device found!")
  931. step_status[step_num] = 'f' # failed
  932. result_msg[step_num] = a
  933. except ValueError:
  934. print1(a)
  935. print1("ValueError! No Device found!")
  936. step_status[step_num] = 'f' # failed
  937. result_msg[step_num] = "Invalid output: {a}"
  938. ###########################################################################
  939. def step16_routine():
  940. global step_status
  941. global result_msg
  942. step_num = 16
  943. step_status[step_num] = 'r' # running
  944. print1("\n----------------------------------------------------")
  945. print1("Step " + str(step_num) + " Started 检查dip_switch功能测试 test 1...")
  946. step_status[step_num] = 'p' # passed
  947. result_msg[step_num] = 'AAPASS'
  948. return;
  949. time.sleep(1)
  950. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  951. a = a.replace('\n','')
  952. a = a.replace('\r','')
  953. a = a.strip()
  954. print1("\n----------------------------------------------------")
  955. try:
  956. a_int = int(a)
  957. if a_int == 2:
  958. #print1("Error! No Device found!")
  959. print1(a)
  960. step_status[step_num] = 'p' # passed
  961. result_msg[step_num] = a
  962. else:
  963. print1(a)
  964. print1("Error! No Device found!")
  965. step_status[step_num] = 'f' # failed
  966. result_msg[step_num] = a
  967. except ValueError:
  968. print1(a)
  969. print1("ValueError! No Device found!")
  970. step_status[step_num] = 'f' # failed
  971. result_msg[step_num] = "Invalid output: {a}"
  972. ###########################################################################
  973. def step17_routine():
  974. global step_status
  975. global result_msg
  976. step_num = 17
  977. step_status[step_num] = 'r' # running
  978. print1("\n----------------------------------------------------")
  979. print1("Step " + str(step_num) + " Started Console接口测试 test 1...")
  980. step_status[step_num] = 'p' # passed
  981. result_msg[step_num] = 'AAPASS'
  982. return;
  983. time.sleep(1)
  984. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  985. a = a.replace('\n','')
  986. a = a.replace('\r','')
  987. a = a.strip()
  988. print1("\n----------------------------------------------------")
  989. try:
  990. a_int = int(a)
  991. if a_int == 2:
  992. #print1("Error! No Device found!")
  993. print1(a)
  994. step_status[step_num] = 'p' # passed
  995. result_msg[step_num] = a
  996. else:
  997. print1(a)
  998. print1("Error! No Device found!")
  999. step_status[step_num] = 'f' # failed
  1000. result_msg[step_num] = a
  1001. except ValueError:
  1002. print1(a)
  1003. print1("ValueError! No Device found!")
  1004. step_status[step_num] = 'f' # failed
  1005. result_msg[step_num] = "Invalid output: {a}"
  1006. ###########################################################################
  1007. def step18_routine():
  1008. global step_status
  1009. global result_msg
  1010. step_num = 18
  1011. step_status[step_num] = 'r' # running
  1012. print1("\n----------------------------------------------------")
  1013. print1("Step " + str(step_num) + " Started Buzzer test 1...")
  1014. #step_status[step_num] = 'p' # passed
  1015. #result_msg[step_num] = 'AAPASS'
  1016. #return;
  1017. time.sleep(1)
  1018. a = os.popen("sh beep.sh").read()
  1019. a = a.replace('\n','')
  1020. a = a.replace('\r','')
  1021. a = a.strip()
  1022. print1("\n----------------------------------------------------")
  1023. if tkMessageBox.askokcancel("PASS?", "测试蜂鸣器是否正常."):
  1024. print1(a)
  1025. step_status[step_num] = 'p' # passed
  1026. result_msg[step_num] = 'PASS'
  1027. return;
  1028. a = a.replace('\n','')
  1029. a = a.replace('\r','')
  1030. a = a.strip()
  1031. print1("Error! No Device found!")
  1032. print1(a)
  1033. step_status[step_num] = 'f' # failed
  1034. result_msg[step_num] = "FAIL"
  1035. ###########################################################################
  1036. def step19_routine():
  1037. global step_status
  1038. global result_msg
  1039. step_num = 19
  1040. step_status[step_num] = 'r' # running
  1041. print1("\n----------------------------------------------------")
  1042. print1("Step " + str(step_num) + " Started SATA_SSD基本功能测试 test 1...")
  1043. step_status[step_num] = 'p' # passed
  1044. result_msg[step_num] = 'AAPASS'
  1045. return;
  1046. time.sleep(1)
  1047. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  1048. a = a.replace('\n','')
  1049. a = a.replace('\r','')
  1050. a = a.strip()
  1051. print1("\n----------------------------------------------------")
  1052. try:
  1053. a_int = int(a)
  1054. if a_int == 2:
  1055. #print1("Error! No Device found!")
  1056. print1(a)
  1057. step_status[step_num] = 'p' # passed
  1058. result_msg[step_num] = a
  1059. else:
  1060. print1(a)
  1061. print1("Error! No Device found!")
  1062. step_status[step_num] = 'f' # failed
  1063. result_msg[step_num] = a
  1064. except ValueError:
  1065. print1(a)
  1066. print1("ValueError! No Device found!")
  1067. step_status[step_num] = 'f' # failed
  1068. result_msg[step_num] = "Invalid output: {a}"
  1069. ###########################################################################
  1070. def step20_routine():
  1071. global step_status
  1072. global result_msg
  1073. step_num = 20
  1074. step_status[step_num] = 'r' # running
  1075. print1("\n----------------------------------------------------")
  1076. print1("Step " + str(step_num) + " Started USB test 1...")
  1077. step_status[step_num] = 'p' # passed
  1078. result_msg[step_num] = 'AAPASS'
  1079. return;
  1080. time.sleep(1)
  1081. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  1082. a = a.replace('\n','')
  1083. a = a.replace('\r','')
  1084. a = a.strip()
  1085. print1("\n----------------------------------------------------")
  1086. try:
  1087. a_int = int(a)
  1088. if a_int == 2:
  1089. #print1("Error! No Device found!")
  1090. print1(a)
  1091. step_status[step_num] = 'p' # passed
  1092. result_msg[step_num] = a
  1093. else:
  1094. print1(a)
  1095. print1("Error! No Device found!")
  1096. step_status[step_num] = 'f' # failed
  1097. result_msg[step_num] = a
  1098. except ValueError:
  1099. print1(a)
  1100. print1("ValueError! No Device found!")
  1101. step_status[step_num] = 'f' # failed
  1102. result_msg[step_num] = "Invalid output: {a}"
  1103. ###########################################################################
  1104. def step21_routine():
  1105. global step_status
  1106. global result_msg
  1107. step_num = 21
  1108. step_status[step_num] = 'r' # running
  1109. print1("\n----------------------------------------------------")
  1110. print1("Step " + str(step_num) + " Started USB test 1...")
  1111. #step_status[step_num] = 'p' # passed
  1112. #result_msg[step_num] = 'AAPASS'
  1113. #return;
  1114. time.sleep(1)
  1115. a = os.popen("sh seven_segment_display.sh").read()
  1116. a = a.replace('\n','')
  1117. a = a.replace('\r','')
  1118. a = a.strip()
  1119. print1("\n----------------------------------------------------")
  1120. if tkMessageBox.askokcancel("PASS?", "测试数码管是否正常."):
  1121. print1(a)
  1122. step_status[step_num] = 'p' # passed
  1123. result_msg[step_num] = 'PASS'
  1124. return;
  1125. a = a.replace('\n','')
  1126. a = a.replace('\r','')
  1127. a = a.strip()
  1128. print1("Error! No Device found!")
  1129. print1(a)
  1130. step_status[step_num] = 'f' # failed
  1131. result_msg[step_num] = "FAIL"
  1132. ###########################################################################
  1133. def step22_routine():
  1134. global step_status
  1135. global result_msg
  1136. step_num = 22
  1137. step_status[step_num] = 'r' # running
  1138. print1("\n----------------------------------------------------")
  1139. print1("Step " + str(step_num) + " Started USB test 1...")
  1140. step_status[step_num] = 'p' # passed
  1141. result_msg[step_num] = 'AAPASS'
  1142. return;
  1143. time.sleep(1)
  1144. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  1145. a = a.replace('\n','')
  1146. a = a.replace('\r','')
  1147. a = a.strip()
  1148. print1("\n----------------------------------------------------")
  1149. try:
  1150. a_int = int(a)
  1151. if a_int == 2:
  1152. #print1("Error! No Device found!")
  1153. print1(a)
  1154. step_status[step_num] = 'p' # passed
  1155. result_msg[step_num] = a
  1156. else:
  1157. print1(a)
  1158. print1("Error! No Device found!")
  1159. step_status[step_num] = 'f' # failed
  1160. result_msg[step_num] = a
  1161. except ValueError:
  1162. print1(a)
  1163. print1("ValueError! No Device found!")
  1164. step_status[step_num] = 'f' # failed
  1165. result_msg[step_num] = "Invalid output: {a}"
  1166. ###########################################################################
  1167. def step23_routine():
  1168. global step_status
  1169. global result_msg
  1170. step_num = 23
  1171. step_status[step_num] = 'r' # running
  1172. print1("\n----------------------------------------------------")
  1173. print1("Step " + str(step_num) + " Started USB test 1...")
  1174. step_status[step_num] = 'p' # passed
  1175. result_msg[step_num] = 'AAPASS'
  1176. return;
  1177. time.sleep(1)
  1178. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  1179. a = a.replace('\n','')
  1180. a = a.replace('\r','')
  1181. a = a.strip()
  1182. print1("\n----------------------------------------------------")
  1183. try:
  1184. a_int = int(a)
  1185. if a_int == 2:
  1186. #print1("Error! No Device found!")
  1187. print1(a)
  1188. step_status[step_num] = 'p' # passed
  1189. result_msg[step_num] = a
  1190. else:
  1191. print1(a)
  1192. print1("Error! No Device found!")
  1193. step_status[step_num] = 'f' # failed
  1194. result_msg[step_num] = a
  1195. except ValueError:
  1196. print1(a)
  1197. print1("ValueError! No Device found!")
  1198. step_status[step_num] = 'f' # failed
  1199. result_msg[step_num] = "Invalid output: {a}"
  1200. ###########################################################################
  1201. def step24_routine():
  1202. global step_status
  1203. global result_msg
  1204. step_num = 24
  1205. step_status[step_num] = 'r' # running
  1206. print1("\n----------------------------------------------------")
  1207. print1("Step " + str(step_num) + " Started USB test 1...")
  1208. step_status[step_num] = 'p' # passed
  1209. result_msg[step_num] = 'AAPASS'
  1210. return;
  1211. time.sleep(1)
  1212. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  1213. a = a.replace('\n','')
  1214. a = a.replace('\r','')
  1215. a = a.strip()
  1216. print1("\n----------------------------------------------------")
  1217. try:
  1218. a_int = int(a)
  1219. if a_int == 2:
  1220. #print1("Error! No Device found!")
  1221. print1(a)
  1222. step_status[step_num] = 'p' # passed
  1223. result_msg[step_num] = a
  1224. else:
  1225. print1(a)
  1226. print1("Error! No Device found!")
  1227. step_status[step_num] = 'f' # failed
  1228. result_msg[step_num] = a
  1229. except ValueError:
  1230. print1(a)
  1231. print1("ValueError! No Device found!")
  1232. step_status[step_num] = 'f' # failed
  1233. result_msg[step_num] = "Invalid output: {a}"
  1234. ###########################################################################
  1235. def step25_routine():
  1236. global step_status
  1237. global result_msg
  1238. step_num = 25
  1239. step_status[step_num] = 'r' # running
  1240. print1("\n----------------------------------------------------")
  1241. print1("Step " + str(step_num) + " Started USB test 1...")
  1242. step_status[step_num] = 'p' # passed
  1243. result_msg[step_num] = 'AAPASS'
  1244. return;
  1245. time.sleep(1)
  1246. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  1247. a = a.replace('\n','')
  1248. a = a.replace('\r','')
  1249. a = a.strip()
  1250. print1("\n----------------------------------------------------")
  1251. try:
  1252. a_int = int(a)
  1253. if a_int == 2:
  1254. #print1("Error! No Device found!")
  1255. print1(a)
  1256. step_status[step_num] = 'p' # passed
  1257. result_msg[step_num] = a
  1258. else:
  1259. print1(a)
  1260. print1("Error! No Device found!")
  1261. step_status[step_num] = 'f' # failed
  1262. result_msg[step_num] = a
  1263. except ValueError:
  1264. print1(a)
  1265. print1("ValueError! No Device found!")
  1266. step_status[step_num] = 'f' # failed
  1267. result_msg[step_num] = "Invalid output: {a}"
  1268. ###########################################################################
  1269. def step26_routine():
  1270. global step_status
  1271. global result_msg
  1272. step_num = 26
  1273. step_status[step_num] = 'r' # running
  1274. print1("\n----------------------------------------------------")
  1275. print1("Step " + str(step_num) + " Started USB test 1...")
  1276. step_status[step_num] = 'p' # passed
  1277. result_msg[step_num] = 'AAPASS'
  1278. return;
  1279. time.sleep(1)
  1280. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  1281. a = a.replace('\n','')
  1282. a = a.replace('\r','')
  1283. a = a.strip()
  1284. print1("\n----------------------------------------------------")
  1285. try:
  1286. a_int = int(a)
  1287. if a_int == 2:
  1288. #print1("Error! No Device found!")
  1289. print1(a)
  1290. step_status[step_num] = 'p' # passed
  1291. result_msg[step_num] = a
  1292. else:
  1293. print1(a)
  1294. print1("Error! No Device found!")
  1295. step_status[step_num] = 'f' # failed
  1296. result_msg[step_num] = a
  1297. except ValueError:
  1298. print1(a)
  1299. print1("ValueError! No Device found!")
  1300. step_status[step_num] = 'f' # failed
  1301. result_msg[step_num] = "Invalid output: {a}"
  1302. ###########################################################################
  1303. def step27_routine():
  1304. global step_status
  1305. global result_msg
  1306. step_num = 27
  1307. step_status[step_num] = 'r' # running
  1308. print1("\n----------------------------------------------------")
  1309. print1("Step " + str(step_num) + " Started USB test 1...")
  1310. step_status[step_num] = 'p' # passed
  1311. result_msg[step_num] = 'AAPASS'
  1312. return;
  1313. time.sleep(1)
  1314. a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read()
  1315. a = a.replace('\n','')
  1316. a = a.replace('\r','')
  1317. a = a.strip()
  1318. print1("\n----------------------------------------------------")
  1319. try:
  1320. a_int = int(a)
  1321. if a_int == 2:
  1322. #print1("Error! No Device found!")
  1323. print1(a)
  1324. step_status[step_num] = 'p' # passed
  1325. result_msg[step_num] = a
  1326. else:
  1327. print1(a)
  1328. print1("Error! No Device found!")
  1329. step_status[step_num] = 'f' # failed
  1330. result_msg[step_num] = a
  1331. except ValueError:
  1332. print1(a)
  1333. print1("ValueError! No Device found!")
  1334. step_status[step_num] = 'f' # failed
  1335. result_msg[step_num] = "Invalid output: {a}"
  1336. ###########################################################################
  1337. def step28_routine():
  1338. global step_status
  1339. global result_msg
  1340. step_num = 28
  1341. step_status[step_num] = 'r' # running
  1342. print1("\n----------------------------------------------------")
  1343. print1("Step " + str(step_num) + " Started RTC test 1...")
  1344. step_status[step_num] = 'p' # passed
  1345. result_msg[step_num] = 'AAPASS'
  1346. return;
  1347. time.sleep(1)
  1348. #tkMessageBox.showinfo("Message Box", "RTC test! RTC电池测试.")
  1349. a = os.popen("sh os-ver.sh RTCBATTERY").read()
  1350. a = a.replace('\n','')
  1351. a = a.replace('\r','')
  1352. a = a.strip()
  1353. print1("\n----------------------------------------------------")
  1354. try:
  1355. a_int = int(a)
  1356. if 3000 <= a_int <= 4000:
  1357. #print1("Error! No Device found!")
  1358. print1(a)
  1359. step_status[step_num] = 'p' # passed
  1360. result_msg[step_num] = a
  1361. else:
  1362. print1(a)
  1363. print1("Error! No Device found!")
  1364. step_status[step_num] = 'f' # failed
  1365. result_msg[step_num] = a
  1366. except ValueError:
  1367. step_status[step_num] = 'f' # failed
  1368. result_msg[step_num] = "Invalid output: {a}"
  1369. #else:
  1370. # print1("Error! No Device found!")
  1371. # print1(a)
  1372. # step_status[step_num] = 'f' # failed
  1373. # result_msg[step_num] = a
  1374. ###########################################################################
  1375. """
  1376. """
  1377. #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  1378. class MasterThread(threading.Thread):
  1379. def __init__(self, guiobj):
  1380. super(MasterThread, self).__init__()
  1381. def run(self):
  1382. global step_status
  1383. global script_ver
  1384. print1("X86 C180####################################################",1)
  1385. print1(script_ver)
  1386. step1_routine()
  1387. if step_status[1] == 'p' or step_status[1] == 'f': # if step 1 passed
  1388. step2_routine()
  1389. if step_status[2] == 'p' or step_status[2] == 'f':
  1390. step3_routine()
  1391. if step_status[3] == 'p' or step_status[3] == 'f':
  1392. step4_routine()
  1393. if step_status[4] == 'p' or step_status[4] == 'f':
  1394. step5_routine()
  1395. if step_status[5] == 'p' or step_status[5] == 'f':
  1396. step6_routine()
  1397. if step_status[6] == 'p' or step_status[6] == 'f':
  1398. step7_routine()
  1399. if step_status[7] == 'p' or step_status[7] == 'f':
  1400. step8_routine()
  1401. if step_status[8] == 'p' or step_status[8] == 'f':
  1402. step9_routine()
  1403. if step_status[9] == 'p' or step_status[9] == 'f':
  1404. step10_routine()
  1405. if step_status[10] == 'p' or step_status[10] == 'f':
  1406. step11_routine()
  1407. if step_status[11] == 'p' or step_status[11] == 'f':
  1408. step12_routine()
  1409. if step_status[12] == 'p' or step_status[12] == 'f':
  1410. step13_routine()
  1411. if step_status[13] == 'p' or step_status[13] == 'f':
  1412. step14_routine()
  1413. if step_status[14] == 'p' or step_status[14] == 'f':
  1414. step15_routine()
  1415. if step_status[15] == 'p' or step_status[15] == 'f':
  1416. step16_routine()
  1417. if step_status[16] == 'p' or step_status[16] == 'f':
  1418. step17_routine()
  1419. if step_status[17] == 'p' or step_status[17] == 'f':
  1420. step18_routine()
  1421. if step_status[18] == 'p' or step_status[18] == 'f':
  1422. step19_routine()
  1423. if step_status[19] == 'p' or step_status[19] == 'f':
  1424. step20_routine()
  1425. if step_status[20] == 'p' or step_status[20] == 'f':
  1426. step21_routine()
  1427. if step_status[21] == 'p' or step_status[21] == 'f':
  1428. step22_routine()
  1429. if step_status[22] == 'p' or step_status[22] == 'f':
  1430. step23_routine()
  1431. if step_status[23] == 'p' or step_status[23] == 'f':
  1432. step24_routine()
  1433. if step_status[24] == 'p' or step_status[24] == 'f':
  1434. step25_routine()
  1435. if step_status[25] == 'p' or step_status[25] == 'f':
  1436. step26_routine()
  1437. if step_status[26] == 'p' or step_status[26] == 'f':
  1438. step27_routine()
  1439. if step_status[27] == 'p' or step_status[27] == 'f':
  1440. step28_routine()
  1441. print1("\n----------------------------------------------------")
  1442. print1("Test concluded!")
  1443. #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  1444. class GuiThread(object):
  1445. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1446. def __init__(self):
  1447. global log_file
  1448. global result_msg
  1449. self.thread_list = {}
  1450. self.running=False
  1451. self.counter=0
  1452. self.root = Tk()
  1453. self.root.geometry("1800x1200")
  1454. self.root.protocol("WM_DELETE_WINDOW", self.destroy) # when user closes the window
  1455. self.root.title("WiPER: FT Simular Test")
  1456. self.note1 = Label(self.root, text="Please press 'Start Test' to begin...", fg='blue')
  1457. self.button1 = Button(self.root, text="Start Test", command=self.start)
  1458. self.lbl = Label(self.root, text="NOT STARTED", width=15, bg='gray')
  1459. self.lbl2 = Label(self.root, text="Device: ",width=20,bg="#C6EBFF")
  1460. self.nb = ttk.Notebook(self.root, name='notebook')
  1461. self.textframe1 = Frame(self.root)
  1462. self.text1 = Text(self.textframe1)
  1463. self.scrollbar1 = Scrollbar(self.textframe1)
  1464. self.paramframe = Frame(self.root)
  1465. self.lblframe = Frame(self.root)
  1466. #self.step1_lbl1 = Label(self.lblframe, text="Step1: Check BIOS Version ", width=50)
  1467. self.step1_lbl1 = Label(self.lblframe, text="Step1: 检查BIOS版本号 ", width=50)
  1468. self.step2_lbl1 = Label(self.lblframe, text="Step2: 检查EC版本号 ", width=50)
  1469. self.step3_lbl1 = Label(self.lblframe, text="Step3: 检查CPU测试 ", width=50)
  1470. self.step4_lbl1 = Label(self.lblframe, text="Step4: 检查Memory内存版本号 ", width=50)
  1471. self.step5_lbl1 = Label(self.lblframe, text="Step5: 检查HDD硬盘版本号 ", width=50)
  1472. self.step6_lbl1 = Label(self.lblframe, text="Step6: 检查OS操作系统版本号 ", width=50)
  1473. self.step7_lbl1 = Label(self.lblframe, text="Step7: RTC电池 ", width=50)
  1474. self.step8_lbl1 = Label(self.lblframe, text="Step8: USB基本功能测试 ", width=50)
  1475. self.step9_lbl1 = Label(self.lblframe, text="Step9: 检查网络在线速度测试 ", width=50)
  1476. self.step10_lbl1 = Label(self.lblframe, text="Step10: 串口A基本功能测试 ", width=50)
  1477. self.step11_lbl1 = Label(self.lblframe, text="Step11: 串口B本功能测试 ", width=50)
  1478. self.step12_lbl1 = Label(self.lblframe, text="Step12: 串口C本功能测试 ", width=50)
  1479. self.step13_lbl1 = Label(self.lblframe, text="Step13: lcd测试 ", width=50)
  1480. self.step14_lbl1 = Label(self.lblframe, text="Step14: led测试 ", width=50)
  1481. self.step15_lbl1 = Label(self.lblframe, text="Step15: 检查电池健康指示灯功能测试 ", width=50)
  1482. self.step16_lbl1 = Label(self.lblframe, text="Step16: 检查dip_switch功能测试 ", width=50)
  1483. self.step17_lbl1 = Label(self.lblframe, text="Step17: Console接口测试 ", width=50)
  1484. self.step18_lbl1 = Label(self.lblframe, text="Step18: Buzzer基本功能测试 ", width=50)
  1485. self.step19_lbl1 = Label(self.lblframe, text="Step19: SATA_SSD基本功能测试 ", width=50)
  1486. self.step20_lbl1 = Label(self.lblframe, text="Step20: HeadBest_Test ", width=50)
  1487. self.step21_lbl1 = Label(self.lblframe, text="Step21: Seven_Segment_Display_Test ", width=50)
  1488. self.step22_lbl1 = Label(self.lblframe, text="Step22: CPUFan_Test ", width=50)
  1489. self.step23_lbl1 = Label(self.lblframe, text="Step23: 检查带网口hub的usb3.0接口1号基本功能测试 ", width=50)
  1490. self.step24_lbl1 = Label(self.lblframe, text="Step24: 检查带网口hub的usb3.0接口2号基本功能测试 ", width=50)
  1491. self.step25_lbl1 = Label(self.lblframe, text="Step25: 电池健康指示灯/充电指示灯/心跳灯 ", width=50)
  1492. self.step26_lbl1 = Label(self.lblframe, text="Step26: 外置键盘测试C180 ", width=50)
  1493. self.step27_lbl1 = Label(self.lblframe, text="Step27: 触摸板测试C180 ", width=50)
  1494. self.step28_lbl1 = Label(self.lblframe, text="Step28: SYSFan_Test ", width=50)
  1495. self.step1_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1496. self.step2_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1497. self.step3_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1498. self.step4_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1499. self.step5_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1500. self.step6_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1501. self.step7_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1502. self.step8_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1503. self.step9_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1504. self.step10_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1505. self.step11_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1506. self.step12_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1507. self.step13_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1508. self.step14_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1509. self.step15_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1510. self.step16_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1511. self.step17_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1512. self.step18_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1513. self.step19_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1514. self.step20_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1515. self.step21_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1516. self.step22_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1517. self.step23_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1518. self.step24_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1519. self.step25_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1520. self.step26_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1521. self.step27_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1522. self.step28_lbl2 = Label(self.lblframe, text="NOT STARTED", bg='gray', width=50)
  1523. self.step_lbl_list = []
  1524. self.step_lbl_list.append('x') # don't care
  1525. self.step_lbl_list.append(self.step1_lbl2)
  1526. self.step_lbl_list.append(self.step2_lbl2)
  1527. self.step_lbl_list.append(self.step3_lbl2)
  1528. self.step_lbl_list.append(self.step4_lbl2)
  1529. self.step_lbl_list.append(self.step5_lbl2)
  1530. self.step_lbl_list.append(self.step6_lbl2)
  1531. self.step_lbl_list.append(self.step7_lbl2)
  1532. self.step_lbl_list.append(self.step8_lbl2)
  1533. self.step_lbl_list.append(self.step9_lbl2)
  1534. self.step_lbl_list.append(self.step10_lbl2)
  1535. self.step_lbl_list.append(self.step11_lbl2)
  1536. self.step_lbl_list.append(self.step12_lbl2)
  1537. self.step_lbl_list.append(self.step13_lbl2)
  1538. self.step_lbl_list.append(self.step14_lbl2)
  1539. self.step_lbl_list.append(self.step15_lbl2)
  1540. self.step_lbl_list.append(self.step16_lbl2)
  1541. self.step_lbl_list.append(self.step17_lbl2)
  1542. self.step_lbl_list.append(self.step18_lbl2)
  1543. self.step_lbl_list.append(self.step19_lbl2)
  1544. self.step_lbl_list.append(self.step20_lbl2)
  1545. self.step_lbl_list.append(self.step21_lbl2)
  1546. self.step_lbl_list.append(self.step22_lbl2)
  1547. self.step_lbl_list.append(self.step23_lbl2)
  1548. self.step_lbl_list.append(self.step24_lbl2)
  1549. self.step_lbl_list.append(self.step25_lbl2)
  1550. self.step_lbl_list.append(self.step26_lbl2)
  1551. self.step_lbl_list.append(self.step27_lbl2)
  1552. self.step_lbl_list.append(self.step28_lbl2)
  1553. result_msg.append('P')
  1554. result_msg.append('P')
  1555. result_msg.append('P')
  1556. result_msg.append('P')
  1557. result_msg.append('P')
  1558. result_msg.append('P')
  1559. result_msg.append('P')
  1560. result_msg.append('P')
  1561. result_msg.append('P')
  1562. result_msg.append('P')
  1563. result_msg.append('P')
  1564. result_msg.append('P')
  1565. result_msg.append('P')
  1566. result_msg.append('P')
  1567. result_msg.append('P')
  1568. result_msg.append('P')
  1569. result_msg.append('P')
  1570. result_msg.append('P')
  1571. result_msg.append('P')
  1572. result_msg.append('P')
  1573. result_msg.append('P')
  1574. result_msg.append('P')
  1575. result_msg.append('P')
  1576. result_msg.append('P')
  1577. result_msg.append('P')
  1578. result_msg.append('P')
  1579. result_msg.append('P')
  1580. result_msg.append('P')
  1581. result_msg.append('P')
  1582. self.my_io_process = IO_process(log_file)
  1583. self.readLog1()
  1584. self.set_param_frame()
  1585. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1586. def destroy(self):
  1587. if tkMessageBox.askokcancel("Quit?", "Are you sure you want to quit?"):
  1588. self.root.quit()
  1589. def counter_label(self):
  1590. def count():
  1591. if self.running:
  1592. global counter
  1593. if self.counter==0: #66600
  1594. display="Starting..."
  1595. else:
  1596. tt=datetime.fromtimestamp(self.counter)
  1597. string=tt.strftime("%H:%M:%S")
  1598. display=string
  1599. self.note1.config(text=display)
  1600. self.note1.after(1000, count)
  1601. self.counter+=1
  1602. count()
  1603. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1604. def run(self):
  1605. self.note1.pack()
  1606. self.button1.pack(side=TOP, padx = 10, pady = 3)
  1607. self.lbl.pack()
  1608. self.lbl2.pack(fill=BOTH,expand=Y)
  1609. self.scrollbar1.config(command=self.text1.yview)
  1610. self.text1.config(yscrollcommand=self.scrollbar1.set)
  1611. self.text1.pack(side=LEFT, fill=Y)
  1612. self.scrollbar1.pack(side=RIGHT, fill=Y)
  1613. self.step1_lbl1.grid(row=0,column=0,sticky=W)
  1614. self.step2_lbl1.grid(row=1,column=0,sticky=W)
  1615. self.step3_lbl1.grid(row=2,column=0,sticky=W)
  1616. self.step4_lbl1.grid(row=3,column=0,sticky=W)
  1617. self.step5_lbl1.grid(row=4,column=0,sticky=W)
  1618. self.step6_lbl1.grid(row=5,column=0,sticky=W)
  1619. self.step7_lbl1.grid(row=6,column=0,sticky=W)
  1620. self.step8_lbl1.grid(row=7,column=0,sticky=W)
  1621. self.step9_lbl1.grid(row=8,column=0,sticky=W)
  1622. self.step10_lbl1.grid(row=9,column=0,sticky=W)
  1623. self.step11_lbl1.grid(row=10,column=0,sticky=W)
  1624. self.step12_lbl1.grid(row=11,column=0,sticky=W)
  1625. self.step13_lbl1.grid(row=12,column=0,sticky=W)
  1626. self.step14_lbl1.grid(row=13,column=0,sticky=W)
  1627. self.step15_lbl1.grid(row=14,column=0,sticky=W)
  1628. self.step16_lbl1.grid(row=15,column=0,sticky=W)
  1629. self.step17_lbl1.grid(row=16,column=0,sticky=W)
  1630. self.step18_lbl1.grid(row=17,column=0,sticky=W)
  1631. self.step19_lbl1.grid(row=18,column=0,sticky=W)
  1632. self.step20_lbl1.grid(row=19,column=0,sticky=W)
  1633. self.step21_lbl1.grid(row=20,column=0,sticky=W)
  1634. self.step22_lbl1.grid(row=21,column=0,sticky=W)
  1635. self.step23_lbl1.grid(row=22,column=0,sticky=W)
  1636. self.step24_lbl1.grid(row=23,column=0,sticky=W)
  1637. self.step25_lbl1.grid(row=24,column=0,sticky=W)
  1638. self.step26_lbl1.grid(row=25,column=0,sticky=W)
  1639. self.step27_lbl1.grid(row=26,column=0,sticky=W)
  1640. self.step28_lbl1.grid(row=27,column=0,sticky=W)
  1641. self.step1_lbl2.grid(row=0,column=1,sticky=W)
  1642. self.step2_lbl2.grid(row=1,column=1,sticky=W)
  1643. self.step3_lbl2.grid(row=2,column=1,sticky=W)
  1644. self.step4_lbl2.grid(row=3,column=1,sticky=W)
  1645. self.step5_lbl2.grid(row=4,column=1,sticky=W)
  1646. self.step6_lbl2.grid(row=5,column=1,sticky=W)
  1647. self.step7_lbl2.grid(row=6,column=1,sticky=W)
  1648. self.step8_lbl2.grid(row=7,column=1,sticky=W)
  1649. self.step9_lbl2.grid(row=8,column=1,sticky=W)
  1650. self.step10_lbl2.grid(row=9,column=1,sticky=W)
  1651. self.step11_lbl2.grid(row=10,column=1,sticky=W)
  1652. self.step12_lbl2.grid(row=11,column=1,sticky=W)
  1653. self.step13_lbl2.grid(row=12,column=1,sticky=W)
  1654. self.step14_lbl2.grid(row=13,column=1,sticky=W)
  1655. self.step15_lbl2.grid(row=14,column=1,sticky=W)
  1656. self.step16_lbl2.grid(row=15,column=1,sticky=W)
  1657. self.step17_lbl2.grid(row=16,column=1,sticky=W)
  1658. self.step18_lbl2.grid(row=17,column=1,sticky=W)
  1659. self.step19_lbl2.grid(row=18,column=1,sticky=W)
  1660. self.step20_lbl2.grid(row=19,column=1,sticky=W)
  1661. self.step21_lbl2.grid(row=20,column=1,sticky=W)
  1662. self.step22_lbl2.grid(row=21,column=1,sticky=W)
  1663. self.step23_lbl2.grid(row=22,column=1,sticky=W)
  1664. self.step24_lbl2.grid(row=23,column=1,sticky=W)
  1665. self.step25_lbl2.grid(row=24,column=1,sticky=W)
  1666. self.step26_lbl2.grid(row=25,column=1,sticky=W)
  1667. self.step27_lbl2.grid(row=26,column=1,sticky=W)
  1668. self.step28_lbl2.grid(row=27,column=1,sticky=W)
  1669. self.lblframe.pack()
  1670. self.textframe1.pack()
  1671. self.paramframe.pack()
  1672. self.nb.add(self.lblframe, text='Status')
  1673. self.nb.add(self.textframe1, text='Log')
  1674. self.nb.add(self.paramframe, text='Parameters')
  1675. self.nb.enable_traversal() # enable keyboard traversal using Ctrl+Tab
  1676. self.nb.pack(fill=BOTH, expand="true", padx=5, pady=1)
  1677. self.root.mainloop()
  1678. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1679. def readLog1(self):
  1680. # This function periodically reads and empties the log buffer
  1681. global log1_buffer
  1682. if log1_buffer != "":
  1683. self.text1.insert(END, log1_buffer)
  1684. text = self.my_io_process.read_file()
  1685. if text != "":
  1686. self.text1.insert(END, text)
  1687. if log1_buffer != "" or text != "": # if log buffer was populated
  1688. self.text1.yview_pickplace("end") # move the scrollbar to the bottom
  1689. log1_buffer = "" # empty the log buffer
  1690. self.root.update() # update the screen
  1691. self.root.after(100, self.readLog1)
  1692. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1693. def set_param_frame(self):
  1694. global params_dict
  1695. self.L = []
  1696. self.E = []
  1697. count = 1
  1698. for key,value in params_dict.iteritems():
  1699. lbl = Label(self.paramframe, text=key)
  1700. enty = Entry(self.paramframe, bd = 4)
  1701. enty.delete(0, END)
  1702. enty.insert(0,value)
  1703. enty.config(state=DISABLED)
  1704. lbl.grid(row=count, sticky=W)
  1705. enty.grid(row=count, column=1)
  1706. self.L.append(lbl)
  1707. self.E.append(enty)
  1708. count = count + 1
  1709. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1710. def start(self):
  1711. global step_status
  1712. running=True
  1713. #self.counter_label()
  1714. #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'] #
  1715. 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'] #
  1716. self.button1.config(state=DISABLED) # disable the start button
  1717. self.text1.delete('1.0', 'end') # delete the log
  1718. self.my_io_process.reset_counter()
  1719. self.thread_list['thread'] = MasterThread(self)
  1720. self.thread_list['thread'].start()
  1721. self.manage()
  1722. self.manage_lblframe()
  1723. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1724. def manage(self):
  1725. # manage the pop-up dialog boxes
  1726. global step_status
  1727. total_no_of_steps = len(step_status) - 1
  1728. flag = 0
  1729. count = 0
  1730. for i in range(1,total_no_of_steps+1):
  1731. if step_status[i] == 'f': # if failed
  1732. #tkMessageBox.showinfo("Message Box", "Error on Step " + str(i) + "! See Log for details.")
  1733. print1("Error on Step " + str(i) + "! See Log for details.")
  1734. flag = 1
  1735. time.sleep(1)
  1736. write_log_to_file(self.text1.get('1.0', 'end'))
  1737. print1("Log written to the external txt file under ./Logs/")
  1738. if step_status[i] == 'p' or step_status[i] == 'f': # if passed
  1739. count = count + 1
  1740. if count == total_no_of_steps: # if all the steps were successful
  1741. flag = 1
  1742. tkMessageBox.showinfo("Message Box", "Test succesfully done!") #Please safely remove the device from the chamber.
  1743. print1("Test succesfully done! Please safely remove the device from the chamber.")
  1744. time.sleep(1)
  1745. write_log_to_file(self.text1.get('1.0', 'end'))
  1746. print1("Log written to the external txt file under ./Logs/")
  1747. self.running=False
  1748. self.counter=0
  1749. if flag == 0: # if not(any step failed or all steps passed)
  1750. self.root.after(500, self.manage)
  1751. else: # if any step has failed or if all the steps have passed
  1752. self.button1.config(state=NORMAL) # enable the start button
  1753. self.my_io_process.empty_file()
  1754. return 0
  1755. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1756. def manage_lblframe(self):
  1757. # manage the frame that displays the step-by-step status
  1758. # manage the top-level status Label
  1759. global step_status
  1760. global device_info
  1761. global result_msg
  1762. total_no_of_steps = len(step_status) - 1
  1763. try:
  1764. SrNo = device_info['SrNo']
  1765. string = "Device: " + SrNo
  1766. self.lbl2.config(text=string)
  1767. except:
  1768. string = "Device: "
  1769. self.lbl2.config(text=string)
  1770. flag = 0
  1771. count1 = 0
  1772. count2 = 0
  1773. count3 = 0
  1774. #self.counter_label()
  1775. for i in range (1,total_no_of_steps + 1):
  1776. if step_status[i] == 'r': # if running
  1777. self.step_lbl_list[i]["text"] = "RUNNING..."
  1778. self.step_lbl_list[i]["bg"] = 'yellow'
  1779. self.lbl.config(bg='yellow')
  1780. self.lbl.config(text='RUNNING...')
  1781. self.running=True
  1782. #self.counter_label()
  1783. if step_status[i] == 'p': # if passed
  1784. self.step_lbl_list[i]["text"] = result_msg[i]
  1785. self.step_lbl_list[i]["bg"] = 'green'
  1786. count2 = count2 + 1
  1787. if step_status[i] == 'f': # if failed
  1788. self.step_lbl_list[i]["text"] = "ERROR!"
  1789. self.step_lbl_list[i]["bg"] = 'red'
  1790. self.lbl.config(bg='red')
  1791. self.lbl.config(text='ERROR!')
  1792. #flag = 1
  1793. count3 = count3 + 1
  1794. if step_status[i] == 'ns': # if not started
  1795. self.step_lbl_list[i]["text"] = "NOT STARTED"
  1796. self.step_lbl_list[i]["bg"] = 'gray'
  1797. count1 = count1 + 1
  1798. if count1 == total_no_of_steps: # if none of the steps have started
  1799. self.lbl.config(bg='gray')
  1800. self.lbl.config(text='NOT STARTED')
  1801. if count2 == total_no_of_steps: # if all the steps are done
  1802. self.lbl.config(bg='green')
  1803. self.lbl.config(text='DONE!')
  1804. flag = 1
  1805. if flag == 0: # if there is no error and all the steps aren't done yet
  1806. self.root.after(200, self.manage_lblframe)
  1807. else: # if there is an error or if all the steps are done already
  1808. device_info['SrNo'] = ""
  1809. return 0
  1810. ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  1811. #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  1812. if __name__ == "__main__":
  1813. g = GuiThread()
  1814. g.run()