def get_free_mb ( folder ) : if platform . system ( ) == 'Windows' : free_bytes = ctypes . c_ulonglong ( 0 ) ctypes . windll . kernel32 . GetDiskFreeSpaceExW ( ctypes . c_wchar_p ( folder ) , None , None , ctypes . pointer ( free_bytes ) ) return free_bytes . value / 1024 / 1024 else : st = os . statvfs ( folder ) return st . f_bavail * st . f_frsize / 1024 / 1024
python function get free disk space linux
Return folder / drive free space ( in bytes )
def get_free_mb(folder):
    """ Return folder/drive free space (in bytes)
    """
    if platform.system() == 'Windows':
        free_bytes = ctypes.c_ulonglong(0)
        ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(folder), None, None, ctypes.pointer(free_bytes))
        return free_bytes.value/1024/1024
    else:
        st = os.statvfs(folder)
        return st.f_bavail * st.f_frsize/1024/1024