Getting WMI to work with Python 3.x
Well, that was easier than I thought…
Someone emailed me recently to say that he was new to Python but wanted to use WMI to query a bunch of machines in a University Computer Lab. He’d downloaded the module from my website but when he tried to import, he got this traceback… I was rather surprised: I don’t claim my code’s perfect, but the current release has been out in the field for a while and I’d have been surprised if something so serious hadn’t been picked up before. Anyway, as you probably guessed, he was using Python 3.1, having gone to python.org and downloaded the latest version. I simply advised him to go back to 2.6 where I knew there was no problem.
But of course, that got me thinking about porting to 3.x. I’ve more-or-less followed the progress of 2to3 and various people’s attempts at porting code to 3.x, and in particular Ned Batchelder’s article a few days ago got me thinking. And coding. And the result is wmi 1.4.2 (and counting), which not only runs on all Python versions from 2.4 to 3.1 but actually has a test suite to prove it. Plus a little web engine for browsing a machine’s WMI structure.
I’m in the process of porting the documentation over to Sphinx, but there’s a pre-release version (sans extra docs) on my website or you can follow the latest and greatest on Subversion.