psutil._common

Common objects shared by __init__.py and _ps*.py modules.

Module Contents

AF_INET6
POSIX
WINDOWS
LINUX
MACOS
OSX
FREEBSD
OPENBSD
NETBSD
BSD
SUNOS
STATUS_RUNNING = running
STATUS_SLEEPING = sleeping
STATUS_DISK_SLEEP = disk-sleep
STATUS_STOPPED = stopped
STATUS_TRACING_STOP = tracing-stop
STATUS_ZOMBIE = zombie
STATUS_DEAD = dead
STATUS_WAKE_KILL = wake-kill
STATUS_WAKING = waking
STATUS_IDLE = idle
STATUS_LOCKED = locked
STATUS_WAITING = waiting
STATUS_SUSPENDED = suspended
STATUS_PARKED = parked
CONN_ESTABLISHED = ESTABLISHED
CONN_SYN_SENT = SYN_SENT
CONN_SYN_RECV = SYN_RECV
CONN_FIN_WAIT1 = FIN_WAIT1
CONN_FIN_WAIT2 = FIN_WAIT2
CONN_TIME_WAIT = TIME_WAIT
CONN_CLOSE = CLOSE
CONN_CLOSE_WAIT = CLOSE_WAIT
CONN_LAST_ACK = LAST_ACK
CONN_LISTEN = LISTEN
CONN_CLOSING = CLOSING
CONN_NONE = NONE
NIC_DUPLEX_FULL = 2
ENCODING
ENCODING_ERRS = replace
sswap
sdiskusage
sdiskio
sdiskpart
snetio
suser
sconn
snicaddr
snicstats
scpustats
pcputimes
popenfile
pthread
puids
pgids
pio
pionice
pctxsw
pconn
conn_tmap
usage_percent(used, total, round_=None)

Calculate percentage usage of ‘used’ against ‘total’.

memoize(fun)

A simple memoize decorator for functions supporting (hashable) positional arguments. It also provides a cache_clear() function for clearing the cache:

>>> @memoize
... def foo()
...     return 1
    ...
>>> foo()
1
>>> foo.cache_clear()
>>>
isfile_strict(path)

Same as os.path.isfile() but does not swallow EACCES / EPERM exceptions, see: http://mail.python.org/pipermail/python-dev/2012-June/120787.html

path_exists_strict(path)

Same as os.path.exists() but does not swallow EACCES / EPERM exceptions, see: http://mail.python.org/pipermail/python-dev/2012-June/120787.html

supports_ipv6()

Return True if IPv6 is supported on this platform.

parse_environ_block(data)

Parse a C environ block of environment variables into a dictionary.

sockfam_to_enum(num)

Convert a numeric socket family value to an IntEnum member. If it’s not a known member, return the numeric value itself.

socktype_to_enum(num)

Convert a numeric socket type value to an IntEnum member. If it’s not a known member, return the numeric value itself.

deprecated_method(replacement)

A decorator which can be used to mark a method as deprecated ‘replcement’ is the method name which will be called instead.

wrap_numbers(input_dict, name)

Given an input_dict and a function name, adjust the numbers which “wrap” (restart from zero) across different calls by adding “old value” to “new value” and return an updated dict.