main commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 16:30:25 +09:00
parent 91c7e04474
commit 537e7b363f
1146 changed files with 45926 additions and 77196 deletions

View File

@@ -1,6 +1,4 @@
"""System information utilities."""
from __future__ import annotations
import os
from math import ceil
@@ -11,16 +9,16 @@ __all__ = ('load_average', 'df')
if hasattr(os, 'getloadavg'):
def _load_average() -> tuple[float, ...]:
def _load_average():
return tuple(ceil(l * 1e2) / 1e2 for l in os.getloadavg())
else: # pragma: no cover
# Windows doesn't have getloadavg
def _load_average() -> tuple[float, ...]:
return 0.0, 0.0, 0.0,
def _load_average():
return (0.0, 0.0, 0.0)
def load_average() -> tuple[float, ...]:
def load_average():
"""Return system load average as a triple."""
return _load_average()
@@ -28,23 +26,23 @@ def load_average() -> tuple[float, ...]:
class df:
"""Disk information."""
def __init__(self, path: str | bytes | os.PathLike) -> None:
def __init__(self, path):
self.path = path
@property
def total_blocks(self) -> float:
def total_blocks(self):
return self.stat.f_blocks * self.stat.f_frsize / 1024
@property
def available(self) -> float:
def available(self):
return self.stat.f_bavail * self.stat.f_frsize / 1024
@property
def capacity(self) -> int:
def capacity(self):
avail = self.stat.f_bavail
used = self.stat.f_blocks - self.stat.f_bfree
return int(ceil(used * 100.0 / (used + avail) + 0.5))
@cached_property
def stat(self) -> os.statvfs_result:
def stat(self):
return os.statvfs(os.path.abspath(self.path))