Skip to content

Commit

Permalink
Merge pull request #720 from ianmcorvidae/winserver-fix
Browse files Browse the repository at this point in the history
Fix windows-11 detection for non-float platform.release() values
  • Loading branch information
ianmcorvidae authored Dec 21, 2024
2 parents 29f355b + afd071c commit 749c6a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 7 additions & 0 deletions meshtastic/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,13 @@ def test_is_windows11_false_win8_1(patched_platform, patched_release):
patched_platform.assert_called()
patched_release.assert_called()

@patch("platform.release", return_value="2022Server")
@patch("platform.system", return_value="Windows")
def test_is_windows11_false_winserver(patched_platform, patched_release):
"""Test is_windows11()"""
assert is_windows11() is False
patched_platform.assert_called()
patched_release.assert_called()

@pytest.mark.unit
@patch("platform.system", return_value="Linux")
Expand Down
14 changes: 7 additions & 7 deletions meshtastic/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,15 @@ def is_windows11() -> bool:
"""Detect if Windows 11"""
is_win11: bool = False
if platform.system() == "Windows":
if float(platform.release()) >= 10.0:
patch = platform.version().split(".")[2]
# in case they add some number suffix later, just get first 5 chars of patch
patch = patch[:5]
try:
try:
if float(platform.release()) >= 10.0:
patch = platform.version().split(".")[2]
# in case they add some number suffix later, just get first 5 chars of patch
patch = patch[:5]
if int(patch) >= 22000:
is_win11 = True
except Exception as e:
print(f"problem detecting win11 e:{e}")
except Exception as e:
print(f"problem detecting win11 e:{e}")
return is_win11


Expand Down

0 comments on commit 749c6a7

Please sign in to comment.