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:
>
> <python>
> 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
> )
> </python>
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