[python-win32] WMI troubles!

Alex Hall mehgcap at gmail.com
Fri Jan 15 20:38:05 CET 2010


Thanks, I will look at the article!

I do not want a single script because, eventually, the plan is to have a 
keystroke for core 1, a keystroke for core 2, a keystroke for percent of ram 
used, a keystroke for hard disk space, and so on. While I could write each 
function in its own script and put a hotkey on each one, it seems easier and 
faster to just make one script and run it once, avoiding the delay I always 
get when this script runs for the first time from happening each time I 
press a hotkey.

Sorry for the lack of detail about the errors. I knew they were wmi errors, 
so when I read back through the messages I wrote it made sense to me, but of 
course I should have said what kind of errors were being generated.


Have a great day,
Alex
Email: mehgcap at gmail.com
----- Original Message ----- 
From: "Tim Roberts" <timr at probo.com>
To: "Python-Win32 List" <python-win32 at python.org>
Sent: Friday, January 15, 2010 14:20
Subject: Re: [python-win32] WMI troubles!


> Alex Hall wrote:
>> Regarding question 2, about only receiving one number for two cores, I
>> have a counter in the loop which gets incremented each time the loop
>> runs. This counter always ends up at 1, not 2, so it is only
>> incremented once. When I first started this last week I did put any
>> returns into a list, but the list was always just one element long.
>> This seems to tell me that I am only getting one number, but I should
>> be getting two. Is there a syntax thing that I am missing or confused
>> about, or is wmi refusing me the information about my other core? Is
>> there a different class I should be using to get the load per core?
>
> The number you are getting is the average load for the physical
> processor, which includes all of the cores and hyperthreaded modules.
> If you have a dual core machine, you'll find that c.NumberOfCores is 2.
> Check this MSDN article:
>    http://msdn.microsoft.com/en-us/library/aa394317.aspx
>
> It describes the WMI Win32_PerfRawData_PerfOS_Processor class, which
> includes information per logical processor, and describes how to figure
> that out from the Win32_Processor information.
>
>
>> As far as pyHook, it sounds like it is not going to work too well. Are
>> you saying it could be the cause of the wmi troubles?
>
> Well, you didn't say what the actual error was until just a few minutes
> ago, so I didn't know the troubles were in WMI.  I assumed you were
> having troubles reaching the "Say" class or doing a "print".  It's
> possible that some of the processes you are hooking do not have
> permission to access WMI.
>
>
>> If so, is there another library I should use instead? I want this to
>> be a global thing, so no matter where in Windows you are, you need
>> only press a hotkey to hear the status of your hardware, like a
>> sighted person need only glance at their resource monitor
>> gadget/sidebar app. For that reason I avoided pyGame and wx since, as
>> I understand it, they only monitor keypresses in their windows, not
>> through the entire system.
>
> In that case, why use a hook at all?  Why not just have a single script
> that fetches and says the resource usage and then exits?  You could have
> that tied to an Explorer hotkey, just like you do now.  Windows hooks
> are a very heavyweight technology.  Your hook code gets executed for
> every keystroke and every mouse motion.
>
>
>> Finally, when you say "calling pythoncom.CoInitialize() in every
>> callback", what do you mean by 'callback'?
>
> Your OnKeyDown and OnKeyUp functions are being called in response to
> external events.  You pass those functions to pyHooks, and it "calls you
> back" when something happens.  Functions that you provide for someone
> else to call are called "callbacks".
>
> -- 
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32 



More information about the python-win32 mailing list