host-pressure 0.1.0__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,53 @@
1
+ """Native host load readings, and a verdict, with no subprocess and no dependency.
2
+
3
+ import host_pressure
4
+
5
+ host_pressure.read() # every reading, as a dict
6
+ host_pressure.verdict() # {"level": "ok", "reasons": []}
7
+ """
8
+ from __future__ import annotations
9
+
10
+ __version__ = "0.1.0"
11
+
12
+ from typing import Any, Dict, Optional
13
+
14
+ from . import _core
15
+ from .verdict import LEVELS, Thresholds, load_thresholds
16
+ from .verdict import verdict as _classify
17
+
18
+ read = _core.read_host_resources
19
+ read_host_resources = _core.read_host_resources
20
+ sample_cpu_percent = _core.sample_cpu_percent
21
+ get_persisted_cpu_percent = _core.get_persisted_cpu_percent
22
+ format_uptime = _core.format_uptime
23
+
24
+
25
+ def verdict(
26
+ readings: Optional[Dict[str, Any]] = None,
27
+ thresholds: Optional[Thresholds] = None,
28
+ sample: Optional[float] = 0.2,
29
+ **options: Any,
30
+ ) -> Dict[str, Any]:
31
+ """Classify one reading as ok, busy or overloaded, with the reasons.
32
+
33
+ Without ``readings`` this reads first. That default sleeps ``sample``
34
+ seconds because CPU needs two samples; pass ``sample=None`` or your own
35
+ ``read()`` result to avoid waiting.
36
+ """
37
+ if readings is None:
38
+ readings = _core.read_host_resources(sample=sample, **options)
39
+ return _classify(readings, thresholds)
40
+
41
+
42
+ __all__ = [
43
+ "LEVELS",
44
+ "Thresholds",
45
+ "__version__",
46
+ "format_uptime",
47
+ "get_persisted_cpu_percent",
48
+ "load_thresholds",
49
+ "read",
50
+ "read_host_resources",
51
+ "sample_cpu_percent",
52
+ "verdict",
53
+ ]
@@ -0,0 +1,6 @@
1
+ """Allow `python -m host_pressure`."""
2
+
3
+ from .cli import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(main())