Switch QA to tty-less mode
authorIustin Pop <iustin@google.com>
Fri, 1 Jun 2012 15:41:22 +0000 (17:41 +0200)
committerIustin Pop <iustin@google.com>
Tue, 5 Jun 2012 13:42:59 +0000 (15:42 +0200)
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

index 7330cbc..bf4f226 100644 (file)
@@ -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.
 
   """