T
Thomas Schulz
Any ideas how to check for free disc space from Python. Platform
independent?
Thanks for any suggestion.
Thomas
independent?
Thanks for any suggestion.
Thomas
Thomas Schulz said:Any ideas how to check for free disc space from Python. Platform
independent?
T. Schulz said:I wonder if it would be worthwhile to have such a functionality
somewhere in the os module?
Fredrik Lundh said:- the os module is traditionally used to provide access to posix-style
services provided by the OS (or the C library). in this case, os.statvfs
is such a function; calling out to "du" isn't
(shouldn't that be "df", btw? os.popen("du -k dir").split()[-5] sure
doesn't give the free diskspace on any platform I have access to...)
(a third argument is that "free disc space" is a rather meaningless metric
on a modern operating system; it's hardly ever useful for anything except
"warning, warning, less than 5% free space" alerts.
you really don't want
people to write "if os.getfreespace() >= len(buffer): f.write(buffer)" and
file a bug when write fails ;-)
Fredrik said:(a third argument is that "free disc space" is a rather meaningless metric
on a modern operating system; it's hardly ever useful for anything except
"warning, warning, less than 5% free space" alerts. you really don't want
people to write "if os.getfreespace() >= len(buffer): f.write(buffer)" and
file a bug when write fails ;-)
But "if estimated_space > int(free_space * 1.05): ..." might not be
such a bad thing when there is no other route to sanity available.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.