Skip to content
Snippets Groups Projects
Commit 50265802 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Make it possible to disable tty in qa_utils.GetCommandOutput


The tty can have strange side effect as it seems to replace \n with
\r\n. In case of simply catting a file and compare it's output this
will break. This patch adds the possibility to disable tty if needed.

Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent c957326e
No related branches found
No related tags found
No related merge requests found
......@@ -148,7 +148,7 @@ def AssertCommand(cmd, fail=False, node=None):
return rcode
def GetSSHCommand(node, cmd, strict=True, opts=None):
def GetSSHCommand(node, cmd, strict=True, opts=None, tty=True):
"""Builds SSH command to be executed.
@type node: string
......@@ -160,9 +160,14 @@ def GetSSHCommand(node, cmd, strict=True, opts=None):
@param strict: whether to enable strict host key checking
@type opts: list
@param opts: list of additional options
@type tty: Bool
@param tty: If we should use tty
"""
args = [ 'ssh', '-oEscapeChar=none', '-oBatchMode=yes', '-l', 'root', '-t' ]
args = ["ssh", "-oEscapeChar=none", "-oBatchMode=yes", "-l", "root"]
if tty:
args.append("-t")
if strict:
tmp = 'yes'
......@@ -227,11 +232,12 @@ def CloseMultiplexers():
utils.RemoveFile(sname)
def GetCommandOutput(node, cmd):
def GetCommandOutput(node, cmd, tty=True):
"""Returns the output of a command executed on the given node.
"""
p = StartLocalCommand(GetSSHCommand(node, cmd), stdout=subprocess.PIPE)
p = StartLocalCommand(GetSSHCommand(node, cmd, tty=tty),
stdout=subprocess.PIPE)
AssertEqual(p.wait(), 0)
return p.stdout.read()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment