[python-win32] WMI troubles!

Tim Golden mail at timgolden.me.uk
Fri Jan 15 10:00:04 CET 2010


On 15/01/2010 05:05, Alex Hall wrote:
> Hello all,
> I just joined this list. I am pretty new to Python, but I really like and
> hope to get more into it;

Welcome to the list. And to Python.

> Anyway, onto the problem. I am working on a simple resource monitor (I have
> never found one that works well with screen readers, so I am writing one). I
> am using python2.6 with all the win32 libs installed. My monitor will use
> wmi to get all of its information, and it was going pretty well until a few
> hours ago, when I started receiving seemingly random errors.

What would definitely help, and this is general advice for posting
to technical groups, is the exact error you received -- the traceback
which looks something like this:

Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "c:\work_in_progress\wmi\trunk\wmi.py", line 1124, in __getattr__
     return getattr (self._namespace, attribute)
   File "c:\python26\lib\site-packages\win32com\client\dynamic.py", line 512, in __getattr__
     raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: winmgmts:.Win32_Processx
>>>

In addition -- and I appreciate that this isn't always easy -- is
the smallest self-contained code example which will fail every time.
Apart from making it easier for people to help you out, it sometimes
makes the source of the error clearer even to you, the developer.

I don't have time now, but I will get to this later on today. The
likeliest cause is that PyHook is introducing a threading context
which is causing problems with the COM-based WMI stuff. Your early
CoInitialize is a nod in the right direction, but unfortunately
redundant where you've put it at the top of the main thread.

But sight of the traceback should help clarify things considerably.

TJG


More information about the python-win32 mailing list