Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Getting Windows computer system info

Reply
Thread Tools

Getting Windows computer system info

 
 
Bolin
Guest
Posts: n/a
 
      11-09-2004
I was wondering how to get some system info from a PC running Windows
in python. I am especially interested in knowing how much RAM the
computer has, how much diskspace is still left, and what jobs are
already running and how much memory they take. If this is off-topic, I
would appreciate if you redirect me.

Thank!

B.
 
Reply With Quote
 
 
 
 
Brad Tilley
Guest
Posts: n/a
 
      11-09-2004
Bolin wrote:
> I was wondering how to get some system info from a PC running Windows
> in python. I am especially interested in knowing how much RAM the
> computer has, how much diskspace is still left, and what jobs are
> already running and how much memory they take. If this is off-topic, I
> would appreciate if you redirect me.
>
> Thank!
>
> B.


You may find this of interest. It's a Python implementation of winver
that I wrote:

http://filebox.vt.edu/users/rtilley/...er/winver.html
 
Reply With Quote
 
 
 
 
Waldemar Osuch
Guest
Posts: n/a
 
      11-10-2004
Bolin wrote:
> I was wondering how to get some system info from a PC running Windows
> in python.


For ease of use nothing beats Tim Golden's wmi package:
http://tgolden.sc.sabren.com/python/wmi.html

But one can do the same stuff using Mark Hammond's pywin32
http://sourceforge.net/projects/pywin32/

Check out <python install>Lib\site-packages\win32\demos folder for examples
 
Reply With Quote
 
Bengt Richter
Guest
Posts: n/a
 
      11-10-2004
On 9 Nov 2004 09:47:31 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) (Bolin) wrote:

>I was wondering how to get some system info from a PC running Windows
>in python. I am especially interested in knowing how much RAM the
>computer has, how much diskspace is still left, and what jobs are
>already running and how much memory they take. If this is off-topic, I
>would appreciate if you redirect me.
>
>Thank!

I use this to get a quick summary of disk free space from the console
command line:

----< df.py >----------------------
import os
def df(drives='C', showna=1):
for drive in drives:
drive = drive.upper()
d = os.popen('dir/w '+drive+':\\').readlines()
if not d:
if showna: print '%s: (n/a)' % drive
continue
print '%s: (%-12s %12s bytes free ' %(
drive,
d[0].strip().split(' is ', 1)[-1]+')',
d[-1].strip().split(' bytes ')[0]
)

if __name__ == '__main__':
import sys
if len(sys.argv)<2: df()
else: df(sys.argv[1])
----------------------------------

actually, i start it with df.cmd, which has:

@python c:\util\df.py CDEVW

since those are my useful drive letters.

As for dynamic stuff, if it's just for you, see if you have pstat.exe on your path
(likely if you have MS dev tools). If so, try it from the command line
to see what it gives you. Then you can write a quick python function
to run it via popen and extract what you want from the read result, e.g.,

>>> import os
>>> for line in os.popen('pstat.exe'):

... if 'mem' in line.lower(): print line.rstrip()
...
Pstat version 0.3: memory: 327080 kb uptime: 0 21:40:12.957
Memory: 327080K Avail: 274140K TotalWs: 40132K InRam Kernel: 3264K P:12572K
c 18 22 8011f9ba 0:00:00.000 0:00:00.160 Wait:VirtualMemory
2a 17 1 801223a4 0:00:00.000 0:00:00.000 Wait:VirtualMemory

Or eliminate the first-guess garbage

>>> import os
>>> for line in os.popen('pstat.exe'):

... if 'emory:' in line: print line.strip()
...
Pstat version 0.3: memory: 327080 kb uptime: 0 21:43:48.997
Memory: 327080K Avail: 274668K TotalWs: 39520K InRam Kernel: 3260K P:12484K

HTH

Regards,
Bengt Richter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
INFO GALORE WITH NEW COMPUTER SYSTEM Cuckoo_Bird Computer Information 0 09-18-2009 01:32 PM
Getting system info using perl saurabh hirani Perl Misc 6 02-06-2009 06:12 AM
Boot-Up not getting to system info page ? help please ? Fred-C- Computer Support 1 05-18-2005 07:19 AM
How to get the Operating System info like ( Wireless info, Wireless connection) Vasanth Perl 0 06-28-2004 08:56 AM
Getting unique info about user or computer? Rhino Java 8 06-18-2004 08:15 PM



Advertisments