summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorbecker33 <becker33@llnl.gov>2017-02-10 10:23:04 -0800
committerGitHub <noreply@github.com>2017-02-10 10:23:04 -0800
commitf9e3b58d7ec2190cdb517ff89ca82019b8eb78da (patch)
treefee8c516cd0660974f99ab24237918875ea7bef7 /lib
parentf1ca79ba6c4217744f2804e8392f7f0e3216e8ca (diff)
downloadspack-f9e3b58d7ec2190cdb517ff89ca82019b8eb78da.tar.gz
spack-f9e3b58d7ec2190cdb517ff89ca82019b8eb78da.tar.bz2
spack-f9e3b58d7ec2190cdb517ff89ca82019b8eb78da.tar.xz
spack-f9e3b58d7ec2190cdb517ff89ca82019b8eb78da.zip
Make distro more robust to unreadable files (#3110)
* Make distro more robust to unreadable files. Will upstream * Comment for clarify
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/external/distro.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/spack/external/distro.py b/lib/spack/external/distro.py
index ca25339ec9..c4905c25a5 100644
--- a/lib/spack/external/distro.py
+++ b/lib/spack/external/distro.py
@@ -993,13 +993,18 @@ class LinuxDistribution(object):
continue
match = _DISTRO_RELEASE_BASENAME_PATTERN.match(basename)
if match:
- filepath = os.path.join(_UNIXCONFDIR, basename)
- distro_info = self._parse_distro_release_file(filepath)
- if 'name' in distro_info:
- # The name is always present if the pattern matches
- self.distro_release_file = filepath
- distro_info['id'] = match.group(1)
- return distro_info
+ try:
+ filepath = os.path.join(_UNIXCONFDIR, basename)
+ distro_info = self._parse_distro_release_file(filepath)
+ if 'name' in distro_info:
+ # The name is always present if the pattern matches
+ self.distro_release_file = filepath
+ distro_info['id'] = match.group(1)
+ return distro_info
+ except IOError:
+ # We found a file we do not have permission to read
+ # Continue checking candidate files for distro file.
+ continue
return {}
def _parse_distro_release_file(self, filepath):