From 14097e39ccc77e03574119eac59524ad2bb60c6f Mon Sep 17 00:00:00 2001
From: Todd Gamblin <tgamblin@llnl.gov>
Date: Tue, 17 Feb 2015 01:28:47 -0800
Subject: [PATCH] Suppress download status meter when routing I/O to a file.

---
 lib/spack/spack/fetch_strategy.py | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index a71f3a1531..48313e2b37 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -41,6 +41,7 @@
         Archive a source directory, e.g. for creating a mirror.
 """
 import os
+import sys
 import re
 import shutil
 from functools import wraps
@@ -141,13 +142,19 @@ def fetch(self):
 
         tty.msg("Trying to fetch from %s" % self.url)
 
+        curl_args = ['-O',        # save file to disk
+                     '-f',        # fail on >400 errors
+                     '-D', '-',   # print out HTML headers
+                     '-L', self.url,]
+
+        if sys.stdout.isatty():
+            curl_args.append('-#')  # status bar when using a tty
+        else:
+            curl_args.append('-sS') # just errors when not.
+
         # Run curl but grab the mime type from the http headers
-        headers = spack.curl('-#',        # status bar
-                             '-O',        # save file to disk
-                             '-f',        # fail on >400 errors
-                             '-D', '-',   # print out HTML headers
-                             '-L', self.url,
-                             return_output=True, fail_on_error=False)
+        headers = spack.curl(
+            *curl_args, return_output=True, fail_on_error=False)
 
         if spack.curl.returncode != 0:
             # clean up archive on failure.
-- 
GitLab