From a58220a13134078b579abaaf1bebc22bed1b8f1a Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sat, 11 Apr 2026 10:20:28 +0200 Subject: [PATCH] lib.ec.SSHClient.ssh_client(): Add type parameter ssh_client() tries a predefined order of client class implementations until it finds a workable candidate. For testing all, it's desirable to be able to target the exact class. Add a "type" parameter to achieve that. I'm aware that type is also a function. But the semantics look so compelling to me that I'm using the variable name anyway. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/ec/SSHClient.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/python/jw/pkg/lib/ec/SSHClient.py b/src/python/jw/pkg/lib/ec/SSHClient.py index 9b11a59b..e00ed8df 100644 --- a/src/python/jw/pkg/lib/ec/SSHClient.py +++ b/src/python/jw/pkg/lib/ec/SSHClient.py @@ -129,10 +129,12 @@ class SSHClient(ExecContext): def username(self) -> str: return self.__username -def ssh_client(*args, **kwargs) -> SSHClient: # export +def ssh_client(*args, type=['AsyncSSH', 'Paramiko', 'Exec'], **kwargs) -> SSHClient: # export from importlib import import_module errors: list[str] = [] - for name in ['AsyncSSH', 'Paramiko', 'Exec']: + if isinstance(type, str): + type = [type] + for name in type: try: ret = getattr(import_module(f'jw.pkg.lib.ec.ssh.{name}'), name)(*args, **kwargs) log(INFO, f'Using SSH-client "{name}"')