bmctools.misc.utils
DirectoryError
Custom exception to throw directoryerror
is_command
def is_command(cmd: str) -> boolCheck whether a command is available on the current system PATH.
Args:
cmd: Command name to look up (e.g. 'racadm').
Returns:
True if the command is found on PATH.
Raises: FileNotFoundError: If the command is not found.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
cmd | str | — |
Returns: bool
is_dir_writeable
def is_dir_writeable(dir: str) -> boolTest whether a directory exists and is writeable.
Args: dir: Absolute or relative path to the directory.
Returns:
True if the directory exists and is writeable.
Raises: DirectoryError: If the directory does not exist or is not writeable.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dir | str | — |
Returns: bool
is_older_than_unit
def is_older_than_unit(given_time: str, age: int, unit: str) -> boolCheck whether a timestamp is older than the given duration.
Args:
given_time: Datetime string in '%Y-%m-%d %H:%M:%S' format.
age: Numeric age threshold.
unit: Time unit character — 'd' (days), 'h' (hours),
'm' (minutes), or 's' (seconds).
Returns:
True if given_time is older than age unit\s ago,
False otherwise.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
given_time | str | — | |
age | int | — | |
unit | str | — |
Returns: bool