Skip to content

Commit 53ed211

Browse files
committed
fix: avoid silent failure when checking /etc/redhat-release
1 parent a3edb9a commit 53ed211

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

Pilot/pilotCommands.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,19 @@ def execute(self):
115115
self.log.info("Host FQDN = %s" % socket.getfqdn())
116116
self.log.info("WorkingDir = %s" % self.pp.workingDir) # this could be different than rootPath
117117

118-
fileName = "/etc/redhat-release"
119-
if os.path.exists(fileName):
120-
with open(fileName, "r") as f:
121-
self.log.info("RedHat Release = %s" % f.read().strip())
122-
123-
fileName = "/etc/lsb-release"
124-
if os.path.isfile(fileName):
125-
with open(fileName, "r") as f:
126-
self.log.info("Linux release:\n%s" % f.read().strip())
118+
for fileName in ["/etc/os-release", "/usr/lib/os-release"]:
119+
if os.path.isfile(fileName):
120+
try:
121+
with open(fileName, "r") as f:
122+
for line in f:
123+
line = line.strip()
124+
if line.startswith(("NAME=", "VERSION=", "PRETTY_NAME=")):
125+
self.log.info(
126+
"OS Release = %s" % line.split("=", 1)[1].strip('"')
127+
)
128+
break
129+
except (OSError, IOError):
130+
self.log.debug("Could not read %s" % fileName)
127131

128132
fileName = "/proc/cpuinfo"
129133
if os.path.exists(fileName):

0 commit comments

Comments
 (0)