473,320 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Getting Windows computer system info

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.
Jul 18 '05 #1
3 4111
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
Jul 18 '05 #2
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
Jul 18 '05 #3
On 9 Nov 2004 09:47:31 -0800, ga*******@voila.fr (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
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mike Turco | last post by:
(This was also posted to comp.database.ms-access before I realized this was the hep group.) Lets say that my WinXP computer has two users: Michael and Kathryn. One or the other logs into the...
5
by: z. f. | last post by:
i need to get the computer name from an aspx page. i use System.Windows.Forms.SystemInformation.ComputerName() and it's working fine, but in second thought, it might not be recomended to use the...
11
by: geoffbache | last post by:
Hi, As part of my efforts to write a test tool that copes with GUIs nicely, I'm trying to establish how I can start a GUI process on Windows that will not bring up the window. So I try to hide...
1
by: eblackmo | last post by:
I have a test network consisting of four servers running windows 2003 server R2 SP2. I have set up a domain which functioned correctly for about a day and a half until the other servers decided they...
41
by: LayneMitch via WebmasterKB.com | last post by:
I was just chating with a few webdevelopers and it was brought to my attention that I need some type of server technology installed on my computer so I could get a visual of how my sites would look...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.