mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-08-01 11:18:09 -07:00
>=Elogind-255.22 now has org.freedesktop.hostname1 but is still missing
OperatingSystemCPEName. Deal with this by having both inside the
try/except statement.
See-Also: 1d4d1949ad
Signed-off-by: Alfred Wingate <parona@protonmail.com>
Part-of: https://codeberg.org/gentoo/gentoo/pulls/666
Merges: https://codeberg.org/gentoo/gentoo/pulls/666
Signed-off-by: Michał Górny <mgorny@gentoo.org>
33 lines
1.3 KiB
Diff
33 lines
1.3 KiB
Diff
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
|
|
|