Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shutil.disk_usage() #56651

Closed
giampaolo opened this issue Jun 29, 2011 · 13 comments
Closed

shutil.disk_usage() #56651

giampaolo opened this issue Jun 29, 2011 · 13 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@giampaolo
Copy link
Contributor

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:

    assignee = 'https://github.com/giampaolo'
    closed_at = <Date 2011-07-01.11:59:42.865>
    created_at = <Date 2011-06-29.16:55:38.667>
    labels = ['type-feature', 'library']
    title = 'shutil.disk_usage()'
    updated_at = <Date 2011-11-09.21:12:40.565>
    user = 'https://github.com/giampaolo'

    bugs.python.org fields:

    activity = <Date 2011-11-09.21:12:40.565>
    actor = 'python-dev'
    assignee = 'giampaolo.rodola'
    closed = True
    closed_date = <Date 2011-07-01.11:59:42.865>
    closer = 'giampaolo.rodola'
    components = ['Library (Lib)']
    creation = <Date 2011-06-29.16:55:38.667>
    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
    Copy link
    Contributor Author

    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 giampaolo self-assigned this Jun 29, 2011
    @giampaolo giampaolo added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 29, 2011
    @giampaolo
    Copy link
    Contributor Author

    @giampaolo
    Copy link
    Contributor Author

    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

    @pitrou
    Copy link
    Member

    pitrou commented Jun 30, 2011

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

    @briancurtin
    Copy link
    Member

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

    @giampaolo
    Copy link
    Contributor Author

    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)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 1, 2011

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

    @merwok
    Copy link
    Member

    merwok commented Jul 2, 2011

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

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

    @giampaolo
    Copy link
    Contributor Author

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

    @merwok
    Copy link
    Member

    merwok commented Jul 2, 2011

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 2, 2011

    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
    Copy link
    Contributor Author

    Thanks for the further fixes.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 9, 2011

    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants