diff --git a/yascheduler/remote_machine/adapters.py b/yascheduler/remote_machine/adapters.py index 7bbbd58..1af2482 100644 --- a/yascheduler/remote_machine/adapters.py +++ b/yascheduler/remote_machine/adapters.py @@ -8,8 +8,12 @@ from .checks import ( check_is_debian, - check_is_debian_bullseye, - check_is_debian_buster, + check_is_debian_10, + check_is_debian_11, + check_is_debian_12, + check_is_debian_13, + check_is_debian_14, + check_is_debian_15, check_is_debian_like, check_is_linux, check_is_windows, @@ -17,6 +21,7 @@ check_is_windows8, check_is_windows10, check_is_windows11, + check_is_windows12, ) from .common import run, run_bg from .linux_methods import ( @@ -90,16 +95,40 @@ class RemoteMachineAdapter(PRemoteMachineAdapter): checks=(*debian_like_adapter.checks, check_is_debian), ) -debian_buster_adapter = evolve( +debian_10_adapter = evolve( debian_adapter, platform="debian-10", - checks=(*debian_adapter.checks, check_is_debian_buster), + checks=(*debian_adapter.checks, check_is_debian_10), ) -debian_bullseye_adapter = evolve( +debian_11_adapter = evolve( debian_adapter, platform="debian-11", - checks=(*debian_adapter.checks, check_is_debian_bullseye), + checks=(*debian_adapter.checks, check_is_debian_11), +) + +debian_12_adapter = evolve( + debian_adapter, + platform="debian-12", + checks=(*debian_adapter.checks, check_is_debian_12), +) + +debian_13_adapter = evolve( + debian_adapter, + platform="debian-13", + checks=(*debian_adapter.checks, check_is_debian_13), +) + +debian_14_adapter = evolve( + debian_adapter, + platform="debian-14", + checks=(*debian_adapter.checks, check_is_debian_14), +) + +debian_15_adapter = evolve( + debian_adapter, + platform="debian-15", + checks=(*debian_adapter.checks, check_is_debian_15), ) windows_adapter = RemoteMachineAdapter( @@ -138,3 +167,9 @@ class RemoteMachineAdapter(PRemoteMachineAdapter): platform="windows-11", checks=(*windows_adapter.checks, check_is_windows11), ) + +windows12_adapter = evolve( + windows_adapter, + platform="windows-12", + checks=(*windows_adapter.checks, check_is_windows12), +) diff --git a/yascheduler/remote_machine/checks.py b/yascheduler/remote_machine/checks.py index 5feb4f9..fdfc7dc 100644 --- a/yascheduler/remote_machine/checks.py +++ b/yascheduler/remote_machine/checks.py @@ -1,5 +1,6 @@ "OS checks" +from functools import partial from typing import Optional, Tuple from asyncssh.connection import SSHClientConnection @@ -38,16 +39,18 @@ async def check_is_debian(conn: SSHClientConnection) -> bool: return os_release[0] == "debian" if os_release else False -async def check_is_debian_buster(conn: SSHClientConnection) -> bool: - "Check for Debian 10" +async def _check_debian_version(version: str, conn: SSHClientConnection) -> bool: + "Check for Debian version" os_release = await _get_os_release(conn) - return os_release[2] == "10" if os_release else False + return os_release[2] == version if os_release else False -async def check_is_debian_bullseye(conn: SSHClientConnection) -> bool: - "Check for Debian 11" - os_release = await _get_os_release(conn) - return os_release[2] == "11" if os_release else False +check_is_debian_10 = partial(_check_debian_version, "10") +check_is_debian_11 = partial(_check_debian_version, "11") +check_is_debian_12 = partial(_check_debian_version, "12") +check_is_debian_13 = partial(_check_debian_version, "13") +check_is_debian_14 = partial(_check_debian_version, "14") +check_is_debian_15 = partial(_check_debian_version, "15") @lru_cache @@ -65,25 +68,16 @@ async def get_wmi_w32_os_caption(conn: SSHClientConnection) -> Optional[str]: return str(proc.stdout) -async def check_is_windows7(conn: SSHClientConnection) -> bool: - "Check for Windows 7" - caption = await get_wmi_w32_os_caption(conn) - return "7" in caption if caption else False - - -async def check_is_windows8(conn: SSHClientConnection) -> bool: - "Check for Windows 8" +async def _check_is_windows_caption_version( + version: str, conn: SSHClientConnection +) -> bool: + "Check for Windows version in caption" caption = await get_wmi_w32_os_caption(conn) - return "8" in caption if caption else False + return version in caption if caption else False -async def check_is_windows10(conn: SSHClientConnection) -> bool: - "Check for Windows 10" - caption = await get_wmi_w32_os_caption(conn) - return "10" in caption if caption else False - - -async def check_is_windows11(conn: SSHClientConnection) -> bool: - "Check for Windows 11" - caption = await get_wmi_w32_os_caption(conn) - return "11" in caption if caption else False +check_is_windows7 = partial(_check_is_windows_caption_version, "7") +check_is_windows8 = partial(_check_is_windows_caption_version, "8") +check_is_windows10 = partial(_check_is_windows_caption_version, "10") +check_is_windows11 = partial(_check_is_windows_caption_version, "11") +check_is_windows12 = partial(_check_is_windows_caption_version, "12") diff --git a/yascheduler/remote_machine/remote_machine.py b/yascheduler/remote_machine/remote_machine.py index b128e9d..cc05cbc 100644 --- a/yascheduler/remote_machine/remote_machine.py +++ b/yascheduler/remote_machine/remote_machine.py @@ -22,15 +22,20 @@ from typing_extensions import Self from .adapters import ( + debian_10_adapter, + debian_11_adapter, + debian_12_adapter, + debian_13_adapter, + debian_14_adapter, + debian_15_adapter, debian_adapter, - debian_bullseye_adapter, - debian_buster_adapter, debian_like_adapter, linux_adapter, windows7_adapter, windows8_adapter, windows10_adapter, windows11_adapter, + windows12_adapter, windows_adapter, ) from .exc import PlatformGuessFailed @@ -47,15 +52,20 @@ ) ADAPTERS: Sequence[PRemoteMachineAdapter] = [ - debian_bullseye_adapter, - debian_buster_adapter, + debian_10_adapter, + debian_11_adapter, + debian_12_adapter, + debian_13_adapter, + debian_14_adapter, + debian_15_adapter, debian_adapter, debian_like_adapter, linux_adapter, - windows11_adapter, windows10_adapter, - windows8_adapter, + windows11_adapter, + windows12_adapter, windows7_adapter, + windows8_adapter, windows_adapter, ]