diff --git a/tools/base.py b/tools/base.py index 67cb2be..af78154 100644 --- a/tools/base.py +++ b/tools/base.py @@ -992,6 +992,7 @@ def log_callback(log,log_type): msg = 'code:{}'.format(code) if code == 0: msg="success" + self.ret_code = code if code==0: self.bar.finsh('CMD Result:{}'.format(msg),'\033[37m') @@ -999,7 +1000,6 @@ def log_callback(log,log_type): self.bar.finsh('CMD Result:{}'.format(msg),'\033[31m') - self.ret_code = code self.ret_out = out self.ret_err = err self.ret_ok = True @@ -1008,10 +1008,14 @@ def run_command(self,executable='/bin/sh'): self.command_thread = threading.Thread(target=self.command_thread) self.command_thread.start() time.sleep(0.5) # 等待线程启动 - while self.is_command_finish()==-1 and not self.ret_ok: + while self.is_command_finish()==-1: self.bar.update_time() time.sleep(0.1) + start_time = time.time() + while not self.ret_ok and time.time()-start_time < 2.0: # 2s timeout wait command_thread end + time.sleep(0.1) + Tracking.put_cmd_result(self.ret_code,self.ret_out,self.ret_err,self.command) return (self.ret_code,self.ret_out,self.ret_err)