Update shell_execute.py

This commit is contained in:
qiaofeng1227 2023-03-24 12:16:14 +08:00 committed by GitHub
parent bf6ea8bd47
commit 5b57a0fe55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,12 +9,12 @@ def execute_command_output(cmd_str):
return out_str
# cmd_str: 执行的command命令 times如果不成功的重复次数
def execute_command_output_all(cmd_str, max_time = 3):
def execute_command_output_all(command, max_time = 3):
myLogger.info_logger("Start to execute cmd: " + cmd_str)
execute_time = 0
while execute_time < max_time:
process = subprocess.run(convert_command(cmd_str), capture_output=True, check=True, text=True, shell=True)
process = subprocess.run(f'nsenter -m -u -i -n -p -t 1 sh -c "{command}"', capture_output=True, check=True, text=True, shell=True)
if process.returncode == 0:
return {"code": "0", "result": process.stdout,}
else: