Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "glint-monitor"
version = "1.0.2"
version = "1.0.3"
description = "A Modern Painter-Rendered Desktop System Monitor"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
11 changes: 8 additions & 3 deletions src/core/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,17 @@ def _gpu(self) -> dict[str, float | None]:
"""Read NVIDIA CLI metrics, then vendor-neutral Windows counters."""
if self._nvidia_smi:
try:
run_options = {
"capture_output": True,
"text": True,
"timeout": 2,
}
if platform.system() == "Windows":
run_options["creationflags"] = subprocess.CREATE_NO_WINDOW
result = subprocess.run(
["nvidia-smi", "--query-gpu=utilization.gpu,temperature.gpu", "--format=csv,noheader,nounits"],
capture_output=True,
check=True,
text=True,
timeout=2,
**run_options,
)
usage, temperature = result.stdout.splitlines()[0].split(",", maxsplit=1)
self._gpu_values = {"usage": float(usage.strip()), "temperature": float(temperature.strip())}
Expand Down
20 changes: 20 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,26 @@ def test_nvidia_smi_path_is_resolved_once(monkeypatch):
assert len(calls) == 1


def test_nvidia_smi_suppresses_console_only_on_windows(monkeypatch):
import src.core.sensors as sensors_module

reader = SensorReader()
reader._nvidia_smi = "nvidia-smi"
completed = Mock(stdout="40, 55\n")
run = Mock(return_value=completed)
monkeypatch.setattr(sensors_module.subprocess, "run", run)
monkeypatch.setattr(sensors_module.platform, "system", lambda: "Windows")
monkeypatch.setattr(sensors_module.subprocess, "CREATE_NO_WINDOW", 0x08000000, raising=False)

assert reader._gpu() == {"usage": 40.0, "temperature": 55.0}
assert run.call_args.kwargs["creationflags"] == 0x08000000

run.reset_mock()
monkeypatch.setattr(sensors_module.platform, "system", lambda: "Linux")
assert reader._gpu() == {"usage": 40.0, "temperature": 55.0}
assert "creationflags" not in run.call_args.kwargs


def test_get_all_skips_heavy_probes_after_stop():
import threading

Expand Down
Loading