[PATCH 6/6] Remove parse_uevent_file since it won't work with pyudev.

Anne Mulhern amulhern at redhat.com
Fri Aug 1 15:38:26 UTC 2014





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Friday, August 1, 2014 1:22:34 AM
> Subject: [PATCH 6/6] Remove parse_uevent_file since it won't work with pyudev.
> 
> We can't add data to pyudev.Device instances so this function has no use.
> ---
>  blivet/udev.py     | 15 ---------------
>  tests/udev_test.py | 39 ---------------------------------------
>  2 files changed, 54 deletions(-)
> 
> diff --git a/blivet/udev.py b/blivet/udev.py
> index 7517ffe..6c3fd17 100644
> --- a/blivet/udev.py
> +++ b/blivet/udev.py
> @@ -47,21 +47,6 @@ def get_devices(subsystem="block"):
>      return [d for d in global_udev.list_devices(subsystem=subsystem)
>                          if not __is_blacklisted_blockdev(d.sys_name)]
>  
> -def parse_uevent_file(dev):
> -    path = os.path.normpath("%s/uevent" % device_get_sysfs_path(dev))
> -    if not os.access(path, os.R_OK):
> -        return dev
> -
> -    with open(path) as f:
> -        for line in f.readlines():
> -            (key, equals, value) = line.strip().partition("=")
> -            if not equals:
> -                continue
> -
> -            dev[key] = value
> -
> -    return dev
> -
>  def settle():
>      # wait maximal 300 seconds for udev to be done running blkid, lvm,
>      # mdadm etc. This large timeout is needed when running on machines with
> diff --git a/tests/udev_test.py b/tests/udev_test.py
> index 86cc434..a930031 100644
> --- a/tests/udev_test.py
> +++ b/tests/udev_test.py
> @@ -2,7 +2,6 @@
>  
>  import unittest
>  import mock
> -import os
>  
>  class UdevTest(unittest.TestCase):
>  
> @@ -17,44 +16,6 @@ class UdevTest(unittest.TestCase):
>          for device in devices:
>              self.assertNotEqual(blivet.udev.get_device(device.sys_path),
>              None)
>  
> -    def test_udev_parse_uevent_file_1(self):
> -        import blivet.udev
> -        # For this one we're accessing the real uevent file (twice).
> -        path = '/devices/virtual/block/loop1'
> -        if not os.path.exists("/sys" + path):
> -            self.skipTest("this test requires the presence of /dev/loop1")
> -
> -        info = {'sysfs_path': path}
> -        for line in open('/sys' + path + '/uevent').readlines():
> -            (name, equals, value) = line.strip().partition("=")
> -            if not equals:
> -                continue
> -
> -            info[name] = value
> -
> -        dev = {'sysfs_path': path}
> -        blivet.udev.os.path.normpath = os.path.normpath
> -        blivet.udev.os.access = os.access
> -        blivet.udev.os.R_OK = os.R_OK
> -        ret = blivet.udev.parse_uevent_file(dev)
> -        self.assertEqual(ret, info)
> -        blivet.udev.os.path.normpath = mock.Mock()
> -        blivet.udev.os.access = mock.Mock()
> -        blivet.udev.os.R_OK = mock.Mock()
> -
> -    def test_udev_parse_uevent_file_2(self):
> -        import blivet.udev
> -        blivet.udev.os.path.normpath = os.path.normpath
> -        blivet.udev.os.access.return_value = False
> -        path = '/devices/virtual/block/loop1'
> -        if not os.path.exists("/sys" + path):
> -            self.skipTest("this test requires the presence of /dev/loop1")
> -
> -        dev = {'sysfs_path': path}
> -
> -        ret = blivet.udev.parse_uevent_file(dev)
> -        self.assertEqual(ret, {'sysfs_path':
> '/devices/virtual/block/loop1'})
> -
>      def udev_settle_test(self):
>          import blivet.udev
>          blivet.udev.util = mock.Mock()
> --
> 1.9.3
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

Assuming all else is good, it probably makes sense to squash
this patch with patch (1) for push.

Otherwise, Ack.

- mulhern


More information about the anaconda-patches mailing list