From 6e4883a0a858b65680db9dc033ef2e4d8aadacd0 Mon Sep 17 00:00:00 2001 From: zhanghan2021 Date: Thu, 23 Nov 2023 14:53:26 +0800 Subject: [PATCH] Check the execution results of commands --- common/command.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/common/command.py b/common/command.py index 9968bcd..df56211 100644 --- a/common/command.py +++ b/common/command.py @@ -2,6 +2,7 @@ #!/usr/bin/env python # cython:language_level=3 +from common.log import Logger class Command: @@ -22,4 +23,17 @@ class Command: else: return False - \ No newline at end of file + @staticmethod + def cmd_check(cmd_stdo, cmd_stde, cmd_returncode, cmd): + if cmd_returncode and Command.check_ethtool_cg(cmd_stde): + Logger().warning("{} : {}".format(cmd, cmd_stde.decode('utf8'))) + return False + elif cmd_returncode: + if len(cmd_stde) != 0: + Logger().warning("{}".format(cmd_stde.decode('utf8'))) + # else: + # Logger().error("exec command {} failed! ".format(cmd)) + return False + else: + return True + \ No newline at end of file -- Gitee