| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 |
- #!/usr/bin/python
- # _*_ coding: utf-8 _*_
- try:
- from Tkinter import * # python2
- import ttk
- import tkMessageBox
- except Exception as e:
- from tkinter import * # python3
- from tkinter import ttk
- from tkinter import messagebox as tkMessageBox
- import time
- import os
- import threading
- import random
- def ask_choice_with_timeout(title, message, timeout=5, default_choice=False):
- # 创建顶层弹窗窗口(Python 2 Tkinter语法)
- import Tkinter as tk
- top = tk.Toplevel()
- top.title(title)
- top.geometry("350x180") # 弹窗大小
- top.resizable(False, False) # 禁止调整大小
-
- # 设置模态窗口(阻塞主窗口操作)
- top.transient(top.master)
- top.grab_set()
-
- # 存储结果(用列表实现可变变量,Python 2中nonlocal仅在3.x支持)
- result = [default_choice]
-
- # 显示提示信息
- msg_label = tk.Label(top, text=message, padx=20, pady=20, font=("Arial", 10))
- msg_label.pack(fill=tk.X)
-
- # 显示倒计时提示
- timeout_text = "{}秒后自动{}...".format(timeout, "确认" if default_choice else "取消")
- timeout_label = tk.Label(top, text=timeout_text, fg="gray", font=("Arial", 9))
- timeout_label.pack()
-
- # 按钮回调函数
- def on_ok():
- result[0] = True
- top.destroy()
-
- def on_cancel():
- result[0] = False
- top.destroy()
-
- # 按钮布局
- btn_frame = tk.Frame(top)
- btn_frame.pack(pady=15)
-
- ok_btn = tk.Button(btn_frame, text="OK", command=on_ok, width=8)
- cancel_btn = tk.Button(btn_frame, text="Cancel", command=on_cancel, width=8)
-
- ok_btn.pack(side=tk.LEFT, padx=10)
- cancel_btn.pack(side=tk.LEFT, padx=10)
-
- # 倒计时线程(Python 2 threading语法)
- def countdown():
- current_timeout = timeout
- while current_timeout > 0:
- current_timeout -= 1
- # 更新倒计时文本
- new_text = "{}秒后自动{}...".format(current_timeout, "确认" if default_choice else "取消")
- print(new_text)
- timeout_label.config(text=new_text)
- top.update() # 刷新界面
- time.sleep(1) # 等待1秒
- top.destroy() # 超时关闭窗口
-
- # 启动守护线程(Python 2兼容)
- t = threading.Thread(target=countdown)
- t.setDaemon(True) # 守护线程,主程序退出时自动结束
- t.start()
-
- # 等待窗口关闭
- top.wait_window()
-
- return result[0]
- def step1_routine(context, *args):
- # bios_version
- time.sleep(0.1)
- a = os.popen("sh os-ver.sh bios").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step2_routine(context):
- # bios release date
- a = os.popen('sh os-ver.sh ec').read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step3_routine(context):
- # CPU type
- a = os.popen("cat /proc/cpuinfo | grep \"model name\" | awk '{print $5}' | head -1").read().replace('\n',
- '').replace(
- '\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step4_routine(context):
- # memory_version
- a = os.popen("sh mem-ver.sh").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step5_routine(context):
- # hdd_version
- b = os.popen("sh hdd-ver.sh").read().strip()
- a = os.popen("cat /sys/block/nvme0n1/device/firmware_rev").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found! " + a
- else:
- return True, 'PASS-{}'.format(a)
- def step6_routine(context):
- # os_version
- string = "os"
- a = os.popen("lsb_release -rs").read().strip()
- if a == "22.04":
- return True, 'PASS-{}'.format(a)
- else:
- return False, "Error! No Device found! " + a
- def step7_routine(context):
- a = os.popen("sh os-ver.sh RTCBATTERY").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if 3000 <= a_int <= 4000:
- return True, a_int
- else:
- return False, "FAIL " + a
- def step8_routine(context):
- # usb function
- a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 5:
- return True, a
- else:
- return False, "FAIL " + a
- def step9_routine(context):
- # network speed cli
- c = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
- try:
- c_int = int(c)
- except ValueError:
- return False, "Invalid output c: {}".format(c)
- if c_int != 1:
- return False, "FAIL " + "Error! No Device found!"
- a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- elif a == "Download: Upload:":
- return False, "FAIL " + "Error! no ethernet!"
- else:
- b = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
- try:
- b_int = int(b)
- except ValueError:
- return False, "Invalid output b: {}".format(b)
- if b_int == 1:
- return True, a
- else:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- def step10_routine(context):
- return True, 'AAPASS'
- #serialA
- a = os.popen("sh pcie.sh").read().strip()
- time.sleep(1)
- ttyWCH0 = os.popen("sh serialport-test.sh /dev/ttyWCH0").read().strip()
- try:
- a_int = int(ttyWCH0)
- except ValueError:
- return False, "Invalid output ttyWCH0: {}".format(ttyWCH0)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH0"
- ttyWCH1 = os.popen("sh serialport-test.sh /dev/ttyWCH1").read().strip()
- try:
- a_int = int(ttyWCH1)
- except ValueError:
- return False, "Invalid output ttyWCH1: {}".format(ttyWCH1)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH1"
- ttyWCH2 = os.popen("sh serialport-test.sh /dev/ttyWCH2").read().strip()
- try:
- a_int = int(ttyWCH2)
- except ValueError:
- return False, "Invalid output ttyWCH2: {}".format(ttyWCH2)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH2"
- ttyWCH3 = os.popen("sh serialport-test.sh /dev/ttyWCH3").read().strip()
- try:
- a_int = int(ttyWCH3)
- except ValueError:
- return False, "Invalid output ttyWCH3: {}".format(ttyWCH3)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH3"
- ttyWCH4 = os.popen("sh serialport-test.sh /dev/ttyWCH4").read().strip()
- try:
- a_int = int(ttyWCH4)
- except ValueError:
- return False, "Invalid output ttyWCH4: {}".format(ttyWCH4)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH4"
- ttyWCH5 = os.popen("sh serialport-test.sh /dev/ttyWCH5").read().strip()
- try:
- a_int = int(ttyWCH5)
- except ValueError:
- return False, "Invalid output ttyWCH5: {}".format(ttyWCH5)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH5"
- ttyWCH6 = os.popen("sh serialport-test.sh /dev/ttyWCH6").read().strip()
- try:
- a_int = int(ttyWCH6)
- except ValueError:
- return False, "Invalid output ttyWCH6: {}".format(ttyWCH6)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH6"
- ttyWCH7 = os.popen("sh serialport-test.sh /dev/ttyWCH7").read().strip()
- try:
- a_int = int(ttyWCH7)
- except ValueError:
- return False, "Invalid output ttyWCH7: {}".format(ttyWCH7)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH7"
- return True, "PASS"
- def step11_routine(context):
- return True, 'AAPASS'
- #serialB
- a = os.popen("sh pcie.sh").read().strip()
- time.sleep(1)
- ttyWCH8 = os.popen("sh serialport-test.sh /dev/ttyWCH8").read().strip()
- try:
- a_int = int(ttyWCH8)
- except ValueError:
- return False, "Invalid output ttyWCH8: {}".format(ttyWCH8)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH8"
- ttyWCH9 = os.popen("sh serialport-test.sh /dev/ttyWCH9").read().strip()
- try:
- a_int = int(ttyWCH9)
- except ValueError:
- return False, "Invalid output ttyWCH9: {}".format(ttyWCH9)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH9"
-
- ttyWCH10 = os.popen("sh serialport-test.sh /dev/ttyWCH10").read().strip()
- try:
- a_int = int(ttyWCH10)
- except ValueError:
- return False, "Invalid output ttyWCH10: {}".format(ttyWCH10)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH10"
-
- ttyWCH11 = os.popen("sh serialport-test.sh /dev/ttyWCH11").read().strip()
- try:
- a_int = int(ttyWCH11)
- except ValueError:
- return False, "Invalid output ttyWCH11: {}".format(ttyWCH11)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH11"
-
- ttyWCH12 = os.popen("sh serialport-test.sh /dev/ttyWCH12").read().strip()
- try:
- a_int = int(ttyWCH12)
- except ValueError:
- return False, "Invalid output ttyWCH12: {}".format(ttyWCH12)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH12"
-
- ttyWCH13 = os.popen("sh serialport-test.sh /dev/ttyWCH13").read().strip()
- try:
- a_int = int(ttyWCH13)
- except ValueError:
- return False, "Invalid output ttyWCH13: {}".format(ttyWCH13)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH13"
-
- ttyWCH14 = os.popen("sh serialport-test.sh /dev/ttyWCH14").read().strip()
- try:
- a_int = int(ttyWCH14)
- except ValueError:
- return False, "Invalid output ttyWCH14: {}".format(ttyWCH14)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH14"
-
- ttyWCH15 = os.popen("sh serialport-test.sh /dev/ttyWCH15").read().strip()
- try:
- a_int = int(ttyWCH15)
- except ValueError:
- return False, "Invalid output ttyWCH15: {}".format(ttyWCH15)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyWCH15"
-
- return True, "PASS"
- def step12_routine(context):
- #serialC
- ttyS0 = os.popen("sh serialport-test.sh /dev/ttyS0").read().strip()
- try:
- a_int = int(ttyS0)
- except ValueError:
- return False, "Invalid output ttyS0: {}".format(ttyS0)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS0"
- ttyS1 = os.popen("sh serialport-test.sh /dev/ttyS1").read().strip()
- try:
- a_int = int(ttyS1)
- except ValueError:
- return False, "Invalid output ttyS1: {}".format(ttyS1)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS1"
-
- ttyS2 = os.popen("sh serialport-test.sh /dev/ttyS2").read().strip()
- try:
- a_int = int(ttyS2)
- except ValueError:
- return False, "Invalid output ttyS2: {}".format(ttyS2)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS2"
-
- ttyS3 = os.popen("sh serialport-test.sh /dev/ttyS3").read().strip()
- try:
- a_int = int(ttyS3)
- except ValueError:
- return False, "Invalid output ttyS3: {}".format(ttyS3)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS3"
-
- # ttyS4 = os.popen("sh serialport-test.sh /dev/ttyS4").read().strip()
- # try:
- # a_int = int(ttyS4)
- # except ValueError:
- # return False, "Invalid output ttyS4: {}".format(ttyS4)
- # if a_int == 1:
- # pass
- # else:
- # return False, "FAIL " + "Error! No Device found! ttyS4"
-
- # ttyS5 = os.popen("sh serialport-test.sh /dev/ttyS5").read().strip()
- # try:
- # a_int = int(ttyS5)
- # except ValueError:
- # return False, "Invalid output ttyS5: {}".format(ttyS5)
- # if a_int == 1:
- # pass
- # else:
- # return False, "FAIL " + "Error! No Device found! ttyS5"
-
- ttyS6 = os.popen("sh serialport-test.sh /dev/ttyS6").read().strip()
- try:
- a_int = int(ttyS6)
- except ValueError:
- return False, "Invalid output ttyS6: {}".format(ttyS6)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS6"
-
- ttyS7 = os.popen("sh serialport-test.sh /dev/ttyS7").read().strip()
- try:
- a_int = int(ttyS7)
- except ValueError:
- return False, "Invalid output ttyS7: {}".format(ttyS7)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS7"
-
- return True, "PASS"
- def step13_routine(context):
- #LCD Test
- a = os.popen('./lcd/lcd/lcd_app | grep -c "LCD test completed"').read().replace('\n', '').replace('\r', '').strip()
- a = os.popen("sh serialport-test.sh /dev/a").read().strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output a: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step14_routine(context):
- #LED Test
- a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step15_routine(context):
- a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step16_routine(context):
- return True, 'AAPASS'
- # a = os.popen("sh os-ver.sh USB394").read().replace('\n', '').replace('\r', '').strip()
- # if a == "0":
- # return False, "Error! No Device found!\n" + a
- # else:
- # return True, 'PASS-{}'.format(a)
- def step17_routine(context):
- # network speed cli
- return True, 'AAPASS'
- a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "Error! No Device found!\n" + a
- elif a == "Download: Upload:":
- return False, "Error! no ethernet!\n" + a
- else:
- return True, 'PASS-{}'.format(a)
- def step18_routine(context):
- a = os.popen("sh beep.sh").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试蜂鸣器是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试蜂鸣器是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step19_routine(context):
- return True, 'AAPASS'
- def step20_routine(context):
- return True, 'AAPASS'
- def step21_routine(context):
- a = os.popen("sh seven_segment_display.sh").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试数码管是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step22_routine(context):
- return True, 'AAPASS'
- def step23_routine(context):
- return True, 'AAPASS'
- def step24_routine(context):
- return True, 'AAPASS'
- def step25_routine(context):
- return True, 'AAPASS'
- def step26_routine(context):
- return True, 'AAPASS'
- def step27_routine(context):
- a = os.popen("bash ./gsensor-SC7A20H/C180_gsensor_function_script.sh | grep -c \"pass\"").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step28_routine(context):
- return True, 'AAPASS'
- def step29_routine(context):
- a = os.popen("sh display.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
- a = os.popen("find ./test_picture/ -name '*.jpg' | wc -l").read().strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step30_routine(context):
- a = os.popen("sh fio.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step31_routine(context):
- a = os.popen("sh os-ver.sh speaker | wc -l").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step32_routine(context):
- a = os.popen("sh record_play.sh 111111 | wc -l").read().replace('\n', '').replace('\r', '').strip()
- a = os.popen("echo 111111 | sudo -S find /tmp/ -name 'my_recording.wav' 2>&1 | wc -l").read().strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step33_routine(context):
- a = os.popen("sh led-test.sh | tail -1").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int == 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step34_routine(context):
- #a = os.popen("/usr/bin/guvcview &").read().replace('\n', '').replace('\r', '').strip()
- os.system("/usr/bin/guvcview &")
- time.sleep(15)
- os.system("sh os-ver.sh exit &")
- return True, 'PASS'
-
- def step35_routine(context):
- #return True, 'AAPASS'
- a = os.popen("sh ./keyboard.sh 111111").read().replace('\n', '').replace('\r', '').strip()
- try:
- if len(a) == 1:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- elif a == "cashDrawer1: , cashDrawer2: ":
- return False, "FAIL " + "Error! no cashDrawer!"
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if len(a) == 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step36_routine(context):
- # network speed cli
- c = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
- try:
- c_int = int(c)
- except ValueError:
- return False, "Invalid output c: {}".format(c)
- if c_int != 1:
- return False, "FAIL " + "Error! No Device found!"
- a = os.popen("sh os-ver.sh speedcliDownload").read().replace('\n', '').replace('\r', '').strip()
- if len(a) == 0:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- elif a == "Download: Upload:":
- return False, "FAIL " + "Error! no ethernet!"
- else:
- b = os.popen("ip link show | grep -c \"BROADCAST,MULTICAST,UP,LOWER_UP\"").read().strip()
- try:
- b_int = int(b)
- except ValueError:
- return False, "Invalid output b: {}".format(b)
- if b_int == 1:
- return True, a
- else:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- def step37_routine(context):
- a = os.popen("lsblk -d -o TRAN,NAME,SIZE | grep usb | wc -l").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 6:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step38_routine(context):
- time.sleep(1)
- os.system("sh os-ver.sh 1080p &")
- time.sleep(15)
- os.system("sh os-ver.sh exit &")
- return True, 'PASS'
- def step39_routine(context):
- a = os.popen("sh ./cashDrawer_test.sh 111111 | tail -n 1").read().replace('\n', '').replace('\r', '').strip()
- try:
- if len(a) == 0:
- return False, "FAIL " + "Error! No Device found! {}".format(a)
- elif a == "cashDrawer1: , cashDrawer2: ":
- return False, "FAIL " + "Error! no cashDrawer!"
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if len(a) > 0:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step40_routine(context):
- #serialC
- ttyS0 = os.popen("sh serialport-test.sh /dev/ttyS0").read().strip()
- try:
- a_int = int(ttyS0)
- except ValueError:
- return False, "Invalid output ttyS0: {}".format(ttyS0)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS0"
- ttyS1 = os.popen("sh serialport-test.sh /dev/ttyS1").read().strip()
- try:
- a_int = int(ttyS1)
- except ValueError:
- return False, "Invalid output ttyS1: {}".format(ttyS1)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS1"
-
- ttyS2 = os.popen("sh serialport-test.sh /dev/ttyS2").read().strip()
- try:
- a_int = int(ttyS2)
- except ValueError:
- return False, "Invalid output ttyS2: {}".format(ttyS2)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS2"
-
- ttyS3 = os.popen("sh serialport-test.sh /dev/ttyS3").read().strip()
- try:
- a_int = int(ttyS3)
- except ValueError:
- return False, "Invalid output ttyS3: {}".format(ttyS3)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS3"
-
- ttyS6 = os.popen("sh serialport-test.sh /dev/ttyS6").read().strip()
- try:
- a_int = int(ttyS6)
- except ValueError:
- return False, "Invalid output ttyS6: {}".format(ttyS6)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS6"
-
- ttyS7 = os.popen("sh serialport-test.sh /dev/ttyS7").read().strip()
- try:
- a_int = int(ttyS7)
- except ValueError:
- return False, "Invalid output ttyS7: {}".format(ttyS7)
- if a_int == 1:
- pass
- else:
- return False, "FAIL " + "Error! No Device found! ttyS7"
-
- return True, "PASS"
- def step41_routine(context):
- a = os.popen("bash usb_test.sh 111111 | grep -s 'PASSED' | wc -l").read().replace('\n', '').replace('\r', '').strip()
- #b = os.popen("bash usb_test.sh 111111").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step42_routine(context):
- a = os.popen("sh readsn.sh").read().replace('\n', '').replace('\r', '').strip()
- try:
- if len(a) == 0:
- return False, "Error! Serial Number is empty!\n" + a
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if len(a) == 11:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
- def step43_routine(context):
- a = os.popen("/usr/bin/guvcview &").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试数码管是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step44_routine(context):
- a = os.popen("sh os-ver.sh speaker").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试喇叭是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step45_routine(context):
- a = os.popen("sh os-ver.sh arecord").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试Microphone_Test是否正常."):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step46_routine(context):
- a = os.popen("sh lightRing.sh").read().replace('\n', '').replace('\r', '').strip()
- if tkMessageBox.askokcancel("PASS?", "测试确定LEDBlinking是否正常?"):
- # if ask_choice_with_timeout("PASS?", "测试数码管是否正常.",30):
- return True, 'PASS'
- else:
- return False, "FAIL"
- def step47_routine(context):
- a = os.popen("xinput --list | grep -c 'TouchScreen'").read().replace('\n', '').replace('\r', '').strip()
- try:
- a_int = int(a)
- except ValueError:
- return False, "Invalid output: {}".format(a)
- if a_int >= 1:
- return True, 'PASS-{}'.format(a)
- else:
- return False, "FAIL " + "Error! No Device found!"
|