From 149b5834512a69200f8132759c43860ee7a8e19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8F=A0=E8=90=9D=E6=9C=89=E7=82=B9=E9=85=B8?= Date: Thu, 12 Sep 2024 02:49:40 +0000 Subject: [PATCH] update common/command.py. Subprocess.call has been abandoned, it is recommended to use subprocess.run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 菠萝有点酸 --- common/command.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/command.py b/common/command.py index df6e21a..2abbe6f 100644 --- a/common/command.py +++ b/common/command.py @@ -16,8 +16,9 @@ class Command: ''' Encapsulated CALL function to return abnormal location information ''' - if(subprocess.call(cmd, shell = True)): - raise Exception("{} : [{}] Failed to execute!".format(caller, cmd)) + result = subprocess.run(cmd, shell=True, capture_output=True, text=True) + if result.returncode != 0: + raise Exception("{} : [{}] Failed to execute! Output: {}".format(caller, cmd, result.stderr)) @staticmethod def check_ethtool_cg(cmd_stde): -- Gitee