python/sepolicy: Use distro module to get os version
distro module uses /etc/os-release file which contains operating system identification data, see os-release(5). Given that the mechanism doesn't use `rpm` it should be possible to generate man pages on other distributions. Signed-off-by: Petr Lautrbach <lautrbach@redhat.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
7fd9628dd4
commit
3ea0947f1e
1 changed files with 6 additions and 19 deletions
|
@ -1226,27 +1226,14 @@ def boolean_desc(boolean):
|
|||
|
||||
|
||||
def get_os_version():
|
||||
os_version = ""
|
||||
pkg_name = "selinux-policy"
|
||||
system_release = ""
|
||||
try:
|
||||
try:
|
||||
from commands import getstatusoutput
|
||||
except ImportError:
|
||||
from subprocess import getstatusoutput
|
||||
rc, output = getstatusoutput("rpm -q '%s'" % pkg_name)
|
||||
if rc == 0:
|
||||
os_version = output.split(".")[-2]
|
||||
except:
|
||||
os_version = ""
|
||||
import distro
|
||||
system_release = distro.name(pretty=True)
|
||||
except IOError:
|
||||
system_release = "Misc"
|
||||
|
||||
if os_version[0:2] == "fc":
|
||||
os_version = "Fedora" + os_version[2:]
|
||||
elif os_version[0:2] == "el":
|
||||
os_version = "RHEL" + os_version[2:]
|
||||
else:
|
||||
os_version = ""
|
||||
|
||||
return os_version
|
||||
return system_release
|
||||
|
||||
|
||||
def reinit():
|
||||
|
|
Loading…
Reference in a new issue