Better error messages for spack list -v.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from subprocess import CalledProcessError
|
||||||
|
|
||||||
import spack
|
import spack
|
||||||
import spack.packages as packages
|
import spack.packages as packages
|
||||||
@@ -32,9 +33,13 @@ def list(parser, args):
|
|||||||
elif args.version_package:
|
elif args.version_package:
|
||||||
pkg = packages.get(args.version_package)
|
pkg = packages.get(args.version_package)
|
||||||
|
|
||||||
try:
|
|
||||||
# Run curl but grab the mime type from the http headers
|
# Run curl but grab the mime type from the http headers
|
||||||
|
try:
|
||||||
listing = spack.curl('-s', '-L', pkg.list_url, return_output=True)
|
listing = spack.curl('-s', '-L', pkg.list_url, return_output=True)
|
||||||
|
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))
|
url_regex = os.path.basename(url.wildcard_version(pkg.url))
|
||||||
strings = re.findall(url_regex, listing)
|
strings = re.findall(url_regex, listing)
|
||||||
|
|
||||||
@@ -45,13 +50,12 @@ def list(parser, args):
|
|||||||
if match:
|
if match:
|
||||||
versions.append(ver(match.group(0)))
|
versions.append(ver(match.group(0)))
|
||||||
|
|
||||||
colify(str(v) for v in reversed(sorted(set(versions))))
|
if not versions:
|
||||||
|
tty.die("Found no versions for %s" % pkg.name,
|
||||||
except:
|
|
||||||
tty.die("Listing versions for %s failed" % pkg.name,
|
|
||||||
"Listing versions is experimental. You may need to add the list_url",
|
"Listing versions is experimental. You may need to add the list_url",
|
||||||
"attribute to the package to tell Spack where to look for versions.")
|
"attribute to the package to tell Spack where to look for versions.")
|
||||||
raise
|
|
||||||
|
colify(str(v) for v in reversed(sorted(set(versions))))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
colify(packages.all_package_names())
|
colify(packages.all_package_names())
|
||||||
|
Reference in New Issue
Block a user