From 63576194e54e5061c05a709ef15da7fafac44869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20M=2E=20G=C3=B3mez?= Date: Wed, 11 Dec 2019 14:24:10 +0100 Subject: [PATCH] #940: Replace obsolete function `platform.linux_distribution` with `distro.os_release_attr`. --- linux/debian/control | 2 +- linux/ogagent-template.spec | 2 +- src/opengnsys/linux/operations.py | 7 +++++-- src/opengnsys/operations.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/linux/debian/control b/linux/debian/control index 33b22c6..c627c31 100644 --- a/linux/debian/control +++ b/linux/debian/control @@ -10,7 +10,7 @@ Package: ogagent Section: admin Priority: optional Architecture: all -Depends: policykit-1(>=0.100), python-requests (>=0.8.2), python-qt4 (>=4.9), python-six(>=1.1), python-prctl(>=1.1.1), python (>=2.7), libxss1, ${misc:Depends} +Depends: policykit-1(>=0.100), python-requests (>=0.8.2), python-qt4 (>=4.9), python-six(>=1.1), python-prctl(>=1.1.1), python-distro, python (>=2.7), libxss1, ${misc:Depends} Recommends: gnome-shell-extension-top-icons-plus Description: OpenGnsys Agent for Operating Systems This package provides the required components to allow this machine to work on an environment managed by OpenGnsys. diff --git a/linux/ogagent-template.spec b/linux/ogagent-template.spec index 31db99b..b3c7362 100644 --- a/linux/ogagent-template.spec +++ b/linux/ogagent-template.spec @@ -11,7 +11,7 @@ Release: %{release} Summary: OpenGnsys Agent for Operating Systems License: BSD3 Group: Admin -Requires: chkconfig initscripts python-six python-requests PyQt4 libXScrnSaver +Requires: chkconfig initscripts python-six python-requests python-distro PyQt4 libXScrnSaver Vendor: OpenGnsys Project URL: https://opengnsys.es/ Provides: ogagent diff --git a/src/opengnsys/linux/operations.py b/src/opengnsys/linux/operations.py index 0c08f95..f3236e2 100644 --- a/src/opengnsys/linux/operations.py +++ b/src/opengnsys/linux/operations.py @@ -42,6 +42,7 @@ import subprocess import struct import array import six +import distro from opengnsys import utils from .renamer import rename @@ -139,8 +140,10 @@ def getDomainName(): def getLinuxVersion(): - lv = platform.linux_distribution() - return lv[0] + ', ' + lv[1] + """ + Returns the version of the Linux distribution + """ + return distro.os_release_attr('pretty_name') def reboot(flags=0): diff --git a/src/opengnsys/operations.py b/src/opengnsys/operations.py index 1a274b2..be777dd 100644 --- a/src/opengnsys/operations.py +++ b/src/opengnsys/operations.py @@ -47,4 +47,4 @@ else: else: from .linux.operations import * # @UnusedWildImport os_type = 'Linux' - os_version = getLinuxVersion().replace(',', '') + os_version = getLinuxVersion()