def _new_button_click(self): if self.sender().text() == '使用指引': from utils.thread_utils import RunExeThread import os self.thread = RunExeThread( os.path.join(constant.SRC_ROOT, '可靠性工具.docx')) self.thread.start() else: from utils.thread_utils import RemindThread from model.loading import loading import os exe_path = os.path.join( constant.BASE_ROOT.rsplit('\\', 1)[0], 'SwitchTool', 'SwitchTool.exe') exe_path = exe_path.rsplit('\\', 1) if not self.loading: self.loading = loading(self) self.loading.label_2.setText('开关机工具启动中...') self.loading.move(self.width() * 0.45, self.height() * 0.45) else: self.loading.setText('开关机工具启动中...') self.loading.setVisible(True) cmd = 'cd /d ' + exe_path[0] + ' & start ' + exe_path[1] + ' &' self.remind_thread = RemindThread(cmd, 'success', exe_path[1]) self.remind_thread.exec_down.connect(self.show_debug) self.remind_thread.start() self.loading.exec()
def inform_text(self, string): if string == 'begin': self.loading = loading(self) self.loading.label_2.setText('调试中,请等待') self.loading.move(self.width()*0.45, self.height()*0.45) self.loading.exec() if string == 'FAIL': self.loading.label_2.setText('执行失败') self.loading.close() QMessageBox.information(self, '提示', '执行失败', QMessageBox.Yes) return if string == 'FINISH': self.loading.label_2.setText('执行成功') self.loading.close() QMessageBox.information(self, '提示', '执行完成', QMessageBox.Yes) return
def show_debug(self, msg): if msg == 'success': self.loading.close() self.loading = None elif msg == '脚本调试中...' or msg == '脚本调试成功': if self.loading != None: self.loading.label_2.setText(msg) else: from model.loading import loading self.loading = loading(self) self.loading.label_2.setText(msg) self.loading.move(self.width() * 0.45, self.height() * 0.45) self.loading.exec() else: self.loading.close() self.loading = None self.message('脚本异常提示', msg)