From 46bb26c8ec72853044edbeae04eb6e73e5664ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=92=90?= Date: Tue, 27 Feb 2024 15:30:15 +0800 Subject: [PATCH] Add the nmcli con show function --- category/get_net_info.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/category/get_net_info.py b/category/get_net_info.py index 582de89..95dc6aa 100644 --- a/category/get_net_info.py +++ b/category/get_net_info.py @@ -11,6 +11,7 @@ if sys.getdefaultencoding() != 'utf-8': sys.setdefaultencoding('utf-8') from common.decorator_wrap import DecoratorWrap +from common.file import FileOperation from common.log import Logger from common.command import Command @@ -65,4 +66,22 @@ def __get_devices(self): if 'yes' in res.strip().lower(): self.__netdev_act[ifc] = 'ethernet' - return True \ No newline at end of file + return True + +def __get_devices_info(self): + ''' + nmcli con show + ''' + cmd_name = "nmcli con show" + res_list = [] + res = '' + + devices_command="nmcli con show" + cmd_result = Command.cmd_run(devices_command) + res_list.append(cmd_result) + + #wrap result + for i,cmd_result in enumerate(res_list): + split = '=' if i == len(res_list)-1 else '-' + res += FileOperation.wrap_output_format(cmd_name, cmd_result, split) + return Command.cmd_write_file(res, self.__default_file_name) \ No newline at end of file -- Gitee