Source

psi--win32 /

Filename Size Date modified Message
examples
include
psi
src
tests
1.0 KB
2.3 KB
790 B
3.4 KB

PSI - Python System Information

Overview

PSI is a Python module providing direct access to real-time system and process information.

Install

To install PSI from source:

$ python setup.py install

or, using setuptools:

$ easy_install psi

Unit Tests

To run the unit tests:

$ python setup.py test

If any tests fail, please copy & paste the output and send operating system version & details to the mailing list.

Examples

Here's an example Python session demonstrating PSI:

>>> import psi

>>> a = psi.arch.arch_type()
>>> a
<psi.arch.ArchMacOSX object type='Darwin'>
>>> isinstance(a, psi.arch.ArchMacOSX)
True
>>> isinstance(a, psi.arch.ArchDarwin)
True
>>> a.sysname
'Darwin'
>>> a.nodename
'laptop'
>>> a.release
'8.9.1'
>>> a.version
'Darwin Kernel Version 8.9.1: Thu Feb 22 20:55:00 PST 2007; root:xnu-792.18.15~1/RELEASE_I386'
>>> a.machine
'i386'

>>> psi.loadavg()
(0.705078125, 0.73046875, 0.7626953125)

>>> import os
>>> mypid = os.getpid()
>>> mypid
13903
>>> p = psi.process.Process(mypid)
>>> p.command
'Python'
>>> p.command_path
'/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python'
>>> p.user
'chris'
>>> p.start_datetime
datetime.datetime(2007, 9, 1, 10, 58, 51)
>>> p.parent
<psi.process.Process object pid=13860>
>>> p.parent.command
'bash'
>>> "%0.1f MB" % (p.resident_size/1024.0/1024.0)
'9.7 MB'
>>> "%0.1f MB" % (p.virtual_size/1024.0/1024.0)
'43.5 MB'

>>> ps = psi.process.ProcessTable()
>>> ps.count
115
>>> ps.pids
(0, 1, 27, 31, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 56, 59, 63, 66, 67, 69, 71, 72, 89, 117, 122, 134, 136, 149, 155, 156, 159, 162, 172, 175, 176, 177, 179, 180, 182, 183, 190, 194, 214, 229, 238, 242, 245, 246, 248, 251, 256, 257, 264, 265, 267, 268, 270, 271, 272, 273, 274, 286, 392, 401, 402, 403, 1135, 1258, 1442, 1589, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 2575, 2577, 2578, 2616, 2631, 2632, 9118, 9903, 10159, 10990, 12444, 12596, 13122, 13582, 13840, 13904, 13973, 13974, 13976, 14404, 14579, 14580, 14587, 14627, 14719)
>>> p = ps.processes[114]
>>> p.command
'TextMate'