def teardown(self): """ 任务收尾工作,关闭串口,优化测试报告展示 :return: """ logging.debug('task teardown') shellcmd.close_kk_serial(self.device.tv_com) self.fd.optimize()
def run(self): self.scene.dependent.setup(self.scene.device) res, msg = self.scene.dependent.check() if not res: self.dependent_check_sig.emit(msg) else: self.reflash_sig.emit() self.scene.env_check() close_kk_serial(self.scene.device.tv_com)
def work(self): # 删除excel报告 # file_utils.rm(self.fd.excel) # 获取串口号 tv_com, mcu_com = self.device.tv_com, self.device.mcu_com dir_set_start = _get_kk_record_report_set() # 关闭电视串口 shellcmd.close_kk_serial(tv_com) # 通过子进程拉起脚本录制工具执行场景 exec_scene(tv_com, mcu_com, self.scripts) dir_set_complete = _get_kk_record_report_set() logging.warning( f'!!!!! should copy {dir_set_complete - dir_set_start} !!!!!') _copy_report(self.device.tv_com, dir_set_complete - dir_set_start, self.fd.root_pc) if not _parse_result(self.fd.root_pc): setattr(self, 'state', sc.STATE_FAIL)
def check(self) -> tuple: """ 以任务为单位的环境检测,会遍历所有场景列表所需环境依赖做并集,生成新的环境依赖队形进行环境检测 :return: """ logging.debug(f'task_base check, device : {self.device}') config = {} for scene in self.scene_list: for key, value in scene.dependent.serialize().items(): if value: config[key] = True config['tv'] = True new_dp = dp.Dependent(**config) new_dp.device = self.device ret = new_dp.check() shellcmd.close_kk_serial(self.device.tv_com) return ret
def check_env(tv_com, mcu_com='', monkey_tools=False) -> tuple: tv_com = tv_com.strip() mcu_com = mcu_com.strip() if tv_com: ret, info = check_tv_com(tv_com) if not ret: return False, info if monkey_tools: ret, info = check_monkey_tools(tv_com) if not ret: shellcmd.close_kk_serial(tv_com) return False, info if mcu_com: ret, info = check_mcu_com(mcu_com) if not ret: shellcmd.close_kk_serial(tv_com) return False, info ret, info = check_net(tv_com) if not ret: shellcmd.close_kk_serial(tv_com) return False, info return True, 'pass'
return dp.Dependent(muc=self.near, bt_ct=self.blue_controller, bt_a2dp=self.blue_speaker) def set_window(self, window: str): """ 设置当前需要检测的window :param window: :return: """ logging.debug(f'set_window {window}') self.window = window if __name__ == '__main__': from utils import shellcmd com = 'com32' c = Checker(launcher=True, net=True, wifi=True, usb=True, hdmi=True, camera=True, near=False, far=True, blue_controller=True, blue_speaker=True) c.device = dv.Device(com) c.check() shellcmd.close_kk_serial(com)
print('请输入合法的数值,请勿在输入次数时输入非数字的按键') continue wait_time = input('请输入启动应用后的等待时长:') if wait_time: try: wait_time = int(wait_time) except Exception as e: print('Exception: ' + str(e)) print('请输入合法的数值,请勿在输入次数时输入非数字的按键') continue usb_root = input('请输入日志保存路径:') if usb_root: try: file_num = int( send_cmd_get_result(tv_com, 'ls -l ' + usb_root + '|wc -l')) if file_num <= 1: print('请输入正确U盘路径') continue except Exception as e: print('Exception: ' + str(e)) print('请输入合法的数值,请勿在输入次数时输入非数字的按键') continue init_env(tv_com) aria_test(tv_com, out_duration_count, wait_time, usb_root) close_kk_serial(tv_com) import msvcrt print('按任意键退出...') msvcrt.getch() sys.exit()