Merge pull request #1 from scalability-llnl/20140121_bug_fixes
bug fixes from Greg Lee
This commit is contained in:
commit
aaf16a339a
@ -26,7 +26,9 @@
|
|||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import spack.tty as tty
|
import spack.tty as tty
|
||||||
|
from spack.error import SpackError
|
||||||
|
|
||||||
|
|
||||||
class Executable(object):
|
class Executable(object):
|
||||||
@ -66,10 +68,13 @@ def __call__(self, *args, **kwargs):
|
|||||||
stderr=sys.stderr,
|
stderr=sys.stderr,
|
||||||
stdout=subprocess.PIPE if return_output else sys.stdout)
|
stdout=subprocess.PIPE if return_output else sys.stdout)
|
||||||
out, err = proc.communicate()
|
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:
|
if return_output:
|
||||||
return out
|
return out
|
||||||
|
|
||||||
except CalledProcessError, e:
|
except subprocess.CalledProcessError, e:
|
||||||
if fail_on_error: raise
|
if fail_on_error: raise
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
"""
|
"""
|
||||||
from spack.util.filesystem import new_path
|
from spack.util.filesystem import new_path
|
||||||
|
|
||||||
class Prefix(object):
|
class Prefix(str):
|
||||||
"""This class represents an installation prefix, but provides useful
|
"""This class represents an installation prefix, but provides useful
|
||||||
attributes for referring to directories inside the prefix.
|
attributes for referring to directories inside the prefix.
|
||||||
|
|
||||||
@ -48,7 +48,8 @@ class Prefix(object):
|
|||||||
/usr/share
|
/usr/share
|
||||||
/usr/share/man/man4
|
/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
|
print "foobar " + prefix
|
||||||
|
|
||||||
@ -56,36 +57,25 @@ class Prefix(object):
|
|||||||
installs easy.
|
installs easy.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, prefix):
|
def __new__(cls, path):
|
||||||
self.prefix = prefix
|
s = super(Prefix, cls).__new__(cls, path)
|
||||||
self.bin = new_path(self.prefix, 'bin')
|
s.bin = new_path(s, 'bin')
|
||||||
self.sbin = new_path(self.prefix, 'sbin')
|
s.sbin = new_path(s, 'sbin')
|
||||||
self.etc = new_path(self.prefix, 'etc')
|
s.etc = new_path(s, 'etc')
|
||||||
self.include = new_path(self.prefix, 'include')
|
s.include = new_path(s, 'include')
|
||||||
self.lib = new_path(self.prefix, 'lib')
|
s.lib = new_path(s, 'lib')
|
||||||
self.lib64 = new_path(self.prefix, 'lib64')
|
s.lib64 = new_path(s, 'lib64')
|
||||||
self.libexec = new_path(self.prefix, 'libexec')
|
s.libexec = new_path(s, 'libexec')
|
||||||
self.share = new_path(self.prefix, 'share')
|
s.share = new_path(s, 'share')
|
||||||
self.doc = new_path(self.share, 'doc')
|
s.doc = new_path(s.share, 'doc')
|
||||||
self.info = new_path(self.share, 'info')
|
s.info = new_path(s.share, 'info')
|
||||||
self.man = new_path(self.share, 'man')
|
s.man = new_path(s.share, 'man')
|
||||||
self.man1 = new_path(self.man, 'man1')
|
s.man1 = new_path(s.man, 'man1')
|
||||||
self.man2 = new_path(self.man, 'man2')
|
s.man2 = new_path(s.man, 'man2')
|
||||||
self.man3 = new_path(self.man, 'man3')
|
s.man3 = new_path(s.man, 'man3')
|
||||||
self.man4 = new_path(self.man, 'man4')
|
s.man4 = new_path(s.man, 'man4')
|
||||||
self.man5 = new_path(self.man, 'man5')
|
s.man5 = new_path(s.man, 'man5')
|
||||||
self.man6 = new_path(self.man, 'man6')
|
s.man6 = new_path(s.man, 'man6')
|
||||||
self.man7 = new_path(self.man, 'man7')
|
s.man7 = new_path(s.man, 'man7')
|
||||||
self.man8 = new_path(self.man, 'man8')
|
s.man8 = new_path(s.man, 'man8')
|
||||||
|
return s
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.prefix
|
|
||||||
|
|
||||||
|
|
||||||
def __add__(self, other):
|
|
||||||
return str(self) + other
|
|
||||||
|
|
||||||
|
|
||||||
def __radd__(self, other):
|
|
||||||
return other + str(self)
|
|
||||||
|
@ -79,6 +79,10 @@ def _spider(args):
|
|||||||
req.get_method = lambda: "HEAD"
|
req.get_method = lambda: "HEAD"
|
||||||
resp = urllib2.urlopen(req, timeout=TIMEOUT)
|
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'):
|
if not resp.headers["Content-type"].startswith('text/html'):
|
||||||
print "ignoring page " + url + " with content type " + resp.headers["Content-type"]
|
print "ignoring page " + url + " with content type " + resp.headers["Content-type"]
|
||||||
return pages
|
return pages
|
||||||
|
Loading…
Reference in New Issue
Block a user