mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 09:35:54 +02:00
lib.ec.ssh.AsyncSSH: Add class
Add a SSHClient implementation using AsyncSSH. This is the first and currently only class derived from SSHClient which implements SSHClient.Cap.LogOutput, designed to consume and log command output as it streams in. It felt like the lower hanging fruit not to do that with Paramiko: Paramiko doesn't provide a native async API, so it would need to spawn additional worker threads. I think. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
279b7789e2
commit
737cbc3e24
2 changed files with 244 additions and 2 deletions
|
|
@ -129,9 +129,11 @@ class SSHClient(ExecContext):
|
|||
def ssh_client(*args, **kwargs) -> SSHClient: # export
|
||||
from importlib import import_module
|
||||
errors: list[str] = []
|
||||
for name in ['Paramiko', 'Exec']:
|
||||
for name in ['AsyncSSH', 'Paramiko', 'Exec']:
|
||||
try:
|
||||
return getattr(import_module(f'jw.pkg.lib.ec.ssh.{name}'), name)(*args, **kwargs)
|
||||
ret = getattr(import_module(f'jw.pkg.lib.ec.ssh.{name}'), name)(*args, **kwargs)
|
||||
log(INFO, f'Using SSH-client "{name}"')
|
||||
return ret
|
||||
except Exception as e:
|
||||
msg = f'Can\'t instantiate SSH client class {name} ({str(e)})'
|
||||
errors.append(msg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue