blob: 0595c32b3e549823f5b776e5199f69c7a6d142e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
From c05c95ac6d79544ef51b8049f6baa067060706d6 Mon Sep 17 00:00:00 2001
From: Alfred Wingate <parona@protonmail.com>
Date: Mon, 13 Nov 2023 16:21:44 +0200
Subject: [PATCH] Add non-systemd method to get distro name and version
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -597,11 +597,16 @@ def get_version():
""" Try to get distro and version
"""
- bus = dbus.SystemBus()
-
- # get information about the distribution from systemd (hostname1)
- sys_info = bus.get_object("org.freedesktop.hostname1", "/org/freedesktop/hostname1")
- cpe = str(sys_info.Get("org.freedesktop.hostname1", "OperatingSystemCPEName", dbus_interface=dbus.PROPERTIES_IFACE))
+ try:
+ bus = dbus.SystemBus()
+
+ # get information about the distribution from systemd (hostname1)
+ sys_info = bus.get_object("org.freedesktop.hostname1", "/org/freedesktop/hostname1")
+ cpe = str(sys_info.Get("org.freedesktop.hostname1", "OperatingSystemCPEName", dbus_interface=dbus.PROPERTIES_IFACE))
+ except dbus.exceptions.DBusException:
+ import platform
+ info = platform.freedesktop_os_release()
+ return (info["NAME"], info["VERSION_ID"])
if cpe:
# 2nd to 4th fields from e.g. "cpe:/o:fedoraproject:fedora:25" or "cpe:/o:redhat:enterprise_linux:7.3:GA:server"
--
2.53.0
|