summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-01-23 01:31:40 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2014-01-23 01:31:40 -0800
commitaaf16a339a84c8cdf22e6f3fdc35094ad5384b83 (patch)
treea2411c0e73e0758296f137b64588ad59c610460e
parent8f7c92706ff3365f3d45a0ad6fdbaa4a08a9c101 (diff)
parentb4da28f71e2cef84c6e289afe89aa4bdf7936048 (diff)
downloadspack-aaf16a339a84c8cdf22e6f3fdc35094ad5384b83.tar.gz
spack-aaf16a339a84c8cdf22e6f3fdc35094ad5384b83.tar.bz2
spack-aaf16a339a84c8cdf22e6f3fdc35094ad5384b83.tar.xz
spack-aaf16a339a84c8cdf22e6f3fdc35094ad5384b83.zip
Merge pull request #1 from scalability-llnl/20140121_bug_fixes
bug fixes from Greg Lee
-rw-r--r--lib/spack/spack/util/executable.py7
-rw-r--r--lib/spack/spack/util/prefix.py60
-rw-r--r--lib/spack/spack/util/web.py4
3 files changed, 35 insertions, 36 deletions
diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py
index 58c70ed28c..4d5eff0bd8 100644
--- a/lib/spack/spack/util/executable.py
+++ b/lib/spack/spack/util/executable.py
@@ -26,7 +26,9 @@ import os
import sys
import re
import subprocess
+
import spack.tty as tty
+from spack.error import SpackError
class Executable(object):
@@ -66,10 +68,13 @@ class Executable(object):
stderr=sys.stderr,
stdout=subprocess.PIPE if return_output else sys.stdout)
out, err = proc.communicate()
+ if fail_on_error and proc.returncode != 0:
+ raise SpackError("command '%s' returned error code %d"
+ % (" ".join(cmd), proc.returncode))
if return_output:
return out
- except CalledProcessError, e:
+ except subprocess.CalledProcessError, e:
if fail_on_error: raise
def __repr__(self):
diff --git a/lib/spack/spack/util/prefix.py b/lib/spack/spack/util/prefix.py
index 50347a28f7..09a04676f7 100644
--- a/lib/spack/spack/util/prefix.py
+++ b/lib/spack/spack/util/prefix.py
@@ -27,7 +27,7 @@ This file contains utilities to help with installing packages.
"""
from spack.util.filesystem import new_path
-class Prefix(object):
+class Prefix(str):
"""This class represents an installation prefix, but provides useful
attributes for referring to directories inside the prefix.
@@ -48,7 +48,8 @@ class Prefix(object):
/usr/share
/usr/share/man/man4
- In addition, Prefix objects can be added to strings, e.g.:
+ Prefix objects behave identically to strings. In fact, they
+ subclass str. So operators like + are legal:
print "foobar " + prefix
@@ -56,36 +57,25 @@ class Prefix(object):
installs easy.
"""
- def __init__(self, prefix):
- self.prefix = prefix
- self.bin = new_path(self.prefix, 'bin')
- self.sbin = new_path(self.prefix, 'sbin')
- self.etc = new_path(self.prefix, 'etc')
- self.include = new_path(self.prefix, 'include')
- self.lib = new_path(self.prefix, 'lib')
- self.lib64 = new_path(self.prefix, 'lib64')
- self.libexec = new_path(self.prefix, 'libexec')
- self.share = new_path(self.prefix, 'share')
- self.doc = new_path(self.share, 'doc')
- self.info = new_path(self.share, 'info')
- self.man = new_path(self.share, 'man')
- self.man1 = new_path(self.man, 'man1')
- self.man2 = new_path(self.man, 'man2')
- self.man3 = new_path(self.man, 'man3')
- self.man4 = new_path(self.man, 'man4')
- self.man5 = new_path(self.man, 'man5')
- self.man6 = new_path(self.man, 'man6')
- self.man7 = new_path(self.man, 'man7')
- self.man8 = new_path(self.man, 'man8')
-
-
- def __str__(self):
- return self.prefix
-
-
- def __add__(self, other):
- return str(self) + other
-
-
- def __radd__(self, other):
- return other + str(self)
+ def __new__(cls, path):
+ s = super(Prefix, cls).__new__(cls, path)
+ s.bin = new_path(s, 'bin')
+ s.sbin = new_path(s, 'sbin')
+ s.etc = new_path(s, 'etc')
+ s.include = new_path(s, 'include')
+ s.lib = new_path(s, 'lib')
+ s.lib64 = new_path(s, 'lib64')
+ s.libexec = new_path(s, 'libexec')
+ s.share = new_path(s, 'share')
+ s.doc = new_path(s.share, 'doc')
+ s.info = new_path(s.share, 'info')
+ s.man = new_path(s.share, 'man')
+ s.man1 = new_path(s.man, 'man1')
+ s.man2 = new_path(s.man, 'man2')
+ s.man3 = new_path(s.man, 'man3')
+ s.man4 = new_path(s.man, 'man4')
+ s.man5 = new_path(s.man, 'man5')
+ s.man6 = new_path(s.man, 'man6')
+ s.man7 = new_path(s.man, 'man7')
+ s.man8 = new_path(s.man, 'man8')
+ return s
diff --git a/lib/spack/spack/util/web.py b/lib/spack/spack/util/web.py
index db021cc884..82e202aa8f 100644
--- a/lib/spack/spack/util/web.py
+++ b/lib/spack/spack/util/web.py
@@ -79,6 +79,10 @@ def _spider(args):
req.get_method = lambda: "HEAD"
resp = urllib2.urlopen(req, timeout=TIMEOUT)
+ if not "Content-type" in resp.headers:
+ print "ignoring page " + url
+ return pages
+
if not resp.headers["Content-type"].startswith('text/html'):
print "ignoring page " + url + " with content type " + resp.headers["Content-type"]
return pages