diff options
| author | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-07-26 16:33:57 +0100 |
|---|---|---|
| committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-07-26 16:33:57 +0100 |
| commit | 2bd043dfd2f4c096cee56fdfb4633dc6b7b2ab30 (patch) | |
| tree | d376735220233431c685acc28e0e65c651645168 /examples/disk_usage.py | |
| parent | 8542903b3cc27bcba3e9663c3ee18d3ecf15c5be (diff) | |
| download | psutil-2bd043dfd2f4c096cee56fdfb4633dc6b7b2ab30.tar.gz | |
Fix issue #411: [Windows] examples/disk_usage.py may pop-up a GUI error.
Diffstat (limited to 'examples/disk_usage.py')
| -rwxr-xr-x | examples/disk_usage.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/disk_usage.py b/examples/disk_usage.py index b0ea7b0a..305f3e58 100755 --- a/examples/disk_usage.py +++ b/examples/disk_usage.py @@ -34,9 +34,12 @@ 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 'cdrom' in part.opts: - # may raise ENOENT if there's no cd-rom in the drive - continue + if os.name == 'nt': + if 'cdrom' in part.opts or part.fstype == '': + # skip cd-rom drives with no disk in it; they may raise + # ENOENT, pop-up a Windows GUI error for a non-ready + # partition or just hang. + continue usage = psutil.disk_usage(part.mountpoint) print_(templ % (part.device, bytes2human(usage.total), |
