[anaconda][master/rhel7-branch] Get rid of instances of devicetree.getDevicesByType (#1228334)

Vratislav Podzimek vpodzime at redhat.com
Fri Jun 5 10:15:58 UTC 2015


On Thu, 2015-06-04 at 12:04 -0400, Samantha N. Bueno wrote:
> These functions are being removed in blivet since there is no great
> benefit to keeping them around.
> 
> Resolves: rhbz#1228334
> ---
>  anaconda            | 3 ++-
>  pyanaconda/image.py | 7 ++++---
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/anaconda b/anaconda
> index 360d5ad..d0e2b61 100755
> --- a/anaconda
> +++ b/anaconda
> @@ -164,7 +164,8 @@ def exitHandler(rebootData, storage, exitCode=None):
>          from pyanaconda.iutil import dracut_eject, get_mount_paths
>  
>          if flags.eject or rebootData.eject:
> -            for cdrom in storage.devicetree.getDevicesByType("cdrom"):
> +            cdrom = [d for d in storage.devicetree.devices if d.type == "cdrom"]
> +            for d in cdrom:
>                  if get_mount_paths(cdrom.path):
>                      dracut_eject(cdrom.path)
I think cdrom could be a generator instead of list.

>  
> diff --git a/pyanaconda/image.py b/pyanaconda/image.py
> index 9662832..d87fa33 100644
> --- a/pyanaconda/image.py
> +++ b/pyanaconda/image.py
> @@ -191,8 +191,8 @@ def opticalInstallMedia(devicetree):
>      # Search for devices identified as cdrom along with any other
>      # device that has an iso9660 filesystem. This will catch USB media
>      # created from ISO images.
> -    for dev in set(devicetree.getDevicesByType("cdrom") + \
> -            [d for d in devicetree.devices if d.format.type == "iso9660"]):
> +    optdevs = [d for d in devicetree.devices if d.type == "cdrom"]
> +    for dev in set(optdevs + [d for d in devicetree.devices if d.format.type == "iso9660"]):
>          if not dev.controllable:
>              continue
Same here for both optdevs and the internal list comprehension.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list