peter-hst / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

disk_usage.py enhancement #411

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by gisle.vanem@gmail.com on 23 Jul 2013 at 10:43

GoogleCodeExporter commented 9 years ago
Fixed in revision f1e76d45aa3e. Thanks for signaling (FWIW I added you to 
CREDITS).

Original comment by g.rodola on 26 Jul 2013 at 3:36

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 28 Sep 2013 at 10:06

GoogleCodeExporter commented 9 years ago
Closing out as fixed. Release 1.1.0 is now available for download.

Original comment by g.rodola on 28 Sep 2013 at 5:32