summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2013-05-17 16:56:00 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2013-05-17 16:56:00 -0700
commit8f37817ae161d5ab75381a130d6989b5bc4b62e8 (patch)
treeac084713fe0e056c2c14703c30272d2126d3e960
parent57ef3b8a807dc79b234cb0bd5cfad1676d5e4ee4 (diff)
downloadspack-8f37817ae161d5ab75381a130d6989b5bc4b62e8.tar.gz
spack-8f37817ae161d5ab75381a130d6989b5bc4b62e8.tar.bz2
spack-8f37817ae161d5ab75381a130d6989b5bc4b62e8.tar.xz
spack-8f37817ae161d5ab75381a130d6989b5bc4b62e8.zip
Better error messages for spack list -v.
-rw-r--r--lib/spack/spack/cmd/list.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/spack/spack/cmd/list.py b/lib/spack/spack/cmd/list.py
index c6f9e4d951..49ba7a113d 100644
--- a/lib/spack/spack/cmd/list.py
+++ b/lib/spack/spack/cmd/list.py
@@ -1,5 +1,6 @@
import os
import re
+from subprocess import CalledProcessError
import spack
import spack.packages as packages
@@ -32,26 +33,29 @@ def list(parser, args):
elif args.version_package:
pkg = packages.get(args.version_package)
+ # Run curl but grab the mime type from the http headers
try:
- # Run curl but grab the mime type from the http headers
listing = spack.curl('-s', '-L', pkg.list_url, return_output=True)
- url_regex = os.path.basename(url.wildcard_version(pkg.url))
- strings = re.findall(url_regex, listing)
-
- versions = []
- wildcard = pkg.version.wildcard()
- for s in strings:
- match = re.search(wildcard, s)
- if match:
- versions.append(ver(match.group(0)))
-
- colify(str(v) for v in reversed(sorted(set(versions))))
-
- except:
- tty.die("Listing versions for %s failed" % pkg.name,
+ except CalledProcessError:
+ tty.die("Fetching %s failed." % pkg.list_url,
+ "'list -v' requires an internet connection.")
+
+ url_regex = os.path.basename(url.wildcard_version(pkg.url))
+ strings = re.findall(url_regex, listing)
+
+ versions = []
+ wildcard = pkg.version.wildcard()
+ for s in strings:
+ match = re.search(wildcard, s)
+ if match:
+ versions.append(ver(match.group(0)))
+
+ if not versions:
+ tty.die("Found no versions for %s" % pkg.name,
"Listing versions is experimental. You may need to add the list_url",
"attribute to the package to tell Spack where to look for versions.")
- raise
+
+ colify(str(v) for v in reversed(sorted(set(versions))))
else:
colify(packages.all_package_names())