@@ -0,0 +1,1172 @@
+#!/usr/bin/env python%0A%0A%22%22%22%0AList all mounted disk partitions a-la %22df%22 command.%0A%22%22%22%0A%0Aimport sys%0Aimport psutil%0A%0Adef convert_bytes(n):%0A    if n == 0:%0A        return %220B%22%0A    symbols = ('k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')%0A    prefix = %7B%7D%0A    for i, s in enumerate(symbols):%0A        prefix%5Bs%5D = 1 %3C%3C (i+1)*10%0A    for s in reversed(symbols):%0A        if n %3E= prefix%5Bs%5D:%0A            value = float(n) / prefix%5Bs%5D%0A            return '%25.1f%25s' %25 (value, s)%0A%0Adef main():%0A    print %22Device       Total     Used     Free  Use %25     Type  Mount%22%0A    for part in psutil.disk_partitions(0):%0A        usage = psutil.disk_usage(part.mountpoint)%0A        print %22%25-9s %258s %258s %258s %255s%25%25 %258s  %25s%22 %25 (part.device,%0A                                                  convert_bytes(usage.total),%0A                                                  convert_bytes(usage.used),%0A                                                  convert_bytes(usage.free),%0A                                                  int(usage.percent),%0A                                                  part.fstype,%0A                                                  part.mountpoint)%0A%0Aif __name__ == '__main__':%0A    sys.exit(main())%0A

add disk_usage.py example script