Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 42 additions & 32 deletions exec_helpers/_ssh_client_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ CPYTHON: bool = ...

class _MemorizedSSH(type):
@classmethod
def __prepare__(mcs: typing.Type[_MemorizedSSH], name: str, bases: typing.Iterable[typing.Type], **kwargs: typing.Dict) -> collections.OrderedDict: ...
def __prepare__(
mcs: typing.Type[_MemorizedSSH],
name: str,
bases: typing.Iterable[typing.Type],
**kwargs: typing.Dict
) -> collections.OrderedDict: ...

def __call__( # type: ignore
cls: _MemorizedSSH,
host: str,
port: int=...,
username: typing.Optional[str]=...,
password: typing.Optional[str]=...,
private_keys: typing.Optional[typing.Iterable[paramiko.RSAKey]]=...,
auth: typing.Optional[ssh_auth.SSHAuth]=...,
verbose: bool=...
port: int = ...,
username: typing.Optional[str] = ...,
password: typing.Optional[str] = ...,
private_keys: typing.Optional[typing.Iterable[paramiko.RSAKey]] = ...,
auth: typing.Optional[ssh_auth.SSHAuth] = ...,
verbose: bool = ...,
) -> SSHClientBase: ...

@classmethod
Expand All @@ -36,12 +41,12 @@ class SSHClientBase(api.ExecHelper, metaclass=_MemorizedSSH):
def __init__(
self,
host: str,
port: int=...,
username: typing.Optional[str]=...,
password: typing.Optional[str]=...,
private_keys: typing.Optional[typing.Iterable[paramiko.RSAKey]]=...,
auth: typing.Optional[ssh_auth.SSHAuth]=...,
verbose: bool=...
port: int = ...,
username: typing.Optional[str] = ...,
password: typing.Optional[str] = ...,
private_keys: typing.Optional[typing.Iterable[paramiko.RSAKey]] = ...,
auth: typing.Optional[ssh_auth.SSHAuth] = ...,
verbose: bool = ...,
) -> None: ...

@property
Expand Down Expand Up @@ -90,20 +95,25 @@ class SSHClientBase(api.ExecHelper, metaclass=_MemorizedSSH):

def reconnect(self) -> None: ...

def sudo(self, enforce: typing.Optional[bool]=...) -> typing.ContextManager: ...
def sudo(self, enforce: typing.Optional[bool] = ...) -> typing.ContextManager: ...

def keepalive(self, enforce: bool=...) -> typing.ContextManager: ...
def keepalive(self, enforce: bool = ...) -> typing.ContextManager: ...

def execute_async(
self,
command: str,
stdin: typing.Union[typing.AnyStr, bytearray, None]=...,
open_stdout: bool=...,
open_stderr: bool=...,
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
stdin: typing.Union[typing.AnyStr, bytearray, None] = ...,
open_stdout: bool = ...,
open_stderr: bool = ...,
verbose: bool = ...,
log_mask_re: typing.Optional[str] = ...,
**kwargs: typing.Dict
) -> typing.Tuple[paramiko.Channel, paramiko.ChannelFile, typing.Optional[paramiko.ChannelFile], typing.Optional[paramiko.ChannelFile]]: ...
) -> typing.Tuple[
paramiko.Channel,
paramiko.ChannelFile,
typing.Optional[paramiko.ChannelFile],
typing.Optional[paramiko.ChannelFile],
]: ...

def _exec_command(
self,
Expand All @@ -112,20 +122,20 @@ class SSHClientBase(api.ExecHelper, metaclass=_MemorizedSSH):
stdout: paramiko.channel.ChannelFile,
stderr: paramiko.channel.ChannelFile,
timeout: typing.Union[int, None],
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
verbose: bool = ...,
log_mask_re: typing.Optional[str] = ...,
**kwargs: typing.Dict
) -> exec_result.ExecResult: ...

def execute_through_host(
self,
hostname: str,
command: str,
auth: typing.Optional[ssh_auth.SSHAuth]=...,
target_port: int=...,
verbose: bool=...,
timeout: typing.Union[int, None]=...,
get_pty: bool=...,
auth: typing.Optional[ssh_auth.SSHAuth] = ...,
target_port: int = ...,
verbose: bool = ...,
timeout: typing.Union[int, None] = ...,
get_pty: bool = ...,
**kwargs: typing.Dict
) -> exec_result.ExecResult: ...

Expand All @@ -134,9 +144,9 @@ class SSHClientBase(api.ExecHelper, metaclass=_MemorizedSSH):
cls,
remotes: typing.Iterable[SSHClientBase],
command: str,
timeout: typing.Union[int, None]=...,
expected: typing.Optional[typing.Iterable[int]]=...,
raise_on_err: bool=...,
timeout: typing.Union[int, None] = ...,
expected: typing.Optional[typing.Iterable[int]] = ...,
raise_on_err: bool = ...,
**kwargs: typing.Dict
) -> typing.Dict[typing.Tuple[str, int], exec_result.ExecResult]: ...

Expand All @@ -146,7 +156,7 @@ class SSHClientBase(api.ExecHelper, metaclass=_MemorizedSSH):

def stat(self, path: str) -> paramiko.sftp_attr.SFTPAttributes: ...

def utime(self, path: str, times: typing.Optional[typing.Tuple[int, int]]=...) -> None: ...
def utime(self, path: str, times: typing.Optional[typing.Tuple[int, int]] = ...) -> None: ...

def isfile(self, path: str) -> bool: ...

Expand Down
42 changes: 21 additions & 21 deletions exec_helpers/api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from exec_helpers import exec_result, proc_enums
class ExecHelper:
log_mask_re: typing.Optional[str] = ...

def __init__(self, logger: logging.Logger, log_mask_re: typing.Optional[str]=...) -> None: ...
def __init__(self, logger: logging.Logger, log_mask_re: typing.Optional[str] = ...) -> None: ...

@property
def logger(self) -> logging.Logger: ...
Expand All @@ -19,18 +19,18 @@ class ExecHelper:

def __exit__(self, exc_type: typing.Any, exc_val: typing.Any, exc_tb: typing.Any) -> None: ...

def _mask_command(self, cmd: str, log_mask_re: typing.Optional[str]=...) -> str: ...
def _mask_command(self, cmd: str, log_mask_re: typing.Optional[str] = ...) -> str: ...

def execute_async(
self,
command: str,
stdin: typing.Union[typing.AnyStr, bytearray, None]=...,
open_stdout: bool=...,
open_stderr: bool=...,
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
stdin: typing.Union[typing.AnyStr, bytearray, None] = ...,
open_stdout: bool = ...,
open_stderr: bool = ...,
verbose: bool = ...,
log_mask_re: typing.Optional[str] = ...,
**kwargs: typing.Dict
) -> typing.Tuple[typing.Any, typing.Any, typing.Any, typing.Any,]: ...
) -> typing.Tuple[typing.Any, typing.Any, typing.Any, typing.Any]: ...

def _exec_command(
self,
Expand All @@ -39,36 +39,36 @@ class ExecHelper:
stdout: typing.Any,
stderr: typing.Any,
timeout: typing.Union[int, None],
verbose: bool=...,
log_mask_re: typing.Optional[str]=...,
verbose: bool = ...,
log_mask_re: typing.Optional[str] = ...,
**kwargs: typing.Dict
) -> exec_result.ExecResult: ...

def execute(
self,
command: str,
verbose: bool=...,
timeout: typing.Union[int, None]=...,
verbose: bool = ...,
timeout: typing.Union[int, None] = ...,
**kwargs: typing.Type
) -> exec_result.ExecResult: ...

def check_call(
self,
command: str,
verbose: bool=...,
timeout: typing.Union[int, None]=...,
error_info: typing.Optional[str]=...,
expected: typing.Optional[typing.Iterable[typing.Union[int, proc_enums.ExitCodes]]]=...,
raise_on_err: bool=...,
verbose: bool = ...,
timeout: typing.Union[int, None] = ...,
error_info: typing.Optional[str] = ...,
expected: typing.Optional[typing.Iterable[typing.Union[int, proc_enums.ExitCodes]]] = ...,
raise_on_err: bool = ...,
**kwargs: typing.Type
) -> exec_result.ExecResult: ...

def check_stderr(
self,
command: str,
verbose: bool=...,
timeout: typing.Union[int, None]=...,
error_info: typing.Optional[str]=...,
raise_on_err: bool=...,
verbose: bool = ...,
timeout: typing.Union[int, None] = ...,
error_info: typing.Optional[str] = ...,
raise_on_err: bool = ...,
**kwargs: typing.Dict
) -> exec_result.ExecResult: ...
24 changes: 7 additions & 17 deletions exec_helpers/exceptions.pyi
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import typing
from exec_helpers import proc_enums, exec_result

class ExecHelperError(Exception):
...
class ExecHelperError(Exception): ...

class DeserializeValueError(ExecHelperError, ValueError):
...


class ExecCalledProcessError(ExecHelperError):
...
class DeserializeValueError(ExecHelperError, ValueError): ...

class ExecCalledProcessError(ExecHelperError): ...

class ExecHelperTimeoutError(ExecCalledProcessError):

result: exec_result.ExecResult = ...
timeout: int = ...

def __init__(
self,
result: exec_result.ExecResult,
timeout: typing.Union[int, float],
) -> None: ...
def __init__(self, result: exec_result.ExecResult, timeout: typing.Union[int, float]) -> None: ...

@property
def cmd(self) -> str: ...
Expand All @@ -36,13 +27,12 @@ class ExecHelperTimeoutError(ExecCalledProcessError):
class CalledProcessError(ExecCalledProcessError):

result: exec_result.ExecResult = ...

expected: typing.List[typing.Union[int, proc_enums.ExitCodes]] = ...

def __init__(
self,
result: exec_result.ExecResult,
expected: typing.Optional[typing.List[typing.Union[int, proc_enums.ExitCodes]]]=...
expected: typing.Optional[typing.List[typing.Union[int, proc_enums.ExitCodes]]] = ...,
) -> None: ...

@property
Expand Down Expand Up @@ -72,7 +62,7 @@ class ParallelCallExceptions(ExecCalledProcessError):
exceptions: typing.Dict[typing.Tuple[str, int], Exception],
errors: typing.Dict[typing.Tuple[str, int], exec_result.ExecResult],
results: typing.Dict[typing.Tuple[str, int], exec_result.ExecResult],
expected: typing.Optional[typing.List[typing.Union[int, proc_enums.ExitCodes]]]=...
expected: typing.Optional[typing.List[typing.Union[int, proc_enums.ExitCodes]]] = ...,
) -> None: ...

class ParallelCallProcessError(ExecCalledProcessError):
Expand All @@ -87,5 +77,5 @@ class ParallelCallProcessError(ExecCalledProcessError):
command: str,
errors: typing.Dict[typing.Tuple[str, int], exec_result.ExecResult],
results: typing.Dict[typing.Tuple[str, int], exec_result.ExecResult],
expected: typing.Optional[typing.List[typing.Union[int, proc_enums.ExitCodes]]]=...
expected: typing.Optional[typing.List[typing.Union[int, proc_enums.ExitCodes]]] = ...,
) -> None: ...
20 changes: 10 additions & 10 deletions exec_helpers/exec_result.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class ExecResult:
def __init__(
self,
cmd: str,
stdin: typing.Union[typing.AnyStr, bytearray, None]=...,
stdout: typing.Optional[typing.Iterable[bytes]]=...,
stderr: typing.Optional[typing.Iterable[bytes]]=...,
exit_code: typing.Union[int, proc_enums.ExitCodes]=...
stdin: typing.Union[typing.AnyStr, bytearray, None] = ...,
stdout: typing.Optional[typing.Iterable[bytes]] = ...,
stderr: typing.Optional[typing.Iterable[bytes]] = ...,
exit_code: typing.Union[int, proc_enums.ExitCodes] = ...,
) -> None: ...

@property
Expand Down Expand Up @@ -43,16 +43,16 @@ class ExecResult:

def read_stdout(
self,
src: typing.Optional[typing.Iterable]=...,
log: typing.Optional[logging.Logger]=...,
verbose: bool=...
src: typing.Optional[typing.Iterable] = ...,
log: typing.Optional[logging.Logger] = ...,
verbose: bool = ...,
) -> None: ...

def read_stderr(
self,
src: typing.Optional[typing.Iterable]=...,
log: typing.Optional[logging.Logger]=...,
verbose: bool=...
src: typing.Optional[typing.Iterable] = ...,
log: typing.Optional[logging.Logger] = ...,
verbose: bool = ...,
) -> None: ...

@property
Expand Down
18 changes: 9 additions & 9 deletions exec_helpers/ssh_auth.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import typing
class SSHAuth:
def __init__(
self,
username: typing.Optional[str]=...,
password: typing.Optional[str]=...,
key: typing.Optional[paramiko.RSAKey]=...,
keys: typing.Optional[typing.Iterable[paramiko.RSAKey]]=...,
key_filename: typing.Union[typing.List[str], str, None]=...,
passphrase: typing.Optional[str]=...
username: typing.Optional[str] = ...,
password: typing.Optional[str] = ...,
key: typing.Optional[paramiko.RSAKey] = ...,
keys: typing.Optional[typing.Iterable[paramiko.RSAKey]] = ...,
key_filename: typing.Union[typing.List[str], str, None] = ...,
passphrase: typing.Optional[str] = ...,
) -> None: ...

@property
Expand All @@ -27,9 +27,9 @@ class SSHAuth:
def connect(
self,
client: typing.Union[paramiko.SSHClient, paramiko.Transport],
hostname: typing.Optional[str]=...,
port: int=...,
log: bool=...
hostname: typing.Optional[str] = ...,
port: int = ...,
log: bool = ...,
) -> None: ...

def __eq__(self, other: typing.Any) -> bool: ...
Expand Down
Loading