mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-28 13:55:24 +02:00
lib.ExecContext.__init__(): Add parameter uri
Take a positional uri argument to the constructor of ExecContext, forcing SSHClient to follow suit. The latter was instantiated with a hostname as only argument up to now, which still works as a special case of an uri. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
db9bf1826d
commit
888c1e7f16
3 changed files with 20 additions and 10 deletions
|
|
@ -7,14 +7,16 @@ import os, abc, shlex, sys
|
|||
from .util import run_cmd
|
||||
from .log import *
|
||||
from .ExecContext import ExecContext, Result
|
||||
from urllib.parse import urlparse
|
||||
|
||||
class SSHClient(ExecContext):
|
||||
|
||||
def __init__(self, hostname: str) -> None:
|
||||
super().__init__(interactive=False, verbose_default=False)
|
||||
self.___ssh = None
|
||||
self.__hostname = hostname
|
||||
self.__password: str|None = None
|
||||
def __init__(self, uri: str, *args, **kwargs) -> None:
|
||||
super().__init__(uri=uri, *args, **kwargs)
|
||||
parsed = urlparse(uri)
|
||||
self.__hostname = parsed.hostname
|
||||
self.__password: parsed.password
|
||||
self.__username = parsed.username
|
||||
|
||||
@abc.abstractmethod
|
||||
async def _run_cmd(self, cmd: list[str]) -> Result:
|
||||
|
|
@ -101,8 +103,8 @@ class SSHClient(ExecContext):
|
|||
|
||||
class SSHClientInternal(SSHClient): # export
|
||||
|
||||
def __init__(self, hostname: str) -> None:
|
||||
super().__init__(hostname=hostname)
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
self.__timeout: float|None = None # Untested
|
||||
self.___ssh: Any|None = None
|
||||
|
||||
|
|
@ -136,10 +138,10 @@ class SSHClientInternal(SSHClient): # export
|
|||
|
||||
class SSHClientCmd(SSHClient): # export
|
||||
|
||||
def __init__(self, hostname: str) -> None:
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
self.__askpass: str|None = None
|
||||
self.__askpass_orig: dict[str, str|None] = dict()
|
||||
super().__init__(hostname=hostname)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __del__(self):
|
||||
for key, val in self.__askpass_orig.items():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue