From f39b6b301680b69d974918267a19eeb83d67ab9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= Date: Wed, 10 Oct 2018 14:26:51 +0200 Subject: [PATCH] Make python-dmidecode a weak dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's only available on x86_64. Resolves: rhbz#1565598 Signed-off-by: Ondřej Lysoněk --- tuned.spec | 4 ++-- tuned/utils/commands.py | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tuned.spec b/tuned.spec index 3bf0db2..9cd74e1 100644 --- a/tuned.spec +++ b/tuned.spec @@ -57,10 +57,10 @@ Requires: %{_py}-schedutils, %{_py}-linux-procfs, %{_py}-perf # requires for packages with inconsistent python2/3 names %if %{with python3} Requires: python3-dbus, python3-gobject-base -Requires: python3-dmidecode +Recommends: python3-dmidecode %else Requires: dbus-python, pygobject3-base -Requires: python-dmidecode +Recommends: python-dmidecode %endif Requires: virt-what, ethtool, gawk, hdparm Requires: util-linux, dbus, polkit diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index 9634709..5692450 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -9,7 +9,11 @@ import re import procfs from subprocess import * from tuned.exceptions import TunedException -import dmidecode +try: + import dmidecode + have_dmidecode = True +except: + have_dmidecode = False try: import syspurpose.files have_syspurpose = True @@ -420,12 +424,15 @@ class commands: if len(ps.find_by_regex(re.compile(value))) == 0: match = False elif option == "chassis_type": - for chassis in dmidecode.chassis().values(): - chassis_type = chassis["data"]["Type"].decode("ascii") - if re.match(value, chassis_type, re.IGNORECASE): - break + if have_dmidecode: + for chassis in dmidecode.chassis().values(): + chassis_type = chassis["data"]["Type"].decode("ascii") + if re.match(value, chassis_type, re.IGNORECASE): + break + else: + match = False else: - match = False + log.debug("Ignoring 'chassis_type' in '%s', dmidecode is not available." % fname) elif option == "syspurpose_role": if have_syspurpose: s = syspurpose.files.SyspurposeStore(