Skip to content

Commit 63d8031

Browse files
mihawk90RytoEX
authored andcommitted
linux: Log missing /etc/os-release file
1 parent 508898f commit 63d8031

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

checks/linux.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@ def checkDistro(lines):
5151
distro = isDistroNix[0].split()
5252
distro = distro[2:]
5353
distro = ' '.join(distro)
54+
distroHelp = ''
5455

55-
return [LEVEL_INFO, distro, ""]
56+
# this is logged when the file can't be found at all
57+
if distro == 'Missing /etc/os-release !':
58+
distro = '(Missing)'
59+
distroHelp = 'No distribution detected. This can lead to undefined behavior. Please consult your distribution\'s support channels on how to fix this.<br>'
60+
61+
return [LEVEL_INFO, distro, distroHelp]
5662

5763

5864
def checkFlatpak(lines):
@@ -178,12 +184,12 @@ def checkLinuxVCam(lines):
178184

179185

180186
def checkLinuxSystemInfo(lines):
181-
if checkFlatpak(lines):
187+
if flatpak := checkFlatpak(lines):
182188
linuxDistroOrFlatpak = 'Flatpak'
183-
linuxSystemInfoHelp = checkFlatpak(lines)[2] + '<br>'
184-
elif checkDistro(lines):
185-
linuxDistroOrFlatpak = 'Distribution: ' + checkDistro(lines)[1]
186-
linuxSystemInfoHelp = ''
189+
linuxSystemInfoHelp = flatpak[2] + '<br>'
190+
elif distro := checkDistro(lines):
191+
linuxDistroOrFlatpak = 'Distribution: ' + distro[1]
192+
linuxSystemInfoHelp = distro[2]
187193
else:
188194
return
189195

@@ -194,13 +200,13 @@ def checkLinuxSystemInfo(lines):
194200
else:
195201
# can happen with misconfigured or virtual systems
196202
displayServer = '⚠️ None'
197-
linuxSystemInfoHelp += 'No Display Server detected. This can lead to undefined behaviour. Please consult your Desktop Environment\'s or Window Manager\'s support channels on how to fix this.<br>'
203+
linuxSystemInfoHelp += 'No Display Server detected. This can lead to undefined behavior. Please consult your Desktop Environment\'s or Window Manager\'s support channels on how to fix this.<br>'
198204

199205
if checkDesktopEnvironment(lines):
200206
desktopEnvironment = 'DE: ' + checkDesktopEnvironment(lines)[1]
201207
else:
202208
# can happen for some misconfigured tiling window managers
203209
desktopEnvironment = 'DE: ⚠️ None'
204-
linuxSystemInfoHelp += 'No Desktop Environment detected. This can lead to undefined behaviour. Please consult your Desktop Environment\'s or Window Manager\'s support channels on how to fix this.'
210+
linuxSystemInfoHelp += 'No Desktop Environment detected. This can lead to undefined behavior. Please consult your Desktop Environment\'s or Window Manager\'s support channels on how to fix this.'
205211

206212
return [LEVEL_INFO, linuxDistroOrFlatpak + ' | ' + displayServer + ' | ' + desktopEnvironment, linuxSystemInfoHelp]

0 commit comments

Comments
 (0)