bug fixes
- Make prefix an actual string so that install doesn't fail. - Executable should throw SpackError on command failure.
This commit is contained in:
		
				
					committed by
					
						
						Todd Gamblin
					
				
			
			
				
	
			
			
			
						parent
						
							8f7c92706f
						
					
				
				
					commit
					b4da28f71e
				
			@@ -26,7 +26,9 @@
 | 
			
		||||
import sys
 | 
			
		||||
import re
 | 
			
		||||
import subprocess
 | 
			
		||||
 | 
			
		||||
import spack.tty as tty
 | 
			
		||||
from spack.error import SpackError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Executable(object):
 | 
			
		||||
@@ -66,10 +68,13 @@ def __call__(self, *args, **kwargs):
 | 
			
		||||
                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):
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@
 | 
			
		||||
"""
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user