Skip to content

Commit d38b648

Browse files
authored
[psutil] Complete AIX (#15088)
1 parent 1218f18 commit d38b648

File tree

2 files changed

+154
-135
lines changed

2 files changed

+154
-135
lines changed

stubs/psutil/psutil/_psaix.pyi

Lines changed: 100 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,112 @@
1-
from _typeshed import Incomplete
2-
from typing import NamedTuple
1+
import sys
32

4-
from psutil._common import (
5-
NIC_DUPLEX_FULL as NIC_DUPLEX_FULL,
6-
NIC_DUPLEX_HALF as NIC_DUPLEX_HALF,
7-
NIC_DUPLEX_UNKNOWN as NIC_DUPLEX_UNKNOWN,
8-
AccessDenied as AccessDenied,
9-
NoSuchProcess as NoSuchProcess,
10-
ZombieProcess as ZombieProcess,
11-
conn_to_ntuple as conn_to_ntuple,
12-
get_procfs_path as get_procfs_path,
13-
memoize_when_activated as memoize_when_activated,
14-
usage_percent as usage_percent,
15-
)
3+
# sys.platform.startswith("aix"):
4+
if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin":
5+
from collections.abc import Callable
6+
from typing import Final, Literal, NamedTuple, TypeVar, overload
7+
from typing_extensions import ParamSpec
168

17-
__extra__all__: Incomplete
18-
HAS_THREADS: Incomplete
19-
HAS_NET_IO_COUNTERS: Incomplete
20-
HAS_PROC_IO_COUNTERS: Incomplete
21-
PAGE_SIZE: Incomplete
22-
AF_LINK: Incomplete
23-
PROC_STATUSES: Incomplete
24-
TCP_STATUSES: Incomplete
25-
proc_info_map: Incomplete
9+
from psutil._common import (
10+
NIC_DUPLEX_FULL as NIC_DUPLEX_FULL,
11+
NIC_DUPLEX_HALF as NIC_DUPLEX_HALF,
12+
NIC_DUPLEX_UNKNOWN as NIC_DUPLEX_UNKNOWN,
13+
AccessDenied as AccessDenied,
14+
NoSuchProcess as NoSuchProcess,
15+
ZombieProcess as ZombieProcess,
16+
conn_to_ntuple as conn_to_ntuple,
17+
get_procfs_path as get_procfs_path,
18+
memoize_when_activated as memoize_when_activated,
19+
usage_percent as usage_percent,
20+
)
2621

27-
class pmem(NamedTuple):
28-
rss: Incomplete
29-
vms: Incomplete
22+
from . import _common, _psposix, _psutil_aix
3023

31-
pfullmem = pmem
24+
__extra__all__: Final[list[str]]
25+
HAS_THREADS: Final[bool]
26+
HAS_NET_IO_COUNTERS: Final[bool]
27+
HAS_PROC_IO_COUNTERS: Final[bool]
28+
PAGE_SIZE: Final[int]
29+
AF_LINK: Final = 18
30+
PROC_STATUSES: Final[dict[int, str]]
31+
TCP_STATUSES: Final[dict[int, str]]
32+
proc_info_map: Final[dict[str, int]]
3233

33-
class scputimes(NamedTuple):
34-
user: float
35-
system: float
36-
idle: float
37-
iowait: float
34+
class pmem(NamedTuple):
35+
rss: int
36+
vms: int
3837

39-
class svmem(NamedTuple):
40-
total: Incomplete
41-
available: Incomplete
42-
percent: Incomplete
43-
used: Incomplete
44-
free: Incomplete
38+
pfullmem = pmem
4539

46-
def virtual_memory(): ...
47-
def swap_memory(): ...
48-
def cpu_times(): ...
49-
def per_cpu_times(): ...
50-
def cpu_count_logical(): ...
51-
def cpu_count_cores(): ...
52-
def cpu_stats(): ...
40+
class scputimes(NamedTuple):
41+
user: float
42+
system: float
43+
idle: float
44+
iowait: float
5345

54-
disk_io_counters: Incomplete
55-
disk_usage: Incomplete
46+
class svmem(NamedTuple):
47+
total: int
48+
available: int
49+
percent: float
50+
used: int
51+
free: int
5652

57-
def disk_partitions(all: bool = ...): ...
53+
_P = ParamSpec("_P")
54+
_R = TypeVar("_R")
5855

59-
net_if_addrs: Incomplete
60-
net_io_counters: Incomplete
56+
def virtual_memory() -> svmem: ...
57+
def swap_memory() -> _common.sswap: ...
58+
def cpu_times() -> scputimes: ...
59+
def per_cpu_times() -> list[scputimes]: ...
60+
def cpu_count_logical() -> int | None: ...
61+
def cpu_count_cores() -> int | None: ...
62+
def cpu_stats() -> _common.scpustats: ...
6163

62-
def net_connections(kind, _pid: int = ...): ...
63-
def net_if_stats(): ...
64-
def boot_time(): ...
65-
def users(): ...
66-
def pids(): ...
67-
def pid_exists(pid): ...
68-
def wrap_exceptions(fun): ...
64+
disk_io_counters = _psutil_aix.disk_io_counters
65+
disk_usage = _psposix.disk_usage
6966

70-
class Process:
71-
pid: Incomplete
72-
def __init__(self, pid) -> None: ...
73-
def oneshot_enter(self) -> None: ...
74-
def oneshot_exit(self) -> None: ...
75-
def name(self): ...
76-
def exe(self): ...
77-
def cmdline(self): ...
78-
def environ(self): ...
79-
def create_time(self): ...
80-
def num_threads(self): ...
81-
def threads(self): ...
82-
def net_connections(self, kind: str = ...): ...
83-
def nice_get(self): ...
84-
def nice_set(self, value): ...
85-
def ppid(self): ...
86-
def uids(self): ...
87-
def gids(self): ...
88-
def cpu_times(self): ...
89-
def terminal(self): ...
90-
def cwd(self): ...
91-
def memory_info(self): ...
92-
memory_full_info: Incomplete
93-
def status(self): ...
94-
def open_files(self): ...
95-
def num_fds(self): ...
96-
def num_ctx_switches(self): ...
97-
def wait(self, timeout: Incomplete | None = ...): ...
98-
def io_counters(self): ...
67+
def disk_partitions(all: bool = False) -> list[_common.sdiskpart]: ...
68+
69+
net_if_addrs = _psutil_aix.net_if_addrs
70+
net_io_counters = _psutil_aix.net_io_counters
71+
72+
@overload
73+
def net_connections(kind: str, _pid: Literal[-1] = -1) -> list[_common.sconn]: ...
74+
@overload
75+
def net_connections(kind: str, _pid: int = -1) -> list[_common.pconn]: ...
76+
def net_if_stats() -> dict[str, _common.snicstats]: ...
77+
def boot_time() -> float: ...
78+
def users() -> list[_common.suser]: ...
79+
def pids() -> list[int]: ...
80+
def pid_exists(pid: int | str) -> bool: ...
81+
def wrap_exceptions(fun: Callable[_P, _R]) -> Callable[_P, _R]: ...
82+
83+
class Process:
84+
__slots__ = ["_cache", "_name", "_ppid", "_procfs_path", "pid"]
85+
pid: int
86+
def __init__(self, pid: int) -> None: ...
87+
def oneshot_enter(self) -> None: ...
88+
def oneshot_exit(self) -> None: ...
89+
def name(self) -> str: ...
90+
def exe(self) -> str: ...
91+
def cmdline(self) -> list[str]: ...
92+
def environ(self) -> dict[str, str]: ...
93+
def create_time(self) -> float: ...
94+
def num_threads(self) -> int: ...
95+
def threads(self) -> list[_common.pthread]: ...
96+
def net_connections(self, kind: str = "inet") -> list[_common.pconn]: ...
97+
def nice_get(self) -> int: ...
98+
def nice_set(self, value: int) -> None: ...
99+
def ppid(self) -> int: ...
100+
def uids(self) -> _common.puids: ...
101+
def gids(self) -> _common.puids: ...
102+
def cpu_times(self) -> _common.pcputimes: ...
103+
def terminal(self) -> str | None: ...
104+
def cwd(self) -> str: ...
105+
def memory_info(self) -> pmem: ...
106+
memory_full_info = memory_info
107+
def status(self) -> str: ...
108+
def open_files(self) -> list[_common.popenfile]: ...
109+
def num_fds(self) -> int: ...
110+
def num_ctx_switches(self) -> _common.pctxsw: ...
111+
def wait(self, timeout: float | None = None): ...
112+
def io_counters(self) -> _common.pio: ...
Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,58 @@
1-
from _typeshed import Incomplete
1+
import sys
22

3-
# TODO: Add POSIX constants and check their aviability (see psutil_posix_add_constants)
4-
AF_LINK: Incomplete
3+
# sys.platform.startswith("aix"):
4+
if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin":
5+
from typing import Final
56

6-
def getpagesize() -> int: ...
7-
def net_if_addrs(): ...
8-
def net_if_flags(nic_name: str, /) -> list[str]: ...
9-
def net_if_is_running(nic_name: str, /) -> bool: ...
10-
def net_if_mtu(nic_name: str, /) -> int: ...
11-
def proc_priority_get(pid: int, /) -> int: ...
12-
def proc_priority_set(pid: int, priority: int, /) -> None: ...
7+
AF_LINK: Final = 18
138

14-
version: Incomplete
15-
SIDL: Incomplete
16-
SZOMB: Incomplete
17-
SACTIVE: Incomplete
18-
SSWAP: Incomplete
19-
SSTOP: Incomplete
20-
TCPS_CLOSED: Incomplete
21-
TCPS_CLOSING: Incomplete
22-
TCPS_CLOSE_WAIT: Incomplete
23-
TCPS_LISTEN: Incomplete
24-
TCPS_ESTABLISHED: Incomplete
25-
TCPS_SYN_SENT: Incomplete
26-
TCPS_SYN_RCVD: Incomplete
27-
TCPS_FIN_WAIT_1: Incomplete
28-
TCPS_FIN_WAIT_2: Incomplete
29-
TCPS_LAST_ACK: Incomplete
30-
TCPS_TIME_WAIT: Incomplete
31-
PSUTIL_CONN_NONE: Incomplete
9+
def getpagesize() -> int: ...
10+
def net_if_addrs(): ...
11+
def net_if_flags(nic_name: str, /) -> list[str]: ...
12+
def net_if_is_running(nic_name: str, /) -> bool: ...
13+
def net_if_mtu(nic_name: str, /) -> int: ...
14+
def proc_priority_get(pid: int, /) -> int: ...
15+
def proc_priority_set(pid: int, priority: int, /) -> None: ...
3216

33-
def proc_args(pid: int, /) -> list[str]: ...
34-
def proc_basic_info(pid: int, procfs_path: str, /): ...
35-
def proc_cpu_times(pid: int, procfs_path: str, /): ...
36-
def proc_cred(pid: int, procfs_path: str, /): ...
37-
def proc_environ(pid: int, /): ...
38-
def proc_name(pid: int, procfs_path: str, /): ...
39-
def proc_threads(pid: int, /): ...
40-
def proc_io_counters(pid: int, /): ...
41-
def proc_num_ctx_switches(requested_pid: int, /): ...
42-
def boot_time(): ...
43-
def disk_io_counters(): ...
44-
def disk_partitions(): ...
45-
def per_cpu_times(): ...
46-
def swap_mem(): ...
47-
def virtual_mem(): ...
48-
def net_io_counters(): ...
49-
def cpu_stats(): ...
50-
def net_connections(requested_pid: int, /): ...
51-
def net_if_stats(nic_name: str, /): ...
52-
def check_pid_range(pid: int, /) -> None: ...
53-
def set_debug(value: bool, /) -> None: ...
17+
version: Final[int]
18+
SIDL: Final[int]
19+
SZOMB: Final[int]
20+
SACTIVE: Final[int]
21+
SSWAP: Final[int]
22+
SSTOP: Final[int]
23+
TCPS_CLOSED: Final[int]
24+
TCPS_CLOSING: Final[int]
25+
TCPS_CLOSE_WAIT: Final[int]
26+
TCPS_LISTEN: Final[int]
27+
TCPS_ESTABLISHED: Final[int]
28+
TCPS_SYN_SENT: Final[int]
29+
TCPS_SYN_RCVD: Final[int]
30+
TCPS_FIN_WAIT_1: Final[int]
31+
TCPS_FIN_WAIT_2: Final[int]
32+
TCPS_LAST_ACK: Final[int]
33+
TCPS_TIME_WAIT: Final[int]
34+
PSUTIL_CONN_NONE: Final = 128
35+
36+
def proc_args(pid: int, /) -> list[str]: ...
37+
def proc_basic_info(pid: int, procfs_path: str, /) -> tuple[int, int, int, float, int, int, int, int]: ...
38+
def proc_cpu_times(pid: int, procfs_path: str, /) -> tuple[float, float, float, float]: ...
39+
def proc_cred(pid: int, procfs_path: str, /) -> tuple[int, int, int, int, int, int]: ...
40+
def proc_environ(pid: int, /) -> dict[str, str]: ...
41+
def proc_name(pid: int, procfs_path: str, /) -> str: ...
42+
def proc_threads(pid: int, /) -> list[tuple[int, float, float]]: ...
43+
def proc_io_counters(pid: int, /) -> tuple[int, int, int, int]: ...
44+
def proc_num_ctx_switches(requested_pid: int, /) -> tuple[int, int]: ...
45+
def boot_time() -> float: ...
46+
def disk_io_counters() -> dict[str, tuple[int, int, int, int, int, int]]: ...
47+
def disk_partitions() -> list[tuple[str, str, str, str]]: ...
48+
def per_cpu_times() -> list[tuple[float, float, float, float]]: ...
49+
def swap_mem() -> tuple[int, int, int, int]: ...
50+
def virtual_mem() -> tuple[int, int, int, int, int]: ...
51+
def net_io_counters() -> dict[str, tuple[int, int, int, int, int, int, int, int]]: ...
52+
def cpu_stats() -> tuple[int, int, int, int]: ...
53+
def net_connections(
54+
requested_pid: int, /
55+
) -> list[tuple[int, int, int, str | tuple[str, int], str | tuple[str, int] | tuple[()], int, int]]: ...
56+
def net_if_stats(nic_name: str, /) -> tuple[bool, int]: ... # It's actually list of 2 elements
57+
def check_pid_range(pid: int, /) -> None: ...
58+
def set_debug(value: bool, /) -> None: ...

0 commit comments

Comments
 (0)