From cdbd3c77577cd9eeff62556b7b89f432ebda294c Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 26 Nov 2025 02:03:52 +0400 Subject: [PATCH] [psutil] Complete aix --- stubs/psutil/psutil/_psaix.pyi | 186 +++++++++++++++------------- stubs/psutil/psutil/_psutil_aix.pyi | 103 +++++++-------- 2 files changed, 154 insertions(+), 135 deletions(-) diff --git a/stubs/psutil/psutil/_psaix.pyi b/stubs/psutil/psutil/_psaix.pyi index 7192f40df856..b6632083c2f7 100644 --- a/stubs/psutil/psutil/_psaix.pyi +++ b/stubs/psutil/psutil/_psaix.pyi @@ -1,98 +1,112 @@ -from _typeshed import Incomplete -from typing import NamedTuple +import sys -from psutil._common import ( - NIC_DUPLEX_FULL as NIC_DUPLEX_FULL, - NIC_DUPLEX_HALF as NIC_DUPLEX_HALF, - NIC_DUPLEX_UNKNOWN as NIC_DUPLEX_UNKNOWN, - AccessDenied as AccessDenied, - NoSuchProcess as NoSuchProcess, - ZombieProcess as ZombieProcess, - conn_to_ntuple as conn_to_ntuple, - get_procfs_path as get_procfs_path, - memoize_when_activated as memoize_when_activated, - usage_percent as usage_percent, -) +# sys.platform.startswith("aix"): +if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": + from collections.abc import Callable + from typing import Final, Literal, NamedTuple, TypeVar, overload + from typing_extensions import ParamSpec -__extra__all__: Incomplete -HAS_THREADS: Incomplete -HAS_NET_IO_COUNTERS: Incomplete -HAS_PROC_IO_COUNTERS: Incomplete -PAGE_SIZE: Incomplete -AF_LINK: Incomplete -PROC_STATUSES: Incomplete -TCP_STATUSES: Incomplete -proc_info_map: Incomplete + from psutil._common import ( + NIC_DUPLEX_FULL as NIC_DUPLEX_FULL, + NIC_DUPLEX_HALF as NIC_DUPLEX_HALF, + NIC_DUPLEX_UNKNOWN as NIC_DUPLEX_UNKNOWN, + AccessDenied as AccessDenied, + NoSuchProcess as NoSuchProcess, + ZombieProcess as ZombieProcess, + conn_to_ntuple as conn_to_ntuple, + get_procfs_path as get_procfs_path, + memoize_when_activated as memoize_when_activated, + usage_percent as usage_percent, + ) -class pmem(NamedTuple): - rss: Incomplete - vms: Incomplete + from . import _common, _psposix, _psutil_aix -pfullmem = pmem + __extra__all__: Final[list[str]] + HAS_THREADS: Final[bool] + HAS_NET_IO_COUNTERS: Final[bool] + HAS_PROC_IO_COUNTERS: Final[bool] + PAGE_SIZE: Final[int] + AF_LINK: Final = 18 + PROC_STATUSES: Final[dict[int, str]] + TCP_STATUSES: Final[dict[int, str]] + proc_info_map: Final[dict[str, int]] -class scputimes(NamedTuple): - user: float - system: float - idle: float - iowait: float + class pmem(NamedTuple): + rss: int + vms: int -class svmem(NamedTuple): - total: Incomplete - available: Incomplete - percent: Incomplete - used: Incomplete - free: Incomplete + pfullmem = pmem -def virtual_memory(): ... -def swap_memory(): ... -def cpu_times(): ... -def per_cpu_times(): ... -def cpu_count_logical(): ... -def cpu_count_cores(): ... -def cpu_stats(): ... + class scputimes(NamedTuple): + user: float + system: float + idle: float + iowait: float -disk_io_counters: Incomplete -disk_usage: Incomplete + class svmem(NamedTuple): + total: int + available: int + percent: float + used: int + free: int -def disk_partitions(all: bool = ...): ... + _P = ParamSpec("_P") + _R = TypeVar("_R") -net_if_addrs: Incomplete -net_io_counters: Incomplete + def virtual_memory() -> svmem: ... + def swap_memory() -> _common.sswap: ... + def cpu_times() -> scputimes: ... + def per_cpu_times() -> list[scputimes]: ... + def cpu_count_logical() -> int | None: ... + def cpu_count_cores() -> int | None: ... + def cpu_stats() -> _common.scpustats: ... -def net_connections(kind, _pid: int = ...): ... -def net_if_stats(): ... -def boot_time(): ... -def users(): ... -def pids(): ... -def pid_exists(pid): ... -def wrap_exceptions(fun): ... + disk_io_counters = _psutil_aix.disk_io_counters + disk_usage = _psposix.disk_usage -class Process: - pid: Incomplete - def __init__(self, pid) -> None: ... - def oneshot_enter(self) -> None: ... - def oneshot_exit(self) -> None: ... - def name(self): ... - def exe(self): ... - def cmdline(self): ... - def environ(self): ... - def create_time(self): ... - def num_threads(self): ... - def threads(self): ... - def net_connections(self, kind: str = ...): ... - def nice_get(self): ... - def nice_set(self, value): ... - def ppid(self): ... - def uids(self): ... - def gids(self): ... - def cpu_times(self): ... - def terminal(self): ... - def cwd(self): ... - def memory_info(self): ... - memory_full_info: Incomplete - def status(self): ... - def open_files(self): ... - def num_fds(self): ... - def num_ctx_switches(self): ... - def wait(self, timeout: Incomplete | None = ...): ... - def io_counters(self): ... + def disk_partitions(all: bool = False) -> list[_common.sdiskpart]: ... + + net_if_addrs = _psutil_aix.net_if_addrs + net_io_counters = _psutil_aix.net_io_counters + + @overload + def net_connections(kind: str, _pid: Literal[-1] = -1) -> list[_common.sconn]: ... + @overload + def net_connections(kind: str, _pid: int = -1) -> list[_common.pconn]: ... + def net_if_stats() -> dict[str, _common.snicstats]: ... + def boot_time() -> float: ... + def users() -> list[_common.suser]: ... + def pids() -> list[int]: ... + def pid_exists(pid: int | str) -> bool: ... + def wrap_exceptions(fun: Callable[_P, _R]) -> Callable[_P, _R]: ... + + class Process: + __slots__ = ["_cache", "_name", "_ppid", "_procfs_path", "pid"] + pid: int + def __init__(self, pid: int) -> None: ... + def oneshot_enter(self) -> None: ... + def oneshot_exit(self) -> None: ... + def name(self) -> str: ... + def exe(self) -> str: ... + def cmdline(self) -> list[str]: ... + def environ(self) -> dict[str, str]: ... + def create_time(self) -> float: ... + def num_threads(self) -> int: ... + def threads(self) -> list[_common.pthread]: ... + def net_connections(self, kind: str = "inet") -> list[_common.pconn]: ... + def nice_get(self) -> int: ... + def nice_set(self, value: int) -> None: ... + def ppid(self) -> int: ... + def uids(self) -> _common.puids: ... + def gids(self) -> _common.puids: ... + def cpu_times(self) -> _common.pcputimes: ... + def terminal(self) -> str | None: ... + def cwd(self) -> str: ... + def memory_info(self) -> pmem: ... + memory_full_info = memory_info + def status(self) -> str: ... + def open_files(self) -> list[_common.popenfile]: ... + def num_fds(self) -> int: ... + def num_ctx_switches(self) -> _common.pctxsw: ... + def wait(self, timeout: float | None = None): ... + def io_counters(self) -> _common.pio: ... diff --git a/stubs/psutil/psutil/_psutil_aix.pyi b/stubs/psutil/psutil/_psutil_aix.pyi index 654cf7691924..9847329a318c 100644 --- a/stubs/psutil/psutil/_psutil_aix.pyi +++ b/stubs/psutil/psutil/_psutil_aix.pyi @@ -1,53 +1,58 @@ -from _typeshed import Incomplete +import sys -# TODO: Add POSIX constants and check their aviability (see psutil_posix_add_constants) -AF_LINK: Incomplete +# sys.platform.startswith("aix"): +if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": + from typing import Final -def getpagesize() -> int: ... -def net_if_addrs(): ... -def net_if_flags(nic_name: str, /) -> list[str]: ... -def net_if_is_running(nic_name: str, /) -> bool: ... -def net_if_mtu(nic_name: str, /) -> int: ... -def proc_priority_get(pid: int, /) -> int: ... -def proc_priority_set(pid: int, priority: int, /) -> None: ... + AF_LINK: Final = 18 -version: Incomplete -SIDL: Incomplete -SZOMB: Incomplete -SACTIVE: Incomplete -SSWAP: Incomplete -SSTOP: Incomplete -TCPS_CLOSED: Incomplete -TCPS_CLOSING: Incomplete -TCPS_CLOSE_WAIT: Incomplete -TCPS_LISTEN: Incomplete -TCPS_ESTABLISHED: Incomplete -TCPS_SYN_SENT: Incomplete -TCPS_SYN_RCVD: Incomplete -TCPS_FIN_WAIT_1: Incomplete -TCPS_FIN_WAIT_2: Incomplete -TCPS_LAST_ACK: Incomplete -TCPS_TIME_WAIT: Incomplete -PSUTIL_CONN_NONE: Incomplete + def getpagesize() -> int: ... + def net_if_addrs(): ... + def net_if_flags(nic_name: str, /) -> list[str]: ... + def net_if_is_running(nic_name: str, /) -> bool: ... + def net_if_mtu(nic_name: str, /) -> int: ... + def proc_priority_get(pid: int, /) -> int: ... + def proc_priority_set(pid: int, priority: int, /) -> None: ... -def proc_args(pid: int, /) -> list[str]: ... -def proc_basic_info(pid: int, procfs_path: str, /): ... -def proc_cpu_times(pid: int, procfs_path: str, /): ... -def proc_cred(pid: int, procfs_path: str, /): ... -def proc_environ(pid: int, /): ... -def proc_name(pid: int, procfs_path: str, /): ... -def proc_threads(pid: int, /): ... -def proc_io_counters(pid: int, /): ... -def proc_num_ctx_switches(requested_pid: int, /): ... -def boot_time(): ... -def disk_io_counters(): ... -def disk_partitions(): ... -def per_cpu_times(): ... -def swap_mem(): ... -def virtual_mem(): ... -def net_io_counters(): ... -def cpu_stats(): ... -def net_connections(requested_pid: int, /): ... -def net_if_stats(nic_name: str, /): ... -def check_pid_range(pid: int, /) -> None: ... -def set_debug(value: bool, /) -> None: ... + version: Final[int] + SIDL: Final[int] + SZOMB: Final[int] + SACTIVE: Final[int] + SSWAP: Final[int] + SSTOP: Final[int] + TCPS_CLOSED: Final[int] + TCPS_CLOSING: Final[int] + TCPS_CLOSE_WAIT: Final[int] + TCPS_LISTEN: Final[int] + TCPS_ESTABLISHED: Final[int] + TCPS_SYN_SENT: Final[int] + TCPS_SYN_RCVD: Final[int] + TCPS_FIN_WAIT_1: Final[int] + TCPS_FIN_WAIT_2: Final[int] + TCPS_LAST_ACK: Final[int] + TCPS_TIME_WAIT: Final[int] + PSUTIL_CONN_NONE: Final = 128 + + def proc_args(pid: int, /) -> list[str]: ... + def proc_basic_info(pid: int, procfs_path: str, /) -> tuple[int, int, int, float, int, int, int, int]: ... + def proc_cpu_times(pid: int, procfs_path: str, /) -> tuple[float, float, float, float]: ... + def proc_cred(pid: int, procfs_path: str, /) -> tuple[int, int, int, int, int, int]: ... + def proc_environ(pid: int, /) -> dict[str, str]: ... + def proc_name(pid: int, procfs_path: str, /) -> str: ... + def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ... + def proc_io_counters(pid: int, /) -> tuple[int, int, int, int]: ... + def proc_num_ctx_switches(requested_pid: int, /) -> tuple[int, int]: ... + def boot_time() -> float: ... + def disk_io_counters() -> dict[str, tuple[int, int, int, int, int, int]]: ... + def disk_partitions() -> list[tuple[str, str, str, str]]: ... + def per_cpu_times() -> list[tuple[float, float, float, float]]: ... + def swap_mem() -> tuple[int, int, int, int]: ... + def virtual_mem() -> tuple[int, int, int, int, int]: ... + def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ... + def cpu_stats() -> tuple[int, int, int, int]: ... + def net_connections( + requested_pid: int, / + ) -> list[tuple[int, int, int, str | tuple[str, int], str | tuple[str, int] | tuple[()], int, int]]: ... + def net_if_stats(nic_name: str, /) -> tuple[bool, int]: ... # It's actually list of 2 elements + def check_pid_range(pid: int, /) -> None: ... + def set_debug(value: bool, /) -> None: ...