Skip to content

Commit b3a3f19

Browse files
authored
Exposed get_pty parameter (#147)
For use with commands that require a pseudo-terminal to run without exceptions (like certain windows powershell commands)
1 parent 6d258ff commit b3a3f19

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

rrmngmnt/ssh.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ def _update_timeout_exception(self, ex, timeout=None):
127127
def command(self, cmd):
128128
return RemoteExecutor.Command(cmd, self)
129129

130-
def run_cmd(self, cmd, input_=None, timeout=None):
130+
def run_cmd(self, cmd, input_=None, timeout=None, get_pty=False):
131131
if self._executor.sudo:
132132
cmd.insert(0, "sudo")
133133

134134
cmd = self.command(cmd)
135-
return cmd.run(input_, timeout)
135+
return cmd.run(input_, timeout, get_pty=get_pty)
136136

137137
@contextlib.contextmanager
138138
def open_file(self, path, mode='r', bufsize=-1):
@@ -245,19 +245,28 @@ def session(self, timeout=None):
245245
"""
246246
return RemoteExecutor.Session(self, timeout)
247247

248-
def run_cmd(self, cmd, input_=None, tcp_timeout=None, io_timeout=None):
248+
def run_cmd(
249+
self,
250+
cmd,
251+
input_=None,
252+
tcp_timeout=None,
253+
io_timeout=None,
254+
get_pty=False
255+
):
249256
"""
250257
Args:
251258
tcp_timeout (float): Tcp timeout
252259
cmd (list): Command
253260
input_ (str): Input data
254261
io_timeout (float): Timeout for data operation (read/write)
262+
get_pty (bool) : get pseudoterminal
263+
(equivalent to passing -t arg to ssh)
255264
256265
Returns:
257266
tuple (int, str, str): Rc, out, err
258267
"""
259268
with self.session(tcp_timeout) as session:
260-
return session.run_cmd(cmd, input_, io_timeout)
269+
return session.run_cmd(cmd, input_, io_timeout, get_pty=get_pty)
261270

262271
def is_connective(self, tcp_timeout=20.0):
263272
"""

0 commit comments

Comments
 (0)