Skip to content

Commit 4c6531c

Browse files
authored
Merge pull request #7 from cloudlinux/py38-compatible-linux-distro
Fix #6 Python 3.8 compatible Linux distribution name detection
2 parents 562acde + 1eb5693 commit 4c6531c

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

uchecker.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import json
3232
import struct
3333
import logging
34-
import platform
3534

3635
from collections import namedtuple
3736

@@ -56,7 +55,20 @@
5655
logging.basicConfig(level=LOGLEVEL, format='%(message)s')
5756

5857

59-
DIST, _, _ = platform.linux_distribution()
58+
def linux_distribution():
59+
distro_id = 'Unknown'
60+
distro_version_id = ''
61+
with open('/etc/os-release') as fd:
62+
for line in fd:
63+
name, _, value = line.partition('=')
64+
if name == 'ID':
65+
distro_id = value.strip().strip('"')
66+
elif name == 'VERSION_ID':
67+
distro_version_id = value.strip().strip('"')
68+
return distro_id + distro_version_id
69+
70+
71+
DIST = linux_distribution()
6072
DATA = json.load(urlopen(USERSPACE_JSON))
6173
KCPLUS_DATA = json.load(urlopen(KCARE_PLUS_JSON))
6274

@@ -261,6 +273,7 @@ def is_up_to_date(libname, build_id):
261273

262274
def main():
263275
failed = False
276+
logging.info("Distro detected: %s", DIST)
264277
for pid, libname, build_id in iter_proc_lib():
265278
comm = get_comm(pid)
266279
logging.info("For %s[%s] `%s` was found with buid id = %s",

0 commit comments

Comments
 (0)