#!/usr/bin/python2 -B """ simple display to show results of disk.py """ import disk def bytes2human(bytes): units = ["B", "KB", "MB", "GB", "TB", "PB", "EB"] counter = 0 while bytes > 1024: bytes = bytes / 1024 counter += 1 human = [bytes, units[counter]] return human def blocks2bytes(blocks, blocksize): bytes = float(blocks) * float(blocksize) return bytes if __name__ == "__main__": diskmoninstance = disk.diskmon() for partition in diskmoninstance.partitions: print "Device:\t\t" + str(partition["device"]) + \ "\nUUID:\t\t" + str(partition["uuid"]) if partition.has_key("mountpoint"): totalbytes = blocks2bytes(partition["total blocks"], partition["blocksize"]) totalhuman = bytes2human(totalbytes) print "Mountpoint:\t" + str(partition["mountpoint"]) + \ "\nFilesystem:\t" + str(partition["filesystem"]) + \ "\nSize:\t\t%.2f %s\n" %(totalhuman[0], totalhuman[1]) else: print "\n" #end of file