From 15c0f2baf01e1b429e70d969acbb0d772acaafe8 Mon Sep 17 00:00:00 2001 From: zhanghan2021 Date: Thu, 23 Nov 2023 14:47:50 +0800 Subject: [PATCH] Execute the shell command and check the output of the ethtool command --- common/command.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 common/command.py diff --git a/common/command.py b/common/command.py new file mode 100644 index 0000000..9968bcd --- /dev/null +++ b/common/command.py @@ -0,0 +1,25 @@ +# -*- coding:utf-8 -*- +#!/usr/bin/env python +# cython:language_level=3 + + +class Command: + + @staticmethod + def call(cmd, caller = ''): + ''' + Encapsulated CALL function to return abnormal location information + ''' + if(subprocess.call(cmd, shell = True)): + raise Exception("{} : [{}] Failed to execute!".format(caller, cmd)) + + @staticmethod + def check_ethtool_cg(cmd_stde): + if cmd_stde == b"Cannot get device coalesce settings: Operation not supported\n": + return True + elif cmd_stde == b"Cannot get device ring settings: Operation not supported\n": + return True + else: + return False + + \ No newline at end of file -- Gitee