On Mon, Oct 12, 2009 at 12:13, Tim Golden <m...@timgolden.me.uk> wrote:
> Ummm. Not quite.
>
> c.Win32_Processor is a class-ish thing which you have to call to
> pull back the *list* of instances. Which you can then just
> count. So something like this:
>
> n_processors = len (c.Win32_Processor ())

Thanks for saving me from a dumb mistake ;-)

> I can't at this moment remember how the c.Win32_Processor interacts
> with physical processors, multicore processors and hyperthreading.
> It's probably documented somewhere, and a little experimentation
> should give you answers quite easily. That's the great thing with
> Python: you just fire up the interpreter and get the answer!

And it does indeed work.  We're using the latest 2.6, and so far
everything has worked well. NumberOfCores and
NumberOfLogicalProcessors does just what I hoped they would do, so now
I have a small bit of n00b code:

print "Getting processor information now...\n"
numProcs = len(c.Win32_Processor ())
print "Number of Processor Packages found: " + str(numProcs)
for p in c.Win32_Processor ():
  print "Number of processor cores: " + str(p.NumberOfCores)
  print "Number of Logical processors: " + str(p.NumberOfLogicalProcessors)
  if p.NumberOfCores != p.NumberOfLogicalProcessors :
      print "HyperThreading seems to be enabled."

and that's enough to start.  For now, I just need to be able to
actually pull accurate information. Later on, I'll write a class for
all this so the other scripts can reference them easily... but this
way, I can check packages, cores and logicals, and whether or not
HyperThreading is enabled; though my logic should be:

if p.NumberOfLogicalProcessors == (p.NumberOfCores * 2)

instead of just a !=.  BUT, either way should work on any multi-core
system I can think of.  Know of any instance where that wouldn't work
accurately?

> This is definitely the place to look for this kind of information:
>
> http://msdn.microsoft.com/en-us/library/aa394373%28VS.85%29.aspx
>
> unfortunately, some of the useful information like NumberOfCores
> and NumberOfLogicalProcessors seems to be available only on the
> very latest releases. Might be an issue for you?

THANKS!  Once again, you're wisdom blows my mind ;-) and your link-fu.
That was one of the things I had hoped to find as I was searching.
That was exactly the kind of information I needed to get things going.
 Just a simple example and a brief explanation of what each item is,
without diving into C or C++ and trying to translate that later.

> Glad it's been useful. I'm just releasing a new version of the
> Python module which includes a little web server whichi lets you
> browse around the classes to a limited extent. If you're interested,
> let me know.

Sure... it'd be neat to play with.  Like I've said before, this is
going to be actually useful, but I'm doing it out of boredom and as a
learning experience more than I am doing it to benefit work or
anything like that.  They don't pay me enough to really want to work
for their benefit ;-)

I have run into another issue though with the various Memory classes...

I thought I was counting DIMMs, but I think I was just counting
sockets.  I thought I was totalling the amount of Physical memory, but
instead I was getting the max supported for each socket...

I've tried CIM_OperatingSystem (which works and gives me the free
physical memory).

I've also tried Win32_*Memory* classes as well as CIM_Memory, and none
of those have successfully given me the actual physical memory.

for each class, NumberOfBlocks either returns nothing, or returns the
wrong information.

I've got 4 256MB DIMMs in my desktop, which is what I'm using to work
on this right now.  Hopefully, they'll find me something with more
DIMMs and higher capacity to play with to make sure this will work on
systems other than my desktop...

But for now, all I'm ending up with is the max capacity for the system
(4GB) not the total installed (1GB)...

I can't seem to find the right Memory related class to get either the
amount present per dimm or the total physical amount present.

I'm still looking into that... and that'll probably be my day.
thankfully, they don't really have much at all for me to officially do
right now, so I've got plenty of time to mess around with this and see
what different things do.

Cheers
Jeff

-- 

Jonathan Swift  - "May you live every day of your life." -
http://www.brainyquote.com/quotes/authors/j/jonathan_swift.html
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to