python / cpython

The Python programming language
https://www.python.org
Other
63.16k stars 30.24k forks source link

shutil.disk_usage() #56651

Closed giampaolo closed 13 years ago

giampaolo commented 13 years ago
BPO 12442
Nosy @rhettinger, @pitrou, @giampaolo, @ezio-melotti, @merwok, @briancurtin
Files
  • diskusage.patch
  • diskusage2.patch
  • diskusage3.patch
  • 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'] ```

    giampaolo commented 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

    giampaolo commented 13 years ago

    Typo. It's: http://mail.python.org/pipermail/python-ideas/2011-June/010480.html

    giampaolo commented 13 years ago

    New patch includes:

    pitrou commented 13 years ago

    Why do you return a percentage? People can compute that themselves if they want to.

    briancurtin commented 13 years ago

    Agreed. I think we should pass on the raw data - how the user wants to format and present that is up to them.

    giampaolo commented 13 years ago

    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)
    1762cc99-3127-4a62-9baf-30c3d0f51ef7 commented 13 years ago

    New changeset 2fc102ebaf73 by Giampaolo Rodola' in branch 'default': Issue bpo-12442: add shutil.disk_usage() http://hg.python.org/cpython/rev/2fc102ebaf73

    merwok commented 13 years ago

    Looks like my message on Rietveld was not received or not read:

    http://bugs.python.org/review/12442/diff/2951/7664#newcode776

    giampaolo commented 13 years ago

    I removed the percent usage from the returned namedtuple hence that comment is no longer necessary.

    merwok commented 13 years ago

    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.

    1762cc99-3127-4a62-9baf-30c3d0f51ef7 commented 13 years ago

    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

    giampaolo commented 13 years ago

    Thanks for the further fixes.

    1762cc99-3127-4a62-9baf-30c3d0f51ef7 commented 12 years ago

    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