On 9/22/06, wesley chun <[EMAIL PROTECTED]> wrote: > this sounds like it will require some work to implement 'df' in > Python
Mmm... although I have discovered a debian package called pydf whose source made interesting reading. > i'd use the one of > the {os,popen2}.popen*() functions or the subprocess module and > actually call 'df' but use Python to communicate with it (sending it > stuff via stdin and receiving output from it [stdout or stderr]). That sounds fascinating... and something to play with. In the end I just did: def fsUsage(dir): """Returns the % usage of a given filesystem""" stat = os.statvfs(dir) from statvfs import F_BLOCKS, F_BFREE total = stat[F_BLOCKS] avail = stat[F_BFREE] used = total-avail percent = used/total*100 return percent S. > > hope this helps a little! > -- wesley > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > "Core Python Programming", Prentice Hall, (c)2007,2001 > http://corepython.com > > wesley.j.chun :: wescpy-at-gmail.com > python training and technical consulting > cyberweb.consulting : silicon valley, ca > http://cyberwebconsulting.com > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor