2424#
2525###############################################################################
2626from nodescraper .base import InBandDataCollector
27+ from nodescraper .connection .inband .inband import CommandArtifact
2728from nodescraper .enums import EventCategory , EventPriority , ExecutionStatus , OSFamily
2829from nodescraper .models import TaskResult
2930
@@ -35,8 +36,15 @@ class KernelModuleCollector(InBandDataCollector[KernelModuleDataModel, None]):
3536
3637 DATA_MODEL = KernelModuleDataModel
3738
38- def parse_proc_modules (self , output ):
39- """Parses the output of /proc/modules into a dictionary."""
39+ def parse_proc_modules (self , output : dict ) -> dict :
40+ """Parse command output and return dict of modules
41+
42+ Args:
43+ output (dict): sut cmd output
44+
45+ Returns:
46+ dict: parsed modules
47+ """
4048 modules = {}
4149 for line in output .strip ().splitlines ():
4250 parts = line .split ()
@@ -48,8 +56,15 @@ def parse_proc_modules(self, output):
4856 }
4957 return modules
5058
51- def get_module_parameters (self , module_name ):
52- """Fetches parameter names and values for a given kernel module using _run_sut_cmd."""
59+ def get_module_parameters (self , module_name : str ) -> dict :
60+ """Fetches parameter names and values for a given kernel module using _run_sut_cmd
61+
62+ Args:
63+ module_name (str): name of module to fetch params for
64+
65+ Returns:
66+ dict: param dict of module
67+ """
5368 param_dict = {}
5469 param_dir = f"/sys/module/{ module_name } /parameters"
5570
@@ -66,7 +81,15 @@ def get_module_parameters(self, module_name):
6681
6782 return param_dict
6883
69- def collect_all_module_info (self ):
84+ def collect_all_module_info (self ) -> tuple [dict , CommandArtifact ]:
85+ """Get all modules and its associated params and values
86+
87+ Raises:
88+ RuntimeError: error for failing to get modules
89+
90+ Returns:
91+ tuple[dict, CommandArtifact]: modules found and exit code
92+ """
7093 res = self ._run_sut_cmd ("cat /proc/modules" )
7194 if res .exit_code != 0 :
7295 raise RuntimeError ("Failed to read /proc/modules" )
@@ -78,10 +101,7 @@ def collect_all_module_info(self):
78101
79102 return modules , res
80103
81- def collect_data (
82- self ,
83- args = None ,
84- ) -> tuple [TaskResult , KernelModuleDataModel | None ]:
104+ def collect_data (self , args = None ) -> tuple [TaskResult , KernelModuleDataModel | None ]:
85105 """
86106 Collect kernel modules data.
87107
0 commit comments