Skip to content

Commit c4ecd03

Browse files
authored
API port from master & bump to 1.4.0 (#87)
* API port from master & bump to 1.4.0 * `ExecuteAsyncResult` NamedTuple * Non-blocking execute * CI optimizations: static part before tests * Partial code-style port for easier backports later
1 parent 8cd9057 commit c4ecd03

17 files changed

+426
-587
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ after_success:
4343
jobs:
4444
fast_finish: true
4545
include:
46-
- stage: test
47-
<<: *python27
48-
- stage: test
49-
<<: *pypy
50-
5146
- <<: *static_analysis
5247
name: "PyLint"
5348
install:
@@ -88,6 +83,11 @@ jobs:
8883
script:
8984
- pydocstyle exec_helpers
9085

86+
- stage: test
87+
<<: *python27
88+
- stage: test
89+
<<: *pypy
90+
9191
- stage: deploy
9292
# This prevents job from appearing in test plan unless commit is tagged:
9393
if: tag IS present

doc/source/SSHClient.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,12 @@ API: SSHClient and SSHAuth.
138138
:param log_mask_re: regex lookup rule to mask command for logger.
139139
all MATCHED groups will be replaced by '<*masked*>'
140140
:type log_mask_re: typing.Optional[str]
141-
:rtype: ``typing.Tuple[paramiko.Channel, paramiko.ChannelFile, typing.Optional[paramiko.ChannelFile], typing.Optional[paramiko.ChannelFile]]``
141+
:rtype: SshExecuteAsyncResult
142142

143143
.. versionchanged:: 1.2.0 open_stdout and open_stderr flags
144144
.. versionchanged:: 1.2.0 stdin data
145145
.. versionchanged:: 1.2.0 get_pty moved to `**kwargs`
146+
.. versionchanged:: 1.4.0 Use typed NamedTuple as result
146147

147148
.. py:method:: execute(command, verbose=False, timeout=1*60*60, **kwargs)
148149
@@ -388,3 +389,24 @@ API: SSHClient and SSHAuth.
388389
:param log: Log on generic connection failure
389390
:type log: ``bool``
390391
:raises paramiko.AuthenticationException: Authentication failed.
392+
393+
394+
.. py:class:: SshExecuteAsyncResult
395+
396+
Typed NamedTuple
397+
398+
.. py:attribute:: interface
399+
400+
``paramiko.Channel``
401+
402+
.. py:attribute:: stdin
403+
404+
``paramiko.ChannelFile``
405+
406+
.. py:attribute:: stderr
407+
408+
``typing.Optional[paramiko.ChannelFile]``
409+
410+
.. py:attribute:: stdout
411+
412+
``typing.Optional[paramiko.ChannelFile]``

doc/source/Subprocess.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ API: Subprocess
5656
:param log_mask_re: regex lookup rule to mask command for logger.
5757
all MATCHED groups will be replaced by '<*masked*>'
5858
:type log_mask_re: ``typing.Optional[str]``
59-
:rtype: ``typing.Tuple[subprocess.Popen, None, typing.Optional[typing.IO], typing.Optional[typing.IO], ]``
59+
:rtype: SubprocessExecuteAsyncResult
60+
:raises OSError: impossible to process STDIN
6061

6162
.. versionadded:: 1.2.0
63+
.. versionchanged:: 1.4.0 Use typed NamedTuple as result
6264

6365
.. py:method:: execute(command, verbose=False, timeout=1*60*60, **kwargs)
6466
@@ -124,3 +126,24 @@ API: Subprocess
124126

125127
.. versionchanged:: 1.1.0 make method
126128
.. versionchanged:: 1.2.0 default timeout 1 hour
129+
130+
131+
.. py:class:: SubprocessExecuteAsyncResult
132+
133+
Typed NamedTuple
134+
135+
.. py:attribute:: interface
136+
137+
``subprocess.Popen``
138+
139+
.. py:attribute:: stdin
140+
141+
``typing.Optional[typing.IO]``
142+
143+
.. py:attribute:: stderr
144+
145+
``typing.Optional[typing.IO]``
146+
147+
.. py:attribute:: stdout
148+
149+
``typing.Optional[typing.IO]``

exec_helpers/__init__.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,41 @@
2424
CalledProcessError,
2525
ParallelCallProcessError,
2626
ParallelCallExceptions,
27-
ExecHelperTimeoutError
27+
ExecHelperTimeoutError,
2828
)
2929

3030
from .exec_result import ExecResult
3131
from .api import ExecHelper
3232
from .ssh_auth import SSHAuth
33+
from ._ssh_client_base import SshExecuteAsyncResult
3334
from .ssh_client import SSHClient
34-
from .subprocess_runner import Subprocess # nosec # Expected
35+
from .subprocess_runner import Subprocess, SubprocessExecuteAsyncResult # nosec # Expected
3536

3637
__all__ = (
37-
'ExecHelperError',
38-
'ExecCalledProcessError',
39-
'CalledProcessError',
40-
'ParallelCallExceptions',
41-
'ParallelCallProcessError',
42-
'ExecHelperTimeoutError',
43-
'ExecHelper',
44-
'SSHClient',
45-
'SSHAuth',
46-
'Subprocess',
47-
'ExitCodes',
48-
'ExecResult',
38+
"ExecHelperError",
39+
"ExecCalledProcessError",
40+
"CalledProcessError",
41+
"ParallelCallExceptions",
42+
"ParallelCallProcessError",
43+
"ExecHelperTimeoutError",
44+
"ExecHelper",
45+
"SSHClient",
46+
"SshExecuteAsyncResult",
47+
"SSHAuth",
48+
"Subprocess",
49+
"SubprocessExecuteAsyncResult",
50+
"ExitCodes",
51+
"ExecResult",
4952
)
5053

51-
__version__ = '1.3.8'
54+
__version__ = "1.4.0"
5255
__author__ = "Alexey Stepanov"
53-
__author_email__ = 'penguinolog@gmail.com'
56+
__author_email__ = "penguinolog@gmail.com"
5457
__maintainers__ = {
55-
'Alexey Stepanov': 'penguinolog@gmail.com',
56-
'Antonio Esposito': 'esposito.cloud@gmail.com',
57-
'Dennis Dmitriev': 'dis-xcom@gmail.com',
58+
"Alexey Stepanov": "penguinolog@gmail.com",
59+
"Antonio Esposito": "esposito.cloud@gmail.com",
60+
"Dennis Dmitriev": "dis-xcom@gmail.com",
5861
}
59-
__url__ = 'https://github.com/python-useful-helpers/exec-helpers'
60-
__description__ = (
61-
"Execution helpers for simplified usage of subprocess and ssh."
62-
)
62+
__url__ = "https://github.com/python-useful-helpers/exec-helpers"
63+
__description__ = "Execution helpers for simplified usage of subprocess and ssh."
6364
__license__ = "Apache License, Version 2.0"

exec_helpers/_log_templates.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
CMD_WAIT_ERROR = (
2626
"Wait for {result.cmd!r} during {timeout!s}s: no return code!\n"
27-
'\tSTDOUT:\n'
28-
'{result.stdout_brief}\n'
29-
'\tSTDERR"\n'
30-
'{result.stderr_brief}'
27+
"\tSTDOUT:\n"
28+
"{result.stdout_brief}\n"
29+
"\tSTDERR:\n"
30+
"{result.stderr_brief}"
3131
)

0 commit comments

Comments
 (0)