devork

E pur si muove

New home for PSI

Saturday, May 30, 2009

PSI, the Python System Information package that pulls interesting information from the kernel and makes it available in a nice Python API, has a new home at bitbucket. This means that the source conde now lives inside a mercurial repository instead of subversion.

This actually happened about a week ago, but better announce it late then never...

Python System Information 0.3b1^W0.3b1.1

Thursday, May 21, 2009

Short summary: PSI is alive and we've just released the first beta of a much improved upcoming 0.3 release!

Back in 2007 Chris Miles announced PSI - Python System Information, a Python extension module to provide access to some system information not normally available to Python. Most notably it allows you to look at all processes on the system and get details like memory usage, cpu usage, users and many more things the kernel knows about a process. And all this in a pythonic way!

At the time the implementation was not perfect (when will an implementation ever be?), it had many memory leaks and reference counting errors, and sadly no one seemed to have the time and motivation to work on it for a long time. But since the beginning of this year I finally found some time to fix these issues and soon some more people joined in. Chris has been amazing in allowing access to almost anything I asked for and since then there has been steady development improving the code base, tests and API. Right now PSI does not leak any memory, and provides basic system indentification and detailed process information on Linux (2.4 & 2.6 kernels), Darwin 10.3 and up, SunOS (5.8-5.11) and AIX (5.3) and it does this for any version of Python greater then 2.3, including 3.0. Not too shabby!

There are many things we would like to do in the future too. more platform support for one. Ideally PSI should run on all the major platforms supported by Python itself (and all minor ones too). And more information too, getting information about processes is one very useful and common thing but there is so much more the kernel can tell us: CPU information and statistics, network interfaces, etc. It's a massive and never ending task, but hopefully we can do the common things on all major platforms.

Update

Version 0.3b1.1 has been released now. Seems the last version did only ship the sources for Linux and not all platforms. This bugfix release also adds the MANIFEST file so that distutils can build binary distributions from the tarball.

Sorry!

Compiling applications in setup.py

Monday, May 11, 2009

If you need to compile a random application in setup.py this is not that hard:

cc = distutils.ccompiler.new_compiler()
distutils.sysconfig.customize_compiler(cc)
cc.link_executable(['test.c'], 'a.out')

There is no need to create the object files explicitly with cc.compile() first if you have no need for them, the command line invoked by .link_executable() will do the compilation step in one go for you.

This part of distutils is actually documented, so check it out, you can pass in many optional arguments and modify the compiler object to customize things.

What's new in Python 2.6: logging

Friday, May 01, 2009

The What's New in Python 2.6 document is very good and contains loads of information, congrats for making it. But it misses out a nice addition to the logging module: LoggerAdapter Objects. It allows you to create a logger object with extra contextual information really easy:

log = logging.LoggerAdapter(logging.getLogger("subsystem"),
                            {"argv1": sys.argv[1]})
logging.basicConfig(format="%(argv1)s %(message)s")

Neat

Secondly it decided to define __all__ which means not all object are exported anymore. Unfortunately this __all__ is incomplete in 2.6.2, even getLogger is not listed in it! The good news is that this is one of the fastest bug report turnaround times I have seen, so expect this to be fixed in the next stable release.

Subscribe to: Posts (Atom)