How can I get disk space usage?
Youngbong Choe
hurd at sds.co.kr
Thu Dec 9 04:41:45 EST 1999
Thank you very much!!
It works fine! :)
Thu, 09 Dec 1999, Fredrik Lundh wrote:
> Youngbong Choe <hurd at sds.co.kr> wrote:
> > Is there a module or function for getting amount of disk free space?
> > If not, how can i get disk usage infomations in python, like "df" command.
>
> os.statvfs (where available).
>
> # statvfs-example-1.py
>
> import statvfs
> import os
>
> st = os.statvfs(".")
>
> print "preferred block size", "=>", st[statvfs.F_BSIZE]
> print "fundamental block size", "=>", st[statvfs.F_FRSIZE]
> print "total blocks", "=>", st[statvfs.F_BLOCKS]
> print "total free blocks", "=>", st[statvfs.F_BFREE]
> print "available blocks", "=>", st[statvfs.F_BAVAIL]
> print "total file nodes", "=>", st[statvfs.F_FILES]
> print "total free nodes", "=>", st[statvfs.F_FFREE]
> print "available nodes", "=>", st[statvfs.F_FAVAIL]
> print "max file name length", "=>", st[statvfs.F_NAMEMAX]
>
> ## sample output:
> ##
> ## preferred block size => 8192
> ## fundamental block size => 1024
> ## total blocks => 749443
> ## total free blocks => 110442
> ## available blocks => 35497
> ## total file nodes => 92158
> ## total free nodes => 68164
> ## available nodes => 68164
> ## max file name length => 255
>
> </F>
>
> <!-- (the eff-bot guide to) the standard python library:
> http://www.pythonware.com/people/fredrik/librarybook.htm
> -->
>
>
> --
> http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list