[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: linux disc space

exarkun

2/15/2008 7:40:00 PM

On Fri, 15 Feb 2008 11:32:09 -0800, Jeff Schwab <jeff@schwabcenter.com> wrote:
>Chris wrote:
>> On Feb 15, 7:10 pm, DataSmash <r...@new.rr.com> wrote:
>>> I simply want to capture the free disc space in a variable so that I
>>> can compare changes. I'm aware of a few commands like "df -h" or "du -
>>> k", but I can't figure out how to capture those values as a variable.
>>> I also looked at os.statvfs(), but that output doesn't seem to make
>>> any sense at all to me, knowing the size of the disc.
>>> Thanks for your help!
>>> R.D.
>>
>> import os, statvfs
>> s = os.statvfs(".")
>> freebytes = s[statvfs.F_BSIZE] * s[statvfs.F_BAVAIL]
>
>Is it worth distinguishing free bytes from available bytes? I've never
>seen them differ, and I'm not sure how they ever would...
>
> [snip]
>
/: 27723000K free, 15817232K available

It's common for some space to be reserved and only usable by the superuser.

Jean-Paul