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

disk_usage.py enhancement #411

Closed
giampaolo opened this issue May 23, 2014 · 3 comments
Closed

disk_usage.py enhancement #411

giampaolo opened this issue May 23, 2014 · 3 comments

Comments

@giampaolo
Copy link
Owner

From gisle.vanem@gmail.com on July 23, 2013 12:43:18

The ./examples/disk_usage.py will pop-up a Windows GUI error for a non-ready 
partition. I think it's better to check if 'part.fstype' is filled with a 
string before progressing and calling 'psutil.disk_usage(part.mountpoint)'.

Like this:
def main():
    templ = "%-17s %8s %8s %8s %5s%% %9s  %s"
    print_(templ % ("Device", "Total", "Used", "Free", "Use ", "Type", "Mount"))
    for part in psutil.disk_partitions(all=False):
        if os.name == 'nt' and part.fstype == '':
             # A non-ready-disk has no fstype. E.g. if no CDROM in the drive
             print ('%s\t\t Not ready' % part.device)
             continue
        usage = psutil.disk_usage(part.mountpoint)
        print_(templ % (part.device,
                        bytes2human(usage.total),
                        bytes2human(usage.used),
                        bytes2human(usage.free),
                        int(usage.percent),
                        part.fstype,
                        part.mountpoint))

Original issue: http://code.google.com/p/psutil/issues/detail?id=411

@giampaolo
Copy link
Owner Author

From g.rodola on July 26, 2013 08:36:16

Fixed in revision f1e76d45aa3e . Thanks for signaling (FWIW I added you to CREDITS).

Status: FixedInHG
Labels: OpSys-Windows Component-Scripts Milestone-1.1.0

@giampaolo
Copy link
Owner Author

From g.rodola on September 28, 2013 03:06:18

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on September 28, 2013 10:32:46

Closing out as fixed. Release 1.1.0 is now available for download.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant