Skip to content

Commit

Permalink
Add more appropriate logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dashmage committed Feb 14, 2024
1 parent 48d9db4 commit 86a1141
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hw_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def file_is_empty(path: Path) -> bool:
to replace. This function checks for those empty resource files.
"""
if path.stat().st_size == 0:
logger.info("%s size is 0, skip install", path)
logger.info("%s size is 0", path)
return True
return False

Expand Down Expand Up @@ -183,6 +183,7 @@ class StorCLIStrategy(TPRStrategyABC):
def install(self, path: Path) -> None:
"""Install storcli."""
if file_is_empty(path):
logger.info("Skipping StorCLI resource install since empty file was detected.")
raise ResourceFileSizeZeroError(tool=self._name, path=path)
if not validate_checksum(STORCLI_VERSION_INFOS, path):
raise ResourceChecksumError
Expand Down Expand Up @@ -210,6 +211,7 @@ class PercCLIStrategy(TPRStrategyABC):
def install(self, path: Path) -> None:
"""Install perccli."""
if file_is_empty(path):
logger.info("Skipping PERCCLI resource install since empty file was detected.")
raise ResourceFileSizeZeroError(tool=self._name, path=path)
if not validate_checksum(PERCCLI_VERSION_INFOS, path):
raise ResourceChecksumError
Expand All @@ -236,6 +238,7 @@ class SAS2IRCUStrategy(TPRStrategyABC):
def install(self, path: Path) -> None:
"""Install sas2ircu."""
if file_is_empty(path):
logger.info("Skipping SAS2IRCU resource install since empty file was detected.")
raise ResourceFileSizeZeroError(tool=self._name, path=path)
if not validate_checksum(SAS2IRCU_VERSION_INFOS, path):
raise ResourceChecksumError
Expand All @@ -261,6 +264,7 @@ class SAS3IRCUStrategy(SAS2IRCUStrategy):
def install(self, path: Path) -> None:
"""Install sas3ircu."""
if file_is_empty(path):
logger.info("Skipping SAS3IRCU resource install since empty file was detected.")
raise ResourceFileSizeZeroError(tool=self._name, path=path)
if not validate_checksum(SAS3IRCU_VERSION_INFOS, path):
raise ResourceChecksumError
Expand Down Expand Up @@ -523,7 +527,9 @@ def check_missing_resources(
# Uploaded but file size is zero
path = fetch_tools.get(tool)
if path and file_is_empty(path):
logger.warning("Tool: %s path: %s size is zero", tool, path)
logger.warning(
"Empty resource file detected for tool %s at path %s", tool, path
)
missing_resources.append(TPR_RESOURCES[tool])
if len(missing_resources) > 0:
return False, f"Missing resources: {missing_resources}"
Expand Down

0 comments on commit 86a1141

Please sign in to comment.