import urllib.parse
from . import _pakfire
-from .distro import Distribution
+from . import util
from .constants import *
from .i18n import _
"""
log.info(_("Sending builder information to hub..."))
- # Fetch distribution information
- distro = Distribution()
-
# Fetch processor information
cpu = cpuinfo.get_cpu_info()
# Pakfire + OS
"pakfire_version" : PAKFIRE_VERSION,
- "os_name" : distro.pretty_name,
+ "os_name" : util.get_distro_name(),
}
# Send request
###############################################################################
import os
+import platform
import shutil
+def get_distro_name():
+ """
+ Returns the distro name of the host
+ """
+ try:
+ release = platform.freedesktop_os_release()
+ except AttributeError:
+ release = _read_os_release()
+
+ return release.get("PRETTY_NAME") or release.get("NAME")
+
+def _read_os_release():
+ """
+ This is a simple implementation to read /etc/os-release and /var/lib/os-release
+ """
+ for file in ("/etc/os-release", "/var/lib/os-release"):
+ try:
+ with open(file, "r") as f:
+ release = {}
+
+ for line in f:
+ key, delim, value = line.partition("=")
+
+ release[key] = value
+
+ return release
+ except FileNotFoundError:
+ pass
+
+ raise OSError("Could not find os-release")
+
def rm(path, *args, **kargs):
"""
version of shutil.rmtree that ignores no-such-file-or-directory errors,