From fd336ecdcf57e7411512a77b7c2db29167502949 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Fri, 17 Apr 2026 17:37:11 +0200 Subject: [PATCH] lib.ec.SSHClient: Support JW_DEFAULT_SSH_CLIENT Allow to configure via the environment which class ssh_client() picks. Can currently be exec, asyncssh, paramiko or a comma-separated search list. The list will be tried through until a class is found that can be instantiated. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/ec/SSHClient.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/python/jw/pkg/lib/ec/SSHClient.py b/src/python/jw/pkg/lib/ec/SSHClient.py index aea5b63b..b5ffae05 100644 --- a/src/python/jw/pkg/lib/ec/SSHClient.py +++ b/src/python/jw/pkg/lib/ec/SSHClient.py @@ -130,9 +130,15 @@ class SSHClient(ExecContext): def username(self) -> str: return self.__username -def ssh_client(*args, type=['AsyncSSH', 'Paramiko', 'Exec'], **kwargs) -> SSHClient: # export +def ssh_client(*args, type: str|list[str]|None=None, **kwargs) -> SSHClient: # export from importlib import import_module errors: list[str] = [] + if type is None: + val = os.getenv('JW_DEFAULT_SSH_CLIENT') + if val is not None: + type = val.split(',') + else: + type = ['AsyncSSH', 'Paramiko', 'Exec'] if isinstance(type, str): type = [type] for name in type: