Exemplo n.º 1
0
def detectos(required_ver, mock=False):
    """Returns boolean whether the detectos is compatible with the
    current operating system, or the mock version, if given."""
    # Do not compare as string because Windows 10 (build 10.0) comes after
    # Windows 8.1 (build 6.3)
    assert isinstance(required_ver, (str, unicode))
    #현재의 os를 초기화 한다.
    current_os = (mock if mock else Windows.parse_windows_build())
    #required_ver에 required_ver을 붙인다.
    required_ver = required_ver.strip()
    #만약 '|'가 required_ver라면
    if '|' in required_ver:
        # Format of min|max
        # req_min에 required_ver[0]에 '|'붙인 것을 초기화한다.
        req_min = required_ver.split('|')[0]
        # req_max에 required_ver[1]에 '|'붙인 것을 초기화한다.
        req_max = required_ver.split('|')[1]

        #비교를 통해 false와 true을 리턴한다.
        if req_min and current_os < Windows.parse_windows_build(req_min):
            return False
        if req_max and current_os > Windows.parse_windows_build(req_max):
            return False
        return True
    else:
        #버전이 호환된다면 현재의 os를 반환한다.
        # Exact version
        return Windows.parse_windows_build(required_ver) == current_os
Exemplo n.º 2
0
def detectos(required_ver, mock=False):
    """Returns boolean whether the detectos is compatible with the
    current operating system, or the mock version, if given."""
    # Do not compare as string because Windows 10 (build 10.0) comes after
    # Windows 8.1 (build 6.3).
    assert (isinstance(required_ver, (str, unicode)))
    current_os = (mock if mock else Windows.parse_windows_build())
    required_ver = required_ver.strip()
    if required_ver.startswith('|'):
        # This is the maximum version
        # For example, |5.1 means Windows XP (5.1) but not Vista (6.0)
        return current_os <= Windows.parse_windows_build(required_ver[1:])
    elif required_ver.endswith('|'):
        # This is the minimum version
        # For example, 6.1| means Windows 7 or later
        return current_os >= Windows.parse_windows_build(required_ver[:-1])
    else:
        # Exact version
        return Windows.parse_windows_build(required_ver) == current_os
Exemplo n.º 3
0
def detectos(required_ver, mock=False):
    """Returns boolean whether the detectos is compatible with the
    current operating system, or the mock version, if given."""
    # Do not compare as string because Windows 10 (build 10.0) comes after
    # Windows 8.1 (build 6.3).
    assert isinstance(required_ver, str)
    current_os = mock or Windows.parse_windows_build()
    required_ver = required_ver.strip()
    if '|' not in required_ver:
        # Exact version
        return Windows.parse_windows_build(required_ver) == current_os
    # Format of min|max
    req_min = required_ver.split('|')[0]
    req_max = required_ver.split('|')[1]
    if req_min and current_os < Windows.parse_windows_build(req_min):
        return False
    if req_max and current_os > Windows.parse_windows_build(req_max):
        return False
    return True
Exemplo n.º 4
0
def detectos(required_ver, mock=False):
    """Returns boolean whether the detectos is compatible with the
    current operating system, or the mock version, if given."""
    # Do not compare as string because Windows 10 (build 10.0) comes after
    # Windows 8.1 (build 6.3).
    assert(isinstance(required_ver, (str, unicode)))
    current_os = (mock if mock else Windows.parse_windows_build())
    required_ver = required_ver.strip()
    if required_ver.startswith('|'):
        # This is the maximum version
        # For example, |5.1 means Windows XP (5.1) but not Vista (6.0)
        return current_os <= Windows.parse_windows_build(required_ver[1:])
    elif required_ver.endswith('|'):
        # This is the minimum version
        # For example, 6.1| means Windows 7 or later
        return current_os >= Windows.parse_windows_build(required_ver[:-1])
    else:
        # Exact version
        return Windows.parse_windows_build(required_ver) == current_os
Exemplo n.º 5
0
def detectos(required_ver, mock=False):
    """Returns boolean whether the detectos is compatible with the
    current operating system, or the mock version, if given."""
    # Do not compare as string because Windows 10 (build 10.0) comes after
    # Windows 8.1 (build 6.3).
    assert isinstance(required_ver, (str, unicode))
    current_os = (mock if mock else Windows.parse_windows_build())
    required_ver = required_ver.strip()
    if '|' in required_ver:
        # Format of min|max
        req_min = required_ver.split('|')[0]
        req_max = required_ver.split('|')[1]
        if req_min and current_os < Windows.parse_windows_build(req_min):
            return False
        if req_max and current_os > Windows.parse_windows_build(req_max):
            return False
        return True
    else:
        # Exact version
        return Windows.parse_windows_build(required_ver) == current_os
Exemplo n.º 6
0
def free_space(pathname):
    """Return free space in bytes"""
    if 'nt' == os.name:
        from bleachbit import Windows
        if Windows.parse_windows_build() >= 6:
            # This works better with UTF-8 paths.
            import psutil
            return psutil.disk_usage(pathname).free
        else:
            # This works better with Windows XP but not UTF-8.
            # Deprecated.
            _, _, free_bytes = win32file.GetDiskFreeSpaceEx(pathname)
            return free_bytes
    mystat = os.statvfs(pathname)
    return mystat.f_bfree * mystat.f_bsize
Exemplo n.º 7
0
def free_space(pathname):
    """Return free space in bytes"""
    if 'nt' == os.name:
        from bleachbit import Windows
        if Windows.parse_windows_build() >= 6:
            # This works better with UTF-8 paths.
            import psutil
            return psutil.disk_usage(pathname).free
        else:
            # This works better with Windows XP but not UTF-8.
            # Deprecated.
            _fb, _tb, total_free_bytes = win32file.GetDiskFreeSpaceEx(pathname)
            return total_free_bytes
    mystat = os.statvfs(pathname)
    return mystat.f_bfree * mystat.f_bsize