mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 17:23:36 +02:00
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 <jan@janware.com>
This commit is contained in:
parent
193b8242d7
commit
fd336ecdcf
1 changed files with 7 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue