#!/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!"