From f14a8b15f17dcf40a3f572a28295ff61f9d32264 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 1 Jun 2012 17:41:22 +0200
Subject: [PATCH] Switch QA to tty-less mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This makes ssh generate much less noise when QA is run itself without
a tty, as otherwise we get thousands of lines of:

  Pseudo-terminal will not be allocated because stdin is not a terminal.

in the QA logs (which are already big enough).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 qa/qa_utils.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/qa/qa_utils.py b/qa/qa_utils.py
index 7330cbc86..bf4f2262e 100644
--- a/qa/qa_utils.py
+++ b/qa/qa_utils.py
@@ -191,7 +191,7 @@ def AssertCommand(cmd, fail=False, node=None):
   return rcode
 
 
-def GetSSHCommand(node, cmd, strict=True, opts=None, tty=True):
+def GetSSHCommand(node, cmd, strict=True, opts=None, tty=None):
   """Builds SSH command to be executed.
 
   @type node: string
@@ -203,12 +203,15 @@ def GetSSHCommand(node, cmd, strict=True, opts=None, tty=True):
   @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
+  @type tty: boolean or None
+  @param tty: if we should use tty; if None, will be auto-detected
 
   """
   args = ["ssh", "-oEscapeChar=none", "-oBatchMode=yes", "-l", "root"]
 
+  if tty is None:
+    tty = sys.stdout.isatty()
+
   if tty:
     args.append("-t")
 
@@ -275,7 +278,7 @@ def CloseMultiplexers():
     utils.RemoveFile(sname)
 
 
-def GetCommandOutput(node, cmd, tty=True):
+def GetCommandOutput(node, cmd, tty=None):
   """Returns the output of a command executed on the given node.
 
   """
-- 
GitLab