Skip to content

Commit

Permalink
refactor: Some small change to address the comments on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
jneo8 committed Feb 26, 2024
1 parent c809841 commit 125dcc2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_bmc_address() -> t.Optional[str]:
def _split_at(s: str, c: str, n: int) -> t.Tuple[str, str]:
"""Split a string 's' at the 'n'th occurrence of delimiter 'c'.
Parameters:
Args:
s (str): The string to split.
c (str): Delimiter for splitting.
n (int): Occurrence of 'c' to split at.
Expand All @@ -107,17 +107,17 @@ def hwinfo(*args: str) -> t.Dict[str, str]:
Args:
args: Probe for a particular hardware class.
Returns:
hw_info: hardware information dicturary
hw_info: hardware information dictionary
"""
apt.add_package("hwinfo", update_cache=False)
hw_classes = list(args)
for idx, hw_item in enumerate(args):
hw_classes[idx] = "--" + hw_item
hw_classes.insert(0, "hwinfo")
hw_info_cmd = ["hwinfo"] + hw_classes

output = subprocess.check_output(hw_classes, text=True)
output = subprocess.check_output(hw_info_cmd, text=True)
if "start debug info" in output.splitlines()[0]:
output = _split_at(output, "=========== end debug info ============", 1)[1]
output = output.split("=========== end debug info ============")[1]

hardwares: t.Dict[str, str] = {}
for item in output.split("\n\n"):
Expand Down
2 changes: 1 addition & 1 deletion src/hw_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def check(self) -> bool:


def _raid_hw_verifier_hwinfo() -> Set[HWTool]:
"""Verify if the HWTool support RAID card exists on machine with hwinfo."""
"""Verify if a supported RAID card exists on the machine using the hwinfo command."""
hwinfo_output = hwinfo("storage")

tools = set()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_split_at(s, delimiter, num, expect):

class TestHwinfo:
@pytest.mark.parametrize(
"hw_classes,expect_cmd, hwinfo_output,expect",
"hw_classes,expect_cmd,hwinfo_output,expect",
[
(
[],
Expand Down

0 comments on commit 125dcc2

Please sign in to comment.