Extracting info from OS/hardware

Josiah Carlson jcarlson at nospam.uci.edu
Mon Mar 15 09:58:19 CET 2004


> In Linux, you can get a lot of information on hardware and status by examining 
> files in the /proc directory. For example, from doing cat /proc/cpuinfo on my 
> system:
[snip proc info]

In Windows 2k (and perhaps XP, 2003, ...) you can some of the same 
information with "set" (portions removed for brevity)
C:\> set
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 6 Stepping 5, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0605

> For disk space and free space, you check /proc/diskstats, etc.
> No idea about how to do it on Windows, but programs like "Treesize" tell me it 
> mustn't be that hard.

Off the top of my head, I can't think of a method for finding out other 
than parsing the results of a "quick":
[parse(os.popen("dir %s:\\"%chr(letter)).read()) \
  for letter in xrange(ord('a'), ord('z')+1)]

There is likely a better and faster way for both by using pywin32 
(current name for win32 extensions).

  - Josiah



More information about the Python-list mailing list