Display prompt for caution only if it is an interactive shell.

Created to fix https://code.google.com/p/skia/issues/detail?id=1197 : Skia Commit Queue quits if the tree is in Caution.

(SkipBuildbotRuns)
Review URL: https://codereview.chromium.org/13325002

git-svn-id: http://skia.googlecode.com/svn/trunk@8446 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index ddac74a..323bba9 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -9,6 +9,9 @@
 for more details about the presubmit API built into gcl.
 """
 
+import os
+import sys
+
 
 def _CheckChangeHasEol(input_api, output_api, source_file_filter=None):
   """Checks that files end with atleast one \n (LF)."""
@@ -67,7 +70,11 @@
     connection = input_api.urllib2.urlopen(json_url)
     status = input_api.json.loads(connection.read())
     connection.close()
-    if 'caution' in status['message'].lower():
+    if ('caution' in status['message'].lower() and
+        os.isatty(sys.stdout.fileno())):
+      # Display a prompt only if we are in an interactive shell. Without this
+      # check the commit queue behaves incorrectly because it considers
+      # prompts to be failures.
       short_text = 'Tree state is: ' + status['general_state']
       long_text = status['message'] + '\n' + json_url
       tree_status_results.append(