Make distro more robust to unreadable files (#3110)
* Make distro more robust to unreadable files. Will upstream * Comment for clarify
This commit is contained in:
parent
f1ca79ba6c
commit
f9e3b58d7e
19
lib/spack/external/distro.py
vendored
19
lib/spack/external/distro.py
vendored
@ -993,13 +993,18 @@ def _get_distro_release_info(self):
|
|||||||
continue
|
continue
|
||||||
match = _DISTRO_RELEASE_BASENAME_PATTERN.match(basename)
|
match = _DISTRO_RELEASE_BASENAME_PATTERN.match(basename)
|
||||||
if match:
|
if match:
|
||||||
filepath = os.path.join(_UNIXCONFDIR, basename)
|
try:
|
||||||
distro_info = self._parse_distro_release_file(filepath)
|
filepath = os.path.join(_UNIXCONFDIR, basename)
|
||||||
if 'name' in distro_info:
|
distro_info = self._parse_distro_release_file(filepath)
|
||||||
# The name is always present if the pattern matches
|
if 'name' in distro_info:
|
||||||
self.distro_release_file = filepath
|
# The name is always present if the pattern matches
|
||||||
distro_info['id'] = match.group(1)
|
self.distro_release_file = filepath
|
||||||
return distro_info
|
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 {}
|
return {}
|
||||||
|
|
||||||
def _parse_distro_release_file(self, filepath):
|
def _parse_distro_release_file(self, filepath):
|
||||||
|
Loading…
Reference in New Issue
Block a user