1
0
Fork 0

Print distro in doctor output (#19633)

This commit is contained in:
Joel Challis 2023-01-19 10:25:47 +00:00 committed by GitHub
parent 3723c0e3d5
commit 4973950ddc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 8 deletions

View file

@ -158,3 +158,21 @@ def is_executable(command):
cli.log.error("{fg_red}Can't run `%s %s`", command, version_arg)
return False
def release_info(file='/etc/os-release'):
"""Parse release info to dict
"""
ret = {}
try:
with open(file) as f:
for line in f:
if '=' in line:
key, value = map(str.strip, line.split('=', 1))
if value.startswith('"') and value.endswith('"'):
value = value[1:-1]
ret[key] = value
except (PermissionError, FileNotFoundError):
pass
return ret