[elbe-devel] [PATCH 49/75] hdimg: Fix Pylint
Torben Hohn
torben.hohn at linutronix.de
Fri May 29 13:29:14 CEST 2020
On Mon, May 25, 2020 at 11:42:42AM -0400, Olivier Dion wrote:
> 266:42: W1401: Anomalous backslash in string: (anomalous-backslash-in-string)
> 266:50: W1401: Anomalous backslash in string: (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>
> ---
> .pylintrc | 2 +-
> elbepack/hdimg.py | 24 +++++++++++++++++-------
> 2 files changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/.pylintrc b/.pylintrc
> index b516d511..59a806a6 100644
> --- a/.pylintrc
> +++ b/.pylintrc
> @@ -27,7 +27,7 @@ persistent=yes
> # usually to register additional checkers.
> load-plugins=
>
> -extension-pkg-whitelist=lxml
> +extension-pkg-whitelist=lxml,_ped
>
>
> [MESSAGES CONTROL]
> diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
> index 5478cbda..40077d9c 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,6 +215,7 @@ class grubinstaller202(grubinstaller_base):
> do("chroot %s grub-install --no-floppy %s" %
> (imagemnt, poopdev))
>
> + # pylint: disable=broad-except
i only see this generating CommandError
why do we have to catch broad Exceptions here ?
> except Exception as E:
> logging.exception(E)
>
> @@ -261,18 +265,23 @@ 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
> + 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"))
oh man, this code is pretty broken.
It will break, when more than one HD image is used.
using entry is also just working out of luck.
entry will simply point the the deepest filesystem.
which is /boot in most cases.
>
> chroot(imagemnt, "update-grub")
>
> do("chroot %s grub-install --no-floppy %s" %
> (imagemnt, poopdev))
> -
> + # pylint: disable=broad-except
> except Exception as E:
> logging.exception(E)
>
> @@ -289,7 +298,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.26.2
>
>
> _______________________________________________
> 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