Browse Source

Update shell_execute.py

qiaofeng1227 2 years ago
parent
commit
67d34efb77
1 changed files with 3 additions and 0 deletions
  1. 3 0
      appmanage/api/utils/shell_execute.py

+ 3 - 0
appmanage/api/utils/shell_execute.py

@@ -20,10 +20,13 @@ def execute_command_output_all(cmd_str, max_time = 2):
         process = subprocess.run(f'nsenter -m -u -i -n -p -t 1 sh -c "{cmd_str}"', capture_output=True, check=False, text=True, shell=True)
         
         if process.returncode == 0 and 'Fail' not in process.stdout and 'fail' not in process.stdout and 'Error' not in process.stdout and 'error' not in process.stdout:
+            myLogger.info_logger("success to excute cmd ")
             return {"code": "0", "result": process.stdout,}
         else:
             execute_time = execute_time + 1
             if execute_time > 2:
+               myLogger.info_logger("failed to excute cmd ")
+               myLogger.info_logger(process.stdout)
                raise CommandException(const.ERROR_SERVER_COMMAND,"Docker returns the original error",process.stdout)
 
 def convert_command(cmd_str):