[elbe-devel] [PATCH v2 40/66] hdimg: Fix Pylint

Torben Hohn torben.hohn at linutronix.de
Wed Jun 10 13:39:57 CEST 2020


On Fri, Jun 05, 2020 at 01:07:04PM -0400, Olivier Dion wrote:
> 266:42: W1401: (anomalous-backslash-in-string)
> 266:50: W1401: (anomalous-backslash-in-string)
> 148:0:  R0205: (useless-object-inheritance)
> 159:4:  R0201: (no-self-use)
> 215:15: W0703: (broad-except)
> 276:15: W0703: (broad-except)
> 267:30: W0631: (undefined-loop-variable)
> 269:26: W0631: (undefined-loop-variable)
> 293:0:  R0205: (useless-object-inheritance)
> 324:26: I1101: (c-extension-no-member)
> 332:22: I1101: (c-extension-no-member)
> 335:22: I1101: (c-extension-no-member)
> 
> Requires fix for undefined-loop-variable!
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
>  elbepack/hdimg.py | 29 +++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
> index 5478cbda..9c516448 100644
> --- a/elbepack/hdimg.py
> +++ b/elbepack/hdimg.py
> @@ -145,6 +145,8 @@ def build_image_mtd(mtd, target):
>      return img_files
>  
>  
> +# TODO:py3 Remove object inheritance
> +# pylint: disable=useless-object-inheritance
>  class grubinstaller_base(object):
>      def __init__(self, fw_type=None):
>          self.fs = mountpoint_dict()
> @@ -156,7 +158,8 @@ class grubinstaller_base(object):
>      def install(self, target):
>          pass
>  
> -    def losetup(self, f):
> +    @staticmethod
> +    def losetup(f):
>          loopdev = get_command_out('losetup --find --show "%s"' % f)
>          return loopdev.rstrip('\n')
>  
> @@ -212,8 +215,8 @@ class grubinstaller202(grubinstaller_base):
>                  do("chroot %s grub-install --no-floppy %s" %
>                     (imagemnt, poopdev))
>  
> -        except Exception as E:
> -            logging.exception(E)
> +        except CommandError as E:
> +            logging.error("Fail installing grub device: %s", E)
>  
>          finally:
>              os.unlink(imagemntfs.fname("boot/grub/device.map"))
> @@ -261,11 +264,16 @@ class grubinstaller97(grubinstaller_base):
>  
>              chroot(imagemnt, "update-initramfs -u -k all")
>  
> -            # Replace groot and kopt because
> -            # else they will be given bad values
> -            do('chroot %s sed -in "s/^# groot=.*$/# groot=\(hd0,%d\)/" %s' %
> +            # Replace groot and kopt because else they will be given
> +            # bad values
> +            #
> +            # FIXME - Pylint says: Using possibly undefined loop variable
> +            # 'entry' (undefined-loop-variable).  entry is defined in
> +            # the previous for-loop.
> +            # # pylint: disable=undefined-loop-variable

i dont think, you have fixed this.
We can fix this later.
But dont ignore a pylint error, that is a real
Problem.


> +            do(r'chroot %s sed -in "s/^# groot=.*$/# groot=\(hd0,%d\)/" %s' %
>                 (imagemnt, int(entry.partnum) - 1, "/boot/grub/menu.lst"))
> -            do('chroot %s sed -in "s/^# kopt=.*$/# kopt=root=LABEL=%s/" %s' %
> +            do(r'chroot %s sed -in "s/^# kopt=.*$/# kopt=root=LABEL=%s/" %s' %
>                 (imagemnt, entry.label, "/boot/grub/menu.lst"))
>  
>              chroot(imagemnt, "update-grub")
> @@ -273,8 +281,8 @@ class grubinstaller97(grubinstaller_base):
>              do("chroot %s grub-install --no-floppy %s" %
>                 (imagemnt, poopdev))
>  
> -        except Exception as E:
> -            logging.exception(E)
> +        except CommandError as E:
> +            logging.error("Fail installing grub device: %s", E)
>  
>          finally:
>              os.unlink(imagemntfs.fname("boot/grub/device.map"))
> @@ -289,7 +297,8 @@ class grubinstaller97(grubinstaller_base):
>              do("kpartx -d %s" % poopdev, allow_fail=True)
>              do("losetup -d %s" % poopdev, allow_fail=True)
>  
> -
> +# TODO:py3 Remove object inheritance
> +# pylint: disable=useless-object-inheritance
>  class simple_fstype(object):
>      def __init__(self, typ):
>          self.type = typ
> -- 
> 2.27.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list