Skip to content

Commit fb76879

Browse files
committed
Expose execute/check_call/check_stderr/__call__ **kwargs for sync code
1 parent 89ea863 commit fb76879

File tree

6 files changed

+652
-54
lines changed

6 files changed

+652
-54
lines changed

doc/source/SSHClient.rst

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ API: SSHClient and SSHAuth.
150150
.. Note:: Enter and exit ssh context manager is produced as well.
151151
.. versionadded:: 1.2.1
152152

153-
.. py:method:: execute(command, verbose=False, timeout=1*60*60, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, **kwargs)
153+
.. py:method:: execute(command, verbose=False, timeout=1*60*60, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, get_pty=False, width=80, height=24, **kwargs)
154154
155155
Execute command and wait for return code.
156156

@@ -168,12 +168,18 @@ API: SSHClient and SSHAuth.
168168
:type open_stdout: ``bool``
169169
:param open_stderr: open STDERR stream for read
170170
:type open_stderr: ``bool``
171+
:param get_pty: Get PTY for connection
172+
:type get_pty: ``bool``
173+
:param width: PTY width
174+
:type width: ``int``
175+
:param height: PTY height
176+
:type height: ``int``
171177
:rtype: ExecResult
172178
:raises ExecHelperTimeoutError: Timeout exceeded
173179

174180
.. versionchanged:: 1.2.0 default timeout 1 hour
175181

176-
.. py:method:: __call__(command, verbose=False, timeout=1*60*60, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, **kwargs)
182+
.. py:method:: __call__(command, verbose=False, timeout=1*60*60, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, get_pty=False, width=80, height=24, **kwargs)
177183
178184
Execute command and wait for return code.
179185

@@ -191,12 +197,18 @@ API: SSHClient and SSHAuth.
191197
:type open_stdout: ``bool``
192198
:param open_stderr: open STDERR stream for read
193199
:type open_stderr: ``bool``
200+
:param get_pty: Get PTY for connection
201+
:type get_pty: ``bool``
202+
:param width: PTY width
203+
:type width: ``int``
204+
:param height: PTY height
205+
:type height: ``int``
194206
:rtype: ExecResult
195207
:raises ExecHelperTimeoutError: Timeout exceeded
196208

197209
.. versionadded:: 3.3.0
198210

199-
.. py:method:: check_call(command, verbose=False, timeout=1*60*60, error_info=None, expected=(0,), raise_on_err=True, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, exception_class=CalledProcessError, **kwargs)
211+
.. py:method:: check_call(command, verbose=False, timeout=1*60*60, error_info=None, expected=(0,), raise_on_err=True, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, get_pty=False, width=80, height=24, exception_class=CalledProcessError, **kwargs)
200212
201213
Execute command and check for return code.
202214

@@ -220,6 +232,12 @@ API: SSHClient and SSHAuth.
220232
:type open_stdout: ``bool``
221233
:param open_stderr: open STDERR stream for read
222234
:type open_stderr: ``bool``
235+
:param get_pty: Get PTY for connection
236+
:type get_pty: ``bool``
237+
:param width: PTY width
238+
:type width: ``int``
239+
:param height: PTY height
240+
:type height: ``int``
223241
:param exception_class: Exception class for errors. Subclass of CalledProcessError is mandatory.
224242
:type exception_class: typing.Type[CalledProcessError]
225243
:rtype: ExecResult
@@ -230,7 +248,7 @@ API: SSHClient and SSHAuth.
230248
.. versionchanged:: 3.2.0 Exception class can be substituted
231249
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
232250

233-
.. py:method:: check_stderr(command, verbose=False, timeout=1*60*60, error_info=None, raise_on_err=True, *, expected=(0,), log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, exception_class=CalledProcessError, **kwargs)
251+
.. py:method:: check_stderr(command, verbose=False, timeout=1*60*60, error_info=None, raise_on_err=True, *, expected=(0,), log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, get_pty=False, width=80, height=24, exception_class=CalledProcessError, **kwargs)
234252
235253
Execute command expecting return code 0 and empty STDERR.
236254

@@ -254,6 +272,12 @@ API: SSHClient and SSHAuth.
254272
:type open_stdout: ``bool``
255273
:param open_stderr: open STDERR stream for read
256274
:type open_stderr: ``bool``
275+
:param get_pty: Get PTY for connection
276+
:type get_pty: ``bool``
277+
:param width: PTY width
278+
:type width: ``int``
279+
:param height: PTY height
280+
:type height: ``int``
257281
:param exception_class: Exception class for errors. Subclass of CalledProcessError is mandatory.
258282
:type exception_class: typing.Type[CalledProcessError]
259283
:rtype: ExecResult

doc/source/Subprocess.rst

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ API: Subprocess
5555
.. Note:: Enter and exit main context manager is produced as well.
5656
.. versionadded:: 4.1.0
5757

58-
.. py:method:: execute(command, verbose=False, timeout=1*60*60, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, **kwargs)
58+
.. py:method:: execute(command, verbose=False, timeout=1*60*60, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, cwd=None, env=None, **kwargs)
5959
6060
Execute command and wait for return code.
6161

@@ -71,9 +71,13 @@ API: Subprocess
7171
:param stdin: pass STDIN text to the process
7272
:type stdin: ``typing.Union[bytes, str, bytearray, None]``
7373
:param open_stdout: open STDOUT stream for read
74-
:type open_stdout: bool
74+
:type open_stdout: ``bool``
7575
:param open_stderr: open STDERR stream for read
76-
:type open_stderr: bool
76+
:type open_stderr: ``bool``
77+
:param cwd: Sets the current directory before the child is executed.
78+
:type cwd: ``typing.Optional[typing.Union[str, bytes]]``
79+
:param env: Defines the environment variables for the new process.
80+
:type env: ``typing.Optional[typing.Mapping[typing.Union[str, bytes], typing.Union[str, bytes]]]``
7781
:rtype: ExecResult
7882
:raises ExecHelperTimeoutError: Timeout exceeded
7983

@@ -83,7 +87,7 @@ API: Subprocess
8387
.. versionchanged:: 1.2.0 default timeout 1 hour
8488
.. versionchanged:: 1.2.0 stdin data
8589

86-
.. py:method:: __call__(command, verbose=False, timeout=1*60*60, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, **kwargs)
90+
.. py:method:: __call__(command, verbose=False, timeout=1*60*60, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, cwd=None, env=None, **kwargs)
8791
8892
Execute command and wait for return code.
8993

@@ -99,16 +103,20 @@ API: Subprocess
99103
:param stdin: pass STDIN text to the process
100104
:type stdin: ``typing.Union[bytes, str, bytearray, None]``
101105
:param open_stdout: open STDOUT stream for read
102-
:type open_stdout: bool
106+
:type open_stdout: ``bool``
103107
:param open_stderr: open STDERR stream for read
104-
:type open_stderr: bool
108+
:type open_stderr: ``bool``
109+
:param cwd: Sets the current directory before the child is executed.
110+
:type cwd: ``typing.Optional[typing.Union[str, bytes]]``
111+
:param env: Defines the environment variables for the new process.
112+
:type env: ``typing.Optional[typing.Mapping[typing.Union[str, bytes], typing.Union[str, bytes]]]``
105113
:rtype: ExecResult
106114
:raises ExecHelperTimeoutError: Timeout exceeded
107115

108116
.. note:: stdin channel is closed after the input processing
109117
.. versionadded:: 3.3.0
110118

111-
.. py:method:: check_call(command, verbose=False, timeout=1*60*60, error_info=None, expected=(0,), raise_on_err=True, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, exception_class=CalledProcessError, **kwargs)
119+
.. py:method:: check_call(command, verbose=False, timeout=1*60*60, error_info=None, expected=(0,), raise_on_err=True, *, log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, cwd=None, env=None, exception_class=CalledProcessError, **kwargs)
112120
113121
Execute command and check for return code.
114122

@@ -133,6 +141,10 @@ API: Subprocess
133141
:type open_stdout: ``bool``
134142
:param open_stderr: open STDERR stream for read
135143
:type open_stderr: ``bool``
144+
:param cwd: Sets the current directory before the child is executed.
145+
:type cwd: ``typing.Optional[typing.Union[str, bytes]]``
146+
:param env: Defines the environment variables for the new process.
147+
:type env: ``typing.Optional[typing.Mapping[typing.Union[str, bytes], typing.Union[str, bytes]]]``
136148
:param exception_class: Exception class for errors. Subclass of CalledProcessError is mandatory.
137149
:type exception_class: typing.Type[CalledProcessError]
138150
:rtype: ExecResult
@@ -144,7 +156,7 @@ API: Subprocess
144156
.. versionchanged:: 3.2.0 Exception class can be substituted
145157
.. versionchanged:: 3.4.0 Expected is not optional, defaults os dependent
146158

147-
.. py:method:: check_stderr(command, verbose=False, timeout=1*60*60, error_info=None, raise_on_err=True, *, expected=(0,), log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, exception_class=CalledProcessError, **kwargs)
159+
.. py:method:: check_stderr(command, verbose=False, timeout=1*60*60, error_info=None, raise_on_err=True, *, expected=(0,), log_mask_re=None, stdin=None, open_stdout=True, open_stderr=True, cwd=None, env=None, exception_class=CalledProcessError, **kwargs)
148160
149161
Execute command expecting return code 0 and empty STDERR.
150162

@@ -169,6 +181,10 @@ API: Subprocess
169181
:type open_stdout: ``bool``
170182
:param open_stderr: open STDERR stream for read
171183
:type open_stderr: ``bool``
184+
:param cwd: Sets the current directory before the child is executed.
185+
:type cwd: ``typing.Optional[typing.Union[str, bytes]]``
186+
:param env: Defines the environment variables for the new process.
187+
:type env: ``typing.Optional[typing.Mapping[typing.Union[str, bytes], typing.Union[str, bytes]]]``
172188
:param exception_class: Exception class for errors. Subclass of CalledProcessError is mandatory.
173189
:type exception_class: typing.Type[CalledProcessError]
174190
:rtype: ExecResult

0 commit comments

Comments
 (0)