Blame SOURCES/tuned-2.8.0-workaround-for-old-pyudev.patch

ad13cb
From 8af58432afeec89467699b36d5e3d9fcc2120cc9 Mon Sep 17 00:00:00 2001
ad13cb
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
ad13cb
Date: Fri, 5 May 2017 13:51:05 +0200
ad13cb
Subject: [PATCH] inventory: added workaround for pyudev < 0.18
ad13cb
MIME-Version: 1.0
ad13cb
Content-Type: text/plain; charset=UTF-8
ad13cb
Content-Transfer-Encoding: 8bit
ad13cb
ad13cb
This is needed for e.g. RHEL-7.4.
ad13cb
ad13cb
Related: rhbz#1251240
ad13cb
ad13cb
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
ad13cb
---
ad13cb
 tuned/hardware/inventory.py | 6 +++++-
ad13cb
 1 file changed, 5 insertions(+), 1 deletion(-)
ad13cb
ad13cb
diff --git a/tuned/hardware/inventory.py b/tuned/hardware/inventory.py
ad13cb
index 7a24348..8c5117d 100644
ad13cb
--- a/tuned/hardware/inventory.py
ad13cb
+++ b/tuned/hardware/inventory.py
ad13cb
@@ -30,7 +30,11 @@ class Inventory(object):
ad13cb
 
ad13cb
 	def get_device(self, subsystem, sys_name):
ad13cb
 		"""Get a pyudev.Device object for the sys_name (e.g. 'sda')."""
ad13cb
-		return pyudev.Devices.from_name(self._udev_context, subsystem, sys_name)
ad13cb
+		try:
ad13cb
+			return pyudev.Devices.from_name(self._udev_context, subsystem, sys_name)
ad13cb
+		# workaround for pyudev < 0.18
ad13cb
+		except AttributeError:
ad13cb
+			return pyudev.Device.from_name(self._udev_context, subsystem, sys_name)
ad13cb
 
ad13cb
 	def get_devices(self, subsystem):
ad13cb
 		"""Get list of devices on a given subsystem."""
ad13cb
-- 
ad13cb
2.9.3
ad13cb