From 459e6b04db01b67adb8af5da70998ff2a1ec3496 Mon Sep 17 00:00:00 2001 From: dormant-user Date: Thu, 28 Nov 2024 19:49:56 -0600 Subject: [PATCH] Fix missing udisk_lib for Linux machines Update `disks` package in pyproject.toml --- docs/README.html | 2 +- docs/index.html | 4 ++-- pyninja/executors/squire.py | 25 ++++++++++++++----------- pyproject.toml | 1 + 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/README.html b/docs/README.html index 7eb3199..94aa6b2 100644 --- a/docs/README.html +++ b/docs/README.html @@ -4,7 +4,7 @@ - + PyNinja — PyNinja documentation diff --git a/docs/index.html b/docs/index.html index 7d7be40..0d93832 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@ - + Welcome to PyNinja’s documentation! — PyNinja documentation @@ -865,7 +865,7 @@

PyNinja - Executors
-pyninja.executors.squire.assert_pyudisk()
+pyninja.executors.squire.assert_pyudisk() None

Ensure disk_report is enabled only for Linux machines and load udiskctl library.

diff --git a/pyninja/executors/squire.py b/pyninja/executors/squire.py index 6e50feb..f69b822 100644 --- a/pyninja/executors/squire.py +++ b/pyninja/executors/squire.py @@ -245,20 +245,23 @@ def dynamic_numbers(string: str) -> int | float | None: return None -def assert_pyudisk(): +def assert_pyudisk() -> None: """Ensure disk_report is enabled only for Linux machines and load ``udiskctl`` library.""" - if models.env.disk_report: - assert models.OPERATING_SYSTEM == enums.OperatingSystem.linux, ValueError( - "\n\tdisk_report feature can be enabled only on Linux machines!" - ) - try: - from pyudisk.config import EnvConfig as PyUdiskConfig - except (ImportError, ModuleNotFoundError): + if models.OPERATING_SYSTEM != enums.OperatingSystem.linux: + if models.env.disk_report: raise ValueError( - "\n\tPyUdisk has not been installed. Use pip install 'PyNinja[extra]' to use disk reporting feature." + "\n\tdisk_report feature can be enabled only on Linux machines!" ) - if not models.env.udisk_lib: - models.env.udisk_lib = PyUdiskConfig().udisk_lib + return + try: + from pyudisk.config import EnvConfig as PyUdiskConfig + except (ImportError, ModuleNotFoundError): + if models.env.disk_report: + raise ValueError( + "\n\tPyUdisk has not been installed. Use pip install 'PyNinja[extra]' to view disk report metrics." + ) + return + models.env.udisk_lib = models.env.udisk_lib or PyUdiskConfig().udisk_lib def comma_separator(list_: list) -> str: diff --git a/pyproject.toml b/pyproject.toml index c31647d..8dd04fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ packages = [ "pyninja.modules", "pyninja.monitor", "pyninja.routes", + "pyninja.features.disks", "pyninja.monitor.templates" ] [tool.setuptools.package-data]