From b5e6e2cfd78e48f63a9295eedb671b8213f303d7 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 21 May 2012 10:57:40 +0200 Subject: [PATCH] some changes in monitor/disk_display.py --- monitor/disk_display.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/monitor/disk_display.py b/monitor/disk_display.py index cf166e4..868b37b 100755 --- a/monitor/disk_display.py +++ b/monitor/disk_display.py @@ -5,36 +5,37 @@ import disk def bytes2human(bytes): - units = ["B", "KB", "MB", "GB", "TB", "PB", "EB"] + units = ["", "K", "M", "G", "T", "P", "E"] counter = 0 while bytes > 1024: bytes = bytes / 1024 counter += 1 - human = [bytes, units[counter]] - return human + return "%.1f%s" %(bytes, units[counter]) def blocks2bytes(blocks, blocksize): - bytes = float(blocks) * float(blocksize) / 1024 + bytes = float(blocks) * float(blocksize) return bytes if __name__ == "__main__": diskmoninstance = disk.diskmon() + notmounted = "Not mounted partitions:" for partition in diskmoninstance.partitions: - print "Device:\t\t" + str(partition["device"]) - print "UUID:\t\t" + str(partition["uuid"]) if partition.has_key("mountpoint"): totalbytes = blocks2bytes(partition["total blocks"], partition["blocksize"]) - totalhuman = bytes2human(totalbytes) + #totalhuman = bytes2human(totalbytes) freebytes = blocks2bytes(partition["free blocks"], partition["blocksize"]) - freehuman = bytes2human(freebytes) - print "Mountpoint:\t" + str(partition["mountpoint"]) + \ - "\nFilesystem:\t" + str(partition["filesystem"]) + \ - "\nUsage:\t\t%.2f%s/%.2f%s\n" %(freehuman[0], freehuman[1], totalhuman[0], totalhuman[1]) + #freehuman = bytes2human(freebytes) + print "Device:\t\t%s" %(partition["device"]) + \ + "\nUUID:\t\t%s" %(partition["uuid"]) + \ + "\nMountpoint:\t%s" %(partition["mountpoint"]) + \ + "\nFilesystem:\t%s" %(partition["filesystem"]) + \ + "\nUsage:\t\t%s/%s" %(bytes2human(freebytes), bytes2human(totalbytes)) + \ + "\nFiles:\t\t%s\n" %(partition["files"]) else: - print "\n" + notmounted = notmounted + " " + partition["device"] + + print notmounted - print "debug output" - print diskmoninstance.partitions #end of file