Closed giampaolo closed 13 years ago
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
New patch includes:
Why do you return a percentage? People can compute that themselves if they want to.
Agreed. I think we should pass on the raw data - how the user wants to format and present that is up to them.
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)
New changeset 2fc102ebaf73 by Giampaolo Rodola' in branch 'default': Issue bpo-12442: add shutil.disk_usage() http://hg.python.org/cpython/rev/2fc102ebaf73
Looks like my message on Rietveld was not received or not read:
http://bugs.python.org/review/12442/diff/2951/7664#newcode776
I removed the percent usage from the returned namedtuple hence that comment is no longer necessary.
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.
New changeset 479973c6aa03 by Éric Araujo in branch 'default': Clean up NEWS entry and tests for shutil.disk_usage (bpo-12442) http://hg.python.org/cpython/rev/479973c6aa03
Thanks for the further fixes.
New changeset bdb3f0e7e268 by Victor Stinner in branch 'default': Issue bpo-12442: nt._getdiskusage() is now using the Windows Unicode API http://hg.python.org/cpython/rev/bdb3f0e7e268
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = 'https://github.com/giampaolo' closed_at =
created_at =
labels = ['type-feature', 'library']
title = 'shutil.disk_usage()'
updated_at =
user = 'https://github.com/giampaolo'
```
bugs.python.org fields:
```python
activity =
actor = 'python-dev'
assignee = 'giampaolo.rodola'
closed = True
closed_date =
closer = 'giampaolo.rodola'
components = ['Library (Lib)']
creation =
creator = 'giampaolo.rodola'
dependencies = []
files = ['22517', '22519', '22532']
hgrepos = []
issue_num = 12442
keywords = ['patch', 'needs review']
message_count = 13.0
messages = ['139439', '139440', '139468', '139475', '139476', '139553', '139569', '139645', '139651', '139655', '139659', '139660', '147374']
nosy_count = 7.0
nosy_names = ['rhettinger', 'pitrou', 'giampaolo.rodola', 'ezio.melotti', 'eric.araujo', 'brian.curtin', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue12442'
versions = ['Python 3.3']
```