[Tutor] Library for Disk Usage (UNIX)

Chris Fuller cfuller084 at thinkingplanet.net
Wed Mar 26 17:11:48 CET 2008


On Wednesday 26 March 2008 09:11, Tom Tucker wrote:
> Hello all. I'm looking for a builtin Python library capable of providing
> similar output to what the unix df command provides.  Obviously, I'm trying
> to avoid a system call if possible.  I'm looking for the following fields
> at a mimimum, total size, used, and /path. Suggestions?  I was looking at
> os.stat(/path)[WXYZ}, and os.path.getsize, but they are lacking.
>
> Thanks for the help,
>
> Tom

You need to know the size of the blocks that the filesystem uses.  Use the 
statvfs module and the os.statvfs function.

Cheers




More information about the Tutor mailing list