mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #22492 from davidjb/2014.7
Correctly report disk usage on Windows. Fix #16508
This commit is contained in:
commit
6662853542
@ -49,24 +49,19 @@ def usage():
|
||||
drive_bitmask >>= 1
|
||||
for drive in drives:
|
||||
try:
|
||||
(sectorspercluster,
|
||||
bytespersector,
|
||||
freeclusters,
|
||||
totalclusters) = win32api.GetDiskFreeSpace(
|
||||
(available_bytes,
|
||||
total_bytes,
|
||||
total_free_bytes) = win32api.GetDiskFreeSpaceEx(
|
||||
'{0}:\\'.format(drive)
|
||||
)
|
||||
totalsize = sectorspercluster * bytespersector * totalclusters
|
||||
available_space = (
|
||||
sectorspercluster * bytespersector * freeclusters
|
||||
)
|
||||
used = totalsize - available_space
|
||||
capacity = int(used / float(totalsize) * 100)
|
||||
used = total_bytes - total_free_bytes
|
||||
capacity = used / float(total_bytes) * 100
|
||||
ret['{0}:\\'.format(drive)] = {
|
||||
'filesystem': '{0}:\\'.format(drive),
|
||||
'1K-blocks': totalsize,
|
||||
'used': used,
|
||||
'available': available_space,
|
||||
'capacity': '{0}%'.format(capacity),
|
||||
'1K-blocks': total_bytes / 1024,
|
||||
'used': used / 1024,
|
||||
'available': total_free_bytes / 1024,
|
||||
'capacity': '{0:.0f}%'.format(capacity),
|
||||
}
|
||||
except Exception:
|
||||
ret['{0}:\\'.format(drive)] = {
|
||||
|
Loading…
Reference in New Issue
Block a user