classification
Title: shutil.disk_usage()
Type: enhancement Stage: committed/rejected
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: giampaolo.rodola Nosy List: brian.curtin, eric.araujo, ezio.melotti, giampaolo.rodola, pitrou, python-dev, rhettinger
Priority: normal Keywords: needs review, patch

Created on 2011-06-29 16:55 by giampaolo.rodola, last changed 2011-11-09 21:12 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
diskusage.patch giampaolo.rodola, 2011-06-29 16:55 review
diskusage2.patch giampaolo.rodola, 2011-06-30 09:31 review
diskusage3.patch giampaolo.rodola, 2011-07-01 08:24 review
Messages (13)
msg139439 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-06-29 16:55
Patch in attachment adds a new disk_usage() function to shutil module which retrieves total, used and free disk space given a certain path plus the percentage usage.

See original discussion on python-ideas ml:
http://mail.python.org/pipermail/python-ideas/2011-June/010480.htm
msg139440 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-06-29 17:02
Typo. It's:
http://mail.python.org/pipermail/python-ideas/2011-June/010480.html
msg139468 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-06-30 09:31
New patch includes:

- Py_BEGIN/END_ALLOW_THREADS around GetDiskFreeSpaceEx() call
- use of assertGreaterEqual / assertLessEqual when testing the percentage usage
- use of hasattr(shutil, 'disk_usage') for skipping the test
- extended url reference in the comments
msg139475 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-06-30 13:10
Why do you return a percentage? People can compute that themselves if they want to.
msg139476 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2011-06-30 13:15
Agreed. I think we should pass on the raw data - how the user wants to format and present that is up to them.
msg139553 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-07-01 08:24
Agreed. 
New patch removes the percentage and fixes computations on posix as recommended by Charles-François:

free = st.f_bavail * st.f_bsize
total = st.f_blocks * st.f_frsize
used = (total - st.f_bfree * st.f_bsize)
msg139569 - (view) Author: Roundup Robot (python-dev) Date: 2011-07-01 11:55
New changeset 2fc102ebaf73 by Giampaolo Rodola' in branch 'default':
Issue #12442: add shutil.disk_usage()
http://hg.python.org/cpython/rev/2fc102ebaf73
msg139645 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-07-02 13:21
Looks like my message on Rietveld was not received or not read:

http://bugs.python.org/review/12442/diff/2951/7664#newcode776
msg139651 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-07-02 13:57
I removed the percent usage from the returned namedtuple hence that comment is no longer necessary.
msg139655 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-07-02 14:30
Ah, excellent!  Thanks for the new function.  About using assertGreater and friends in tests, as Ezio and I suggested, I have done the change in my working copy and will commit it later.
msg139659 - (view) Author: Roundup Robot (python-dev) Date: 2011-07-02 14:47
New changeset 479973c6aa03 by Éric Araujo in branch 'default':
Clean up NEWS entry and tests for shutil.disk_usage (#12442)
http://hg.python.org/cpython/rev/479973c6aa03
msg139660 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2011-07-02 14:53
Thanks for the further fixes.
msg147374 - (view) Author: Roundup Robot (python-dev) Date: 2011-11-09 21:12
New changeset bdb3f0e7e268 by Victor Stinner in branch 'default':
Issue #12442: nt._getdiskusage() is now using the Windows Unicode API
http://hg.python.org/cpython/rev/bdb3f0e7e268
History
Date User Action Args
2011-11-09 21:12:40python-devsetmessages: + msg147374
2011-07-03 00:38:10r.david.murraysetstage: commit review -> committed/rejected
2011-07-02 14:53:53giampaolo.rodolasetmessages: + msg139660
2011-07-02 14:47:40python-devsetmessages: + msg139659
2011-07-02 14:30:42eric.araujosetmessages: + msg139655
2011-07-02 13:57:43giampaolo.rodolasetmessages: + msg139651
2011-07-02 13:21:33eric.araujosetnosy: + eric.araujo
messages: + msg139645
2011-07-01 11:59:42giampaolo.rodolasetstatus: open -> closed
resolution: fixed
stage: patch review -> commit review
2011-07-01 11:55:42python-devsetnosy: + python-dev
messages: + msg139569
2011-07-01 08:24:28giampaolo.rodolasetfiles: + diskusage3.patch

messages: + msg139553
2011-06-30 13:15:13brian.curtinsetmessages: + msg139476
2011-06-30 13:10:57pitrousetmessages: + msg139475
2011-06-30 09:31:48giampaolo.rodolasetfiles: + diskusage2.patch

messages: + msg139468
2011-06-29 17:58:54ezio.melottisetnosy: + ezio.melotti
2011-06-29 17:02:52giampaolo.rodolasetmessages: + msg139440
2011-06-29 17:02:00brian.curtinsetnosy: + brian.curtin
2011-06-29 16:55:38giampaolo.rodolacreate