#!/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) / 1024 return bytes if __name__ == "__main__": diskmoninstance = disk.diskmon() 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) 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]) else: print "\n" print "debug output" print diskmoninstance.partitions #end of file