From 722e4cd2349aa30faf58079f9deba5c8b6f576e4 Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Fri, 24 Mar 2023 12:16:56 +0800 Subject: [PATCH] Update shell_execute.py --- appmanage/api/utils/shell_execute.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appmanage/api/utils/shell_execute.py b/appmanage/api/utils/shell_execute.py index fad87a6d..c5b08a84 100644 --- a/appmanage/api/utils/shell_execute.py +++ b/appmanage/api/utils/shell_execute.py @@ -9,12 +9,12 @@ def execute_command_output(cmd_str): return out_str # cmd_str: 执行的command命令 times:如果不成功的重复次数 -def execute_command_output_all(command, max_time = 3): +def execute_command_output_all(cmd_str, max_time = 3): myLogger.info_logger("Start to execute cmd: " + cmd_str) execute_time = 0 while execute_time < max_time: - process = subprocess.run(f'nsenter -m -u -i -n -p -t 1 sh -c "{command}"', capture_output=True, check=True, text=True, shell=True) + process = subprocess.run(f'nsenter -m -u -i -n -p -t 1 sh -c "{cmd_str}"', capture_output=True, check=True, text=True, shell=True) if process.returncode == 0: return {"code": "0", "result": process.stdout,} else: