Skip to content

Commit 31c6a01

Browse files
committed
Update docs: expected is not optional
1 parent b14c83f commit 31c6a01

File tree

4 files changed

+65
-32
lines changed

4 files changed

+65
-32
lines changed

doc/source/ExecResult.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ API: ExecResult
1010
1111
Command execution result.
1212

13-
.. py:method:: __init__(cmd, stdin=None, stdout=None, stderr=None, exit_code=ExitCodes.EX_INVALID)
13+
.. py:method:: __init__(cmd, stdin=None, stdout=None, stderr=None, exit_code=0xDEADBEEF)
1414
1515
:param cmd: command
1616
:type cmd: ``str``

doc/source/SSHClient.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ API: SSHClient and SSHAuth.
182182

183183
.. versionadded:: 3.3.0
184184

185-
.. py:method:: check_call(command, verbose=False, timeout=1*60*60, error_info=None, expected=None, raise_on_err=True, *, exception_class=CalledProcessError, **kwargs)
185+
.. py:method:: check_call(command, verbose=False, timeout=1*60*60, error_info=None, expected=(0,), raise_on_err=True, *, exception_class=CalledProcessError, **kwargs)
186186
187187
Execute command and check for return code.
188188

@@ -195,7 +195,7 @@ API: SSHClient and SSHAuth.
195195
:param error_info: Text for error details, if fail happens
196196
:type error_info: ``typing.Optional[str]``
197197
:param expected: expected return codes (0 by default)
198-
:type expected: ``typing.Optional[typing.Iterable[int]]``
198+
:type expected: typing.Iterable[typing.Union[int, ExitCodes]]
199199
:param raise_on_err: Raise exception on unexpected return code
200200
:type raise_on_err: ``bool``
201201
:param exception_class: Exception class for errors. Subclass of CalledProcessError is mandatory.
@@ -206,8 +206,9 @@ API: SSHClient and SSHAuth.
206206

207207
.. versionchanged:: 1.2.0 default timeout 1 hour
208208
.. versionchanged:: 3.2.0 Exception class can be substituted
209+
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
209210

210-
.. py:method:: check_stderr(command, verbose=False, timeout=1*60*60, error_info=None, raise_on_err=True, *, expected=None, exception_class=CalledProcessError, **kwargs)
211+
.. py:method:: check_stderr(command, verbose=False, timeout=1*60*60, error_info=None, raise_on_err=True, *, expected=(0,), exception_class=CalledProcessError, **kwargs)
211212
212213
Execute command expecting return code 0 and empty STDERR.
213214

@@ -222,7 +223,7 @@ API: SSHClient and SSHAuth.
222223
:param raise_on_err: Raise exception on unexpected return code
223224
:type raise_on_err: ``bool``
224225
:param expected: expected return codes (0 by default)
225-
:type expected: typing.Optional[typing.Iterable[typing.Union[int, ExitCodes]]]
226+
:type expected: typing.Iterable[typing.Union[int, ExitCodes]]
226227
:param exception_class: Exception class for errors. Subclass of CalledProcessError is mandatory.
227228
:type exception_class: typing.Type[CalledProcessError]
228229
:rtype: ExecResult
@@ -260,8 +261,9 @@ API: SSHClient and SSHAuth.
260261
.. versionchanged:: 1.2.0 default timeout 1 hour
261262
.. versionchanged:: 3.2.0 Expose pty options as optional keyword-only arguments
262263
.. versionchanged:: 3.2.0 Exception class can be substituted
264+
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
263265

264-
.. py:classmethod:: execute_together(remotes, command, timeout=1*60*60, expected=None, raise_on_err=True, *, exception_class=ParallelCallProcessError, **kwargs)
266+
.. py:classmethod:: execute_together(remotes, command, timeout=1*60*60, expected=(0,), raise_on_err=True, *, exception_class=ParallelCallProcessError, **kwargs)
265267
266268
Execute command on multiple remotes in async mode.
267269

@@ -272,7 +274,7 @@ API: SSHClient and SSHAuth.
272274
:param timeout: Timeout for command execution.
273275
:type timeout: ``typing.Union[int, float, None]``
274276
:param expected: expected return codes (0 by default)
275-
:type expected: ``typing.Optional[typing.Iterable[]]``
277+
:type expected: typing.Iterable[typing.Union[int, ExitCodes]]
276278
:param raise_on_err: Raise exception on unexpected return code
277279
:type raise_on_err: ``bool``
278280
:param exception_class: Exception to raise on error. Mandatory subclass of ParallelCallProcessError
@@ -284,6 +286,7 @@ API: SSHClient and SSHAuth.
284286

285287
.. versionchanged:: 1.2.0 default timeout 1 hour
286288
.. versionchanged:: 3.2.0 Exception class can be substituted
289+
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
287290

288291
.. py:method:: open(path, mode='r')
289292

doc/source/Subprocess.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ API: Subprocess
106106
.. note:: stdin channel is closed after the input processing
107107
.. versionadded:: 3.3.0
108108

109-
.. py:method:: check_call(command, verbose=False, timeout=1*60*60, error_info=None, expected=None, raise_on_err=True, *, exception_class=CalledProcessError, **kwargs)
109+
.. py:method:: check_call(command, verbose=False, timeout=1*60*60, error_info=None, expected=(0,), raise_on_err=True, *, exception_class=CalledProcessError, **kwargs)
110110
111111
Execute command and check for return code.
112112

@@ -119,7 +119,7 @@ API: Subprocess
119119
:param error_info: Text for error details, if fail happens
120120
:type error_info: ``typing.Optional[str]``
121121
:param expected: expected return codes (0 by default)
122-
:type expected: ``typing.Optional[typing.Iterable[int]]``
122+
:type expected: typing.Iterable[typing.Union[int, ExitCodes]]
123123
:param raise_on_err: Raise exception on unexpected return code
124124
:type raise_on_err: ``bool``
125125
:param exception_class: Exception class for errors. Subclass of CalledProcessError is mandatory.
@@ -131,8 +131,9 @@ API: Subprocess
131131
.. versionchanged:: 1.1.0 make method
132132
.. versionchanged:: 1.2.0 default timeout 1 hour
133133
.. versionchanged:: 3.2.0 Exception class can be substituted
134+
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
134135

135-
.. py:method:: check_stderr(command, verbose=False, timeout=1*60*60, error_info=None, raise_on_err=True, *, expected=None, exception_class=CalledProcessError, **kwargs)
136+
.. py:method:: check_stderr(command, verbose=False, timeout=1*60*60, error_info=None, raise_on_err=True, *, expected=(0,), exception_class=CalledProcessError, **kwargs)
136137
137138
Execute command expecting return code 0 and empty STDERR.
138139

@@ -147,7 +148,7 @@ API: Subprocess
147148
:param raise_on_err: Raise exception on unexpected return code
148149
:type raise_on_err: ``bool``
149150
:param expected: expected return codes (0 by default)
150-
:type expected: typing.Optional[typing.Iterable[typing.Union[int, ExitCodes]]]
151+
:type expected: typing.Iterable[typing.Union[int, ExitCodes]]
151152
:param exception_class: Exception class for errors. Subclass of CalledProcessError is mandatory.
152153
:type exception_class: typing.Type[CalledProcessError]
153154
:rtype: ExecResult
@@ -157,6 +158,7 @@ API: Subprocess
157158
.. versionchanged:: 1.1.0 make method
158159
.. versionchanged:: 1.2.0 default timeout 1 hour
159160
.. versionchanged:: 3.2.0 Exception class can be substituted
161+
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
160162

161163

162164
.. py:class:: SubprocessExecuteAsyncResult

doc/source/exceptions.rst

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,11 @@ API: exceptions
1818
1919
Base class for process call errors.
2020

21-
.. py:exception:: ExecHelperTimeoutError(ExecCalledProcessError)
21+
class ExecHelperTimeoutProcessError(ExecCalledProcessError):
22+
23+
Timeout based errors.
2224

23-
Execution timeout.
24-
25-
.. versionchanged:: 1.3.0 provide full result and timeout inside.
26-
.. versionchanged:: 1.3.0 subclass ExecCalledProcessError
27-
28-
.. py:method:: __init__(self, result, timeout)
29-
30-
Exception for error on process calls.
31-
32-
:param result: execution result
33-
:type result: exec_result.ExecResult
34-
:param timeout: timeout for command
35-
:type timeout: typing.Union[int, float]
25+
.. versionadded:: 3.4.0
3626

3727
.. py:attribute:: timeout
3828
@@ -54,18 +44,54 @@ API: exceptions
5444
``str``
5545
stdout string or brief string
5646

47+
48+
.. py:exception:: ExecHelperNoKillError(ExecHelperTimeoutProcessError)
49+
50+
Impossible to kill process.
51+
52+
.. versionadded:: 3.4.0
53+
54+
.. py:method:: __init__(self, result, timeout)
55+
56+
Exception for error on process calls.
57+
58+
:param result: execution result
59+
:type result: exec_result.ExecResult
60+
:param timeout: timeout for command
61+
:type timeout: typing.Union[int, float]
62+
63+
64+
.. py:exception:: ExecHelperTimeoutError(ExecHelperTimeoutProcessError)
65+
66+
Execution timeout.
67+
68+
.. versionchanged:: 1.3.0 provide full result and timeout inside.
69+
.. versionchanged:: 1.3.0 subclass ExecCalledProcessError
70+
71+
.. py:method:: __init__(self, result, timeout)
72+
73+
Exception for error on process calls.
74+
75+
:param result: execution result
76+
:type result: exec_result.ExecResult
77+
:param timeout: timeout for command
78+
:type timeout: typing.Union[int, float]
79+
80+
5781
.. py:exception:: CalledProcessError(ExecCalledProcessError)
5882
5983
Exception for error on process calls.
6084

6185
.. versionchanged:: 1.1.1 - provide full result
6286

63-
.. py:method:: __init__(result, expected=None)
87+
.. py:method:: __init__(result, expected=(0,))
6488
6589
:param result: execution result
6690
:type result: ExecResult
67-
:param returncode: return code
68-
:type returncode: typing.Union[int, ExitCodes]
91+
:param expected: expected return codes
92+
:type expected: typing.Iterable[typing.Union[int, ExitCodes]]
93+
94+
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
6995

7096
.. py:attribute:: result
7197
@@ -104,7 +130,7 @@ API: exceptions
104130
105131
Exception during parallel execution.
106132

107-
.. py:method:: __init__(command, errors, results, expected=None, )
133+
.. py:method:: __init__(command, errors, results, expected=(0,), )
108134
109135
:param command: command
110136
:type command: ``str``
@@ -113,9 +139,10 @@ API: exceptions
113139
:param results: all results
114140
:type results: typing.Dict[typing.Tuple[str, int], ExecResult]
115141
:param expected: expected return codes
116-
:type expected: typing.Optional[typing.List[typing.List[typing.Union[int, ExitCodes]]]
142+
:type expected: typing.Iterable[typing.Union[int, ExitCodes]]
117143

118144
.. versionchanged:: 1.0 - fixed inheritance
145+
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
119146

120147
.. py:attribute:: cmd
121148
@@ -144,7 +171,7 @@ API: exceptions
144171
145172
Exception raised during parallel call as result of exceptions.
146173

147-
.. py:method:: __init__(command, exceptions, errors, results, expected=None, )
174+
.. py:method:: __init__(command, exceptions, errors, results, expected=(0,), )
148175
149176
:param command: command
150177
:type command: ``str``
@@ -155,9 +182,10 @@ API: exceptions
155182
:param results: all results
156183
:type results: typing.Dict[typing.Tuple[str, int], ExecResult]
157184
:param expected: expected return codes
158-
:type expected: typing.Optional[typing.List[typing.List[typing.Union[int, ExitCodes]]]
185+
:type expected: typing.Iterable[typing.Union[int, ExitCodes]]
159186

160187
.. versionchanged:: 1.0 - fixed inheritance
188+
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
161189

162190
.. py:attribute:: cmd
163191

0 commit comments

Comments
 (0)