def getDiskSpaceUsage(diskPath=None):
 if (diskPath and os.path.exists(diskPath)):
  if (platform.system() == u'Windows'):
   free_bytes = ctypes.c_ulonglong(0)
   ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(diskPath), None, None, ctypes.pointer(free_bytes))
   return pretty_filesize(free_bytes.value)
  else:
   st = os.statvfs(diskPath)
   return pretty_filesize((st.f_bavail * st.f_frsize))
 else:
  return False

def getDiskSpaceUsage ( diskPath = None ) : if ( diskPath and os . path . exists ( diskPath ) ) : if ( platform . system ( ) == u'Windows' ) : free_bytes = ctypes . c_ulonglong ( 0 ) ctypes . windll . kernel32 . GetDiskFreeSpaceExW ( ctypes . c_wchar_p ( diskPath ) , None , None , ctypes . pointer ( free_bytes ) ) return pretty_filesize ( free_bytes . value ) else : st = os . statvfs ( diskPath ) return pretty_filesize ( ( st . f_bavail * st . f_frsize ) ) else : return False
returns the free space in human readable bytes for a given path or false if no path given .