psutil._pswindows

Windows platform implementation.

Module Contents

msg = this Windows version is too old (< Windows Vista);
enum
__extra__all__ = ['win_service_iter', 'win_service_get', 'ABOVE_NORMAL_PRIORITY_CLASS', 'BELOW_NORMAL_PRIORITY_CLASS', 'HIGH_PRIORITY_CLASS', 'IDLE_PRIORITY_CLASS', 'NORMAL_PRIORITY_CLASS', 'REALTIME_PRIORITY_CLASS', 'CONN_DELETE_TCB', 'AF_LINK']
CONN_DELETE_TCB = DELETE_TCB
ACCESS_DENIED_ERRSET
NO_SUCH_SERVICE_ERRSET
HAS_PROC_IO_PRIORITY
TCP_STATUSES
class Priority

Bases:enum.IntEnum

ABOVE_NORMAL_PRIORITY_CLASS
BELOW_NORMAL_PRIORITY_CLASS
HIGH_PRIORITY_CLASS
IDLE_PRIORITY_CLASS
NORMAL_PRIORITY_CLASS
REALTIME_PRIORITY_CLASS
pinfo_map
NoSuchProcess
ZombieProcess
AccessDenied
TimeoutExpired
WIN_10 = [10, 0]
WIN_8 = [6, 2]
WIN_7 = [6, 1]
WIN_SERVER_2008 = [6, 0]
WIN_VISTA = [6, 0]
WIN_SERVER_2003 = [5, 2]
WIN_XP = [5, 1]
get_winver()

Usage: >>> if get_winver() <= WIN_VISTA: … …

IS_WIN_XP
scputimes
svmem
pmem
pfullmem
pmmap_grouped
pmmap_ext
pio
convert_dos_path(s)
Convert paths using native DOS format like:
“DeviceHarddiskVolume1Windowssystemewfile.txt”
into:
“C:Windowssystemewfile.txt”
py2_strencode(s)

Encode a unicode string to a byte string by using the default fs encoding + “replace” error handler.

virtual_memory()

System virtual memory as a namedtuple.

swap_memory()

Swap system memory as a (total, used, free, sin, sout) tuple.

disk_io_counters
disk_usage(path)

Return disk usage associated with path.

disk_partitions(all)

Return disk partitions.

cpu_times()

Return system CPU times as a named tuple.

per_cpu_times()

Return system per-CPU times as a list of named tuples.

cpu_count_logical()

Return the number of logical CPUs in the system.

cpu_count_physical()

Return the number of physical CPU cores in the system.

cpu_stats()

Return CPU statistics.

cpu_freq()

Return CPU frequency. On Windows per-cpu frequency is not supported.

net_connections(kind, _pid=-1)

Return socket connections. If pid == -1 return system-wide connections (as opposed to connections opened by one process only).

net_if_stats()

Get NIC stats (isup, duplex, speed, mtu).

net_io_counters()

Return network I/O statistics for every network interface installed on the system as a dict of raw tuples.

net_if_addrs()

Return the addresses associated to each NIC.

sensors_battery()

Return battery information.

_last_btime = 0
boot_time()

The system boot time expressed in seconds since the epoch.

users()

Return currently connected users as a list of namedtuples.

win_service_iter()

Yields a list of WindowsService instances.

win_service_get(name)

Open a Windows service and return it as a WindowsService instance.

class WindowsService(name, display_name)

Bases:object

Represents an installed Windows service.

__str__(self)
__repr__(self)
__eq__(self, other)
__ne__(self, other)
_query_config(self)
_query_status(self)
_wrap_exceptions(self)

Ctx manager which translates bare OSError and WindowsError exceptions into NoSuchProcess and AccessDenied.

name(self)

The service name. This string is how a service is referenced and can be passed to win_service_get() to get a new WindowsService instance.

display_name(self)

The service display name. The value is cached when this class is instantiated.

binpath(self)

The fully qualified path to the service binary/exe file as a string, including command line arguments.

username(self)

The name of the user that owns this service.

start_type(self)

A string which can either be “automatic”, “manual” or “disabled”.

pid(self)

The process PID, if any, else None. This can be passed to Process class to control the service’s process.

status(self)

Service status as a string.

description(self)

Service long description.

as_dict(self)

Utility method retrieving all the information above as a dictionary.

pids
pid_exists
ppid_map
wrap_exceptions(fun)

Decorator which translates bare OSError and WindowsError exceptions into NoSuchProcess and AccessDenied.

class Process(pid)

Bases:object

Wrapper class around underlying C implementation.

__slots__ = ['pid', '_name', '_ppid', '_cache']
oneshot_enter(self)
oneshot_exit(self)
oneshot_info(self)

Return multiple information about this process as a raw tuple.

name(self)

Return process name, which on Windows is always the final part of the executable.

exe(self)
cmdline(self)
environ(self)
ppid(self)
_get_raw_meminfo(self)
memory_info(self)
memory_full_info(self)
memory_maps(self)
kill(self)
send_signal(self, sig)
wait(self, timeout=None)
username(self)
create_time(self)
num_threads(self)
threads(self)
cpu_times(self)
suspend(self)
resume(self)
cwd(self)
open_files(self)
connections(self, kind='inet')
nice_get(self)
nice_set(self, value)
ionice_get(self)
io_counters(self)
status(self)
cpu_affinity_get(self)
cpu_affinity_set(self, value)
num_handles(self)
num_ctx_switches(self)