PDA

View Full Version : been playing with the win32 extensions...


inkedmn
08-05-2002, 01:22 PM
since Strike, Vince, and i have decided to take another whack at PyNetMonTool, it became apparent that getting basic system info with python couldn't be done without these extensions.

so, i wrote a little program to get the free space on a windows volume.

here you go...


# Get free disk space

import win32file, sys

def freeSpace(drive):
space = win32file.GetDiskFreeSpaceEx(drive)
free = float(space[2]) / 1000000000
free = str(free)
return free[:5]

if __name__ == '__main__':
drive = sys.argv[1]
y = freeSpace(drive)
print y, "gigabytes free"


the win32 exetensions have a PANTLOAD of stuff...

[edit]

btw, here's the output:


C:\python\pynetmontool>python getfree.py c:
3.822 gigabytes free

jemfinch
08-05-2002, 06:26 PM
Where's the documentation for these win32 extensions? I can think of several fun little callbacks that could be added to the bot when it's run in Windows :)

Jeremy

inkedmn
08-05-2002, 07:02 PM
http://aspn.activestate.com/ASPN/Python/Reference/Products/ActivePython/PythonWin32Extensions/PythonWin32Extensions.html

gufmn
08-05-2002, 08:23 PM
That's going to be very helpful on the project.

Oh, and it appears as though things have slowed down for you at work ink. Way to go! ;)