Module for generic platform information: platform.py

Karl Putland kputland at wisen.com
Wed Oct 27 17:14:50 EDT 1999


Try this on for size

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
IDLE 0.5 -- press F1 for help
>>> from win32api import RegOpenKeyEx, RegQueryValueEx
>>> from win32con import HKEY_LOCAL_MACHINE
>>> from win32api import RegEnumValue
>>> key = RegOpenKeyEx(HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Windows
NT\CurrentVersion')
>>> i=0
>>> while 1:
	try:
		str,obj,type = RegEnumValue(key,i)
		print str,obj,type
		i=i+1
	except:
		break


SoftwareType SYSTEM 1
InstallDate 934559805 4
RegisteredOwner Administrator 1
RegisteredOrganization wisen.com, Inc. 1
CurrentBuild 1.511.1 () (Obsolete data - do not use) 1
CurrentVersion 4.0 1
CurrentBuildNumber 1381 1
CurrentType Uniprocessor Free 1
SystemRoot C:\WINNT 1
SourcePath C:\I386\ 1
PathName C:\WINNT 1
ProductId 13299OEM004225197031 1
CSDVersion Service Pack 4 1
Plus! VersionNumber IE 5 5.00.2314.1003 1
>>>


Karl Putland
kputland at wisen.com


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of M.-A. Lemburg
> Sent: Wednesday, October 27, 1999 10:31 AM
> To: Thomas Heller
> Cc: python-list
> Subject: Re: Module for generic platform information: platform.py
>
>
> Thomas Heller wrote:
> >
> > > Thomas Heller wrote:
> > > >
> > > > I searched the MSDN again,
> > > > it seems that winmsd.exe is included in NT 3.5, 3.51, 4.0
> > > > and installed by default.
> > >
> > > Sound even better ;-) (It doesn't seem to exist on Win95, so I'll
> > > only use it for WinNT.)
> > >
> > > What command string would I have to pass to os.popen to get the output
> > > (I only need the first few lines) without any windows popping up ?
> > >
> > That's were the problem (mentioned earlier) start. This is windows here,
> > so do not expect for programs to write to stdout!
> >
> > As I said before, winmsd writes its output to the file <hostname>.txt.
> > AFAIK, you cannot pipe the output somewhere else, nor can you change the
> > name of this file.
> >
> > The following script demonstrates how to do it:
> >
> >   import string, os, sys
> >   hostname = string.strip (os.popen ("hostname && winmsd /s /f").read())
> >   file = open (hostname + '.txt')
> >   for i in range (12):
> >     sys.stdout.write (file.readline())
> >
> > The output on my system are:
> >
> >   Microsoft Diagnostics Report For \\THOMASNOTEBOOK
> >   ----------------------------------------------------------------------
> >
> >   OS Version Report
> >   ----------------------------------------------------------------------
> >   Microsoft (R) Windows NT (TM) Workstation
> >   Version 4.0 (Build 1381: Service Pack 4) x86 Uniprocessor Free
> >   Registered Owner: Thomas Heller, ION-TOF GmbH
> >
> > BUT: Be prepared to receive this in other languages!
> > AND: winmsd displays a progress dialog window like this
> >
> > +--------------------------+
> > | Generating WinMSD report |
> > |    +-------+             |
> > |    | Cancel|             |
> > +----+-------+-------------+
> >
> > which closes automatically after the second or so, when the report
> > is complete. I did not find a way to suppress this window.
> > Hope this helps,
>
> Well it does, but I don't think weird windows popping up when
> calling a Python function is not really tolerable. Having the
> program write to a fixed filename is even less -- you'd write
> that file (which contains private data I suppose) into the
> current dir which could be just about anywhere...
>
> Perhaps some of the win32 wizards out there could help out
> with a function that gets this data from the registry (either
> direct via MarkHs win32 package or indirect via "regedit") ?
>
> Anyway, thanks for looking into this, Thomas.
>
> --
> Marc-Andre Lemburg
> ______________________________________________________________________
> Y2000:                                                    65 days left
> Business:                                      http://www.lemburg.com/
> Python Pages:                           http://www.lemburg.com/python/
>
>
> --
> http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list