setroubleshoot/0003-framework-Improve-myplatform-detection-in-get_os_env.patch

40 lines
1.3 KiB
Diff
Raw Normal View History

From f47ca051b0c8b7e6e8e84d7efbc69336e18cfee9 Mon Sep 17 00:00:00 2001
From: Petr Lautrbach <plautrba@redhat.com>
Date: Fri, 31 Aug 2018 12:41:09 +0200
Subject: [PATCH 3/4] framework: Improve myplatform detection in
get_os_environment()
- platform.dist() is deprecated therefore it's replaced by
distro.linux_distribution() in the new code
- distro module could raise an exception and in this case we set myplatform to
"unknown"
---
framework/src/setroubleshoot/util.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/framework/src/setroubleshoot/util.py b/framework/src/setroubleshoot/util.py
index 15ca39f..1e1e496 100755
--- a/framework/src/setroubleshoot/util.py
+++ b/framework/src/setroubleshoot/util.py
@@ -550,10 +550,12 @@ def load_plugins(filter_glob=None):
def get_os_environment():
try:
myplatform = open(redhat_release_path).readlines()[0].strip()
- except IOError:
- # dist returns (distname, version, id)
- import platform
- myplatform = ' '.join(platform.dist())
+ except:
+ try:
+ import distro
+ myplatform = ' '.join(distro.linux_distribution())
+ except:
+ myplatform = "unknown"
# uname returns (sysname, nodename, release, version, machine)
uname = os.uname()
--
2.19.0