Fix #113: add timeout passthru to exec_command
This commit is contained in:
parent
10c51e2726
commit
2403504b44
7
NEWS
7
NEWS
|
@ -12,6 +12,13 @@ Issues noted as "Fabric #NN" can be found at https://github.com/fabric/fabric/.
|
||||||
Releases
|
Releases
|
||||||
========
|
========
|
||||||
|
|
||||||
|
v1.10.0 (DD MM YYYY)
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
* #113: Add `timeout` parameter to `SSHClient.exec_command` for easier setting
|
||||||
|
of the command's internal channel object's timeout. Thanks to Cernov Vladimir
|
||||||
|
for the patch.
|
||||||
|
|
||||||
v1.9.0 (6th Nov 2012)
|
v1.9.0 (6th Nov 2012)
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|
|
@ -350,7 +350,7 @@ class SSHClient (object):
|
||||||
self._agent.close()
|
self._agent.close()
|
||||||
self._agent = None
|
self._agent = None
|
||||||
|
|
||||||
def exec_command(self, command, bufsize=-1):
|
def exec_command(self, command, bufsize=-1, timeout=None):
|
||||||
"""
|
"""
|
||||||
Execute a command on the SSH server. A new L{Channel} is opened and
|
Execute a command on the SSH server. A new L{Channel} is opened and
|
||||||
the requested command is executed. The command's input and output
|
the requested command is executed. The command's input and output
|
||||||
|
@ -361,12 +361,15 @@ class SSHClient (object):
|
||||||
@type command: str
|
@type command: str
|
||||||
@param bufsize: interpreted the same way as by the built-in C{file()} function in python
|
@param bufsize: interpreted the same way as by the built-in C{file()} function in python
|
||||||
@type bufsize: int
|
@type bufsize: int
|
||||||
|
@param timeout: set command's channel timeout. See L{Channel.settimeout}.settimeout
|
||||||
|
@type timeout: int
|
||||||
@return: the stdin, stdout, and stderr of the executing command
|
@return: the stdin, stdout, and stderr of the executing command
|
||||||
@rtype: tuple(L{ChannelFile}, L{ChannelFile}, L{ChannelFile})
|
@rtype: tuple(L{ChannelFile}, L{ChannelFile}, L{ChannelFile})
|
||||||
|
|
||||||
@raise SSHException: if the server fails to execute the command
|
@raise SSHException: if the server fails to execute the command
|
||||||
"""
|
"""
|
||||||
chan = self._transport.open_session()
|
chan = self._transport.open_session()
|
||||||
|
chan.settimeout(timeout)
|
||||||
chan.exec_command(command)
|
chan.exec_command(command)
|
||||||
stdin = chan.makefile('wb', bufsize)
|
stdin = chan.makefile('wb', bufsize)
|
||||||
stdout = chan.makefile('rb', bufsize)
|
stdout = chan.makefile('rb', bufsize)
|
||||||
|
|
Loading…
Reference in New Issue