RE: speeding up Python when using wmi

2005-11-28 Thread Tim Golden
[rbt]
>> Here's a quick and dirty version of winver.exe written in Python:

[Tim Golden]
> In short, I recommend replacing the wmi module by the underlying
> calls which it hides, and replacing Tkinter by a win32gui MessageBox.

[rbt]
>Wow... thanks. I didn't expect someone to completely rewrite it like 
>that. I'll use your example and name it PyWinver and attribute it to 
>you. Hope you don't mind. Great learning experience.
>Thanks!

My pleasure. It wasn't that much of a rewrite; there were
only, what, a dozen lines in the original. One of those
rare occasions when I have to *not* recommend using the 
wmi module!

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: speeding up Python when using wmi

2005-11-28 Thread rbt
Tim Golden wrote:
> [rbt]
> 
>> Here's a quick and dirty version of winver.exe written in Python:
> 
> [.. snip ..]
> 
>> It uses wmi to get OS information from Windows... it works well, but 
>> it's slow... too slow. Is there any way to speed up wmi?
> 
>> In the past, I used the platform and sys modules to do some of what 
>> winver.exe does and they were rather fast. However, since switching to
> 
>> wmi (for a more accurate representation) thinngs have gotten slow... 
>> real slow.
> 
>> I suppose this could be a wmi only issue not related at all to Python.
> 
> In short, I recommend replacing the wmi module by the underlying
> calls which it hides, and replacing Tkinter by a win32gui MessageBox.
> The wmi module does some magicish things which are useful for
> interactive
> browsing, but will only slow you down if you know exactly what you need.
> As you don't need anything more than a native message box, don't
> bother with GUI loops etc. Windows will do that for you in a Modal
> Dialog (here message box).
> 
> This was going to be a longer post comparing versions, but in short
> running this code:
> 
> 
> import win32gui
> import win32com.client
> 
> for os in win32com.client.GetObject ("winmgmts:").InstancesOf
> ("Win32_OperatingSystem"):
>   win32gui.MessageBox (
> 0,
> os.Properties_ ("Caption").Value + "\n" + \
>   os.Properties_ ("TotalVisibleMemorySize").Value + "\n" + \
>   os.Properties_ ("Version").Value + "\n" + \
>   os.Properties_ ("CSDVersion").Value,
> "Platform Info", 
> 0
>   )
> 

Wow... thanks. I didn't expect someone to completely rewrite it like 
that. I'll use your example and name it PyWinver and attribute it to 
you. Hope you don't mind. Great learning experience.

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: speeding up Python when using wmi

2005-11-28 Thread Tim Golden
[rbt]

> Here's a quick and dirty version of winver.exe written in Python:

[.. snip ..]

> It uses wmi to get OS information from Windows... it works well, but 
> it's slow... too slow. Is there any way to speed up wmi?

> In the past, I used the platform and sys modules to do some of what 
> winver.exe does and they were rather fast. However, since switching to

> wmi (for a more accurate representation) thinngs have gotten slow... 
> real slow.

> I suppose this could be a wmi only issue not related at all to Python.

In short, I recommend replacing the wmi module by the underlying
calls which it hides, and replacing Tkinter by a win32gui MessageBox.
The wmi module does some magicish things which are useful for
interactive
browsing, but will only slow you down if you know exactly what you need.
As you don't need anything more than a native message box, don't
bother with GUI loops etc. Windows will do that for you in a Modal
Dialog (here message box).

This was going to be a longer post comparing versions, but in short
running this code:


import win32gui
import win32com.client

for os in win32com.client.GetObject ("winmgmts:").InstancesOf
("Win32_OperatingSystem"):
  win32gui.MessageBox (
0,
os.Properties_ ("Caption").Value + "\n" + \
  os.Properties_ ("TotalVisibleMemorySize").Value + "\n" + \
  os.Properties_ ("Version").Value + "\n" + \
  os.Properties_ ("CSDVersion").Value,
"Platform Info", 
0
  )


is nearly as fast as running its VBS equivalent:


For Each os in GetObject("winmgmts:").InstancesOf
("Win32_OperatingSystem")
  
  WScript.Echo os.Caption & VbCr & _
os.TotalVisibleMemorySize & VbCr & _
os.Version & VbCr & _
os.CSDVersion & VbCr

Next


So, if you want to use Python, you could use the script above,
but if you don't care, use VBScript, which probably has a favoured
place in the Windows World (tm).

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

-- 
http://mail.python.org/mailman/listinfo/python-list


speeding up Python when using wmi

2005-11-28 Thread rbt
Here's a quick and dirty version of winver.exe written in Python:

http://filebox.vt.edu/users/rtilley/public/winver/winver.html

It uses wmi to get OS information from Windows... it works well, but 
it's slow... too slow. Is there any way to speed up wmi?

In the past, I used the platform and sys modules to do some of what 
winver.exe does and they were rather fast. However, since switching to 
wmi (for a more accurate representation) thinngs have gotten slow... 
real slow.

I suppose this could be a wmi only issue not related at all to Python.

Any tips or ideas?

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list