How to check amt of SPACE FREE on HDD

Freddie freddie at madcowdisease.org
Fri Dec 20 21:14:17 EST 2002


RichardJ wrote:
> New to python, but have all the O'Reilly Python books and was not able to
> find the call you would use to check the amount of space is available on a
> hard-drive.
> 
> The application will be downloading huge amount of data using ftp, so needs
> to check how much space is available. At the moment running on WinXP Pro,
> but likely to run on Linux.
> 
> Very much appreciate any help.
> Thanks,
> Richard
> 
> 

There's an os.statvfs() method, but it doesn't seem to be particularly 
portable. I've tried it on several systems just now, and the only one it 
actually exists on is my Linux machine (2.4.x kernel, Debian 3.0). 
Windows and various versions of FreeBSD (4.4 through 4.8) don't have it :\

I do need to solve this problem also, so I'll probably have to write a 
class to wrap the multiple methods (statvfs(), parse 'df' output, the 
win32 way). Blerk.

Freddie




More information about the Python-list mailing list