[elbe-devel] [PATCH 2/3] debinstaller,hdimg,rfs: fix style errors
Akash Satamkar
akash at linutronix.de
Thu Sep 26 15:22:05 CEST 2019
pylint and pycodestyle complains:
_______________________________________
elbepack/debinstaller.py:28: [W0611(unused-import), ]
Unused copyfileobj imported from shutil
elbepack/debinstaller.py:28: [C0411(wrong-import-order), ]
standard import "from shutil import copyfileobj, copyfile"
should be placed before "from gpg import core"
elbepack/debinstaller.py:132:23: E128 continuation line
under-indented for visual indent
elbepack/debinstaller.py:133:23: E128 continuation line
under-indented for visual indent
elbepack/hdimg.py:196:80: E501 line too long (80 > 79 characters)
elbepack/hdimg.py:197:80: E501 line too long (80 > 79 characters)
elbepack/hdimg.py:202:68: E221 multiple spaces before operator
elbepack/rfs.py:12: [W0611(unused-import), ] Unused import urllib2
elbepack/rfs.py:23:15: E222 multiple spaces after operator
elbepack/rfs.py:65:80: E501 line too long (84 > 79 characters)
elbepack/rfs.py:187:17: E221 multiple spaces before operator
elbepack/rfs.py:190:80: E501 line too long (90 > 79 characters)
elbepack/rfs.py:193:28: E713 test for membership should be 'not in'
elbepack/rfs.py:251:80: E501 line too long (80 > 79 characters)
elbepack/rfs.py:292:80: E501 line too long (105 > 79 characters)
elbepack/rfs.py:314:5: E303 too many blank lines (2)
elbepack/rfs.py:326:41: E231 missing whitespace after ','
elbepack/rfs.py:341:80: E501 line too long (80 > 79 characters)
elbepack/rfs.py:347:80: E501 line too long (82 > 79 characters)
_________________________________________________
fixed it
Signed-off-by: Akash Satamkar <akash at linutronix.de>
---
elbepack/debinstaller.py | 7 ++++---
elbepack/hdimg.py | 8 ++++----
elbepack/rfs.py | 37 +++++++++++++++++++++++--------------
3 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/elbepack/debinstaller.py b/elbepack/debinstaller.py
index ffe4b542..62fc01a1 100644
--- a/elbepack/debinstaller.py
+++ b/elbepack/debinstaller.py
@@ -23,9 +23,10 @@ except ImportError:
import urllib2
urlopen = urllib2.urlopen
+from shutil import copyfile
+
from gpg import core
from gpg.constants import PROTOCOL_OpenPGP
-from shutil import copyfileobj, copyfile
from elbepack.filesystem import TmpdirFilesystem
from elbepack.egpg import OverallStatus, check_signature
@@ -129,8 +130,8 @@ def download_release(tmp, base_url):
# the Release.gpg signature.
ctx = core.Context()
ctx.set_engine_info(PROTOCOL_OpenPGP,
- None,
- tmp.fname('/'))
+ None,
+ tmp.fname('/'))
# download the Relase file to a tmp file,
# because we need it 2 times
diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index 5c8ef6d8..a625533c 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -193,13 +193,13 @@ class grubinstaller202(grubinstaller_base):
"--no-floppy /dev/poop0" %
(imagemnt, grub_tgt))
if "shimfix" in self.fw_type:
- # grub-install is heavily dependent on the running system having
- # a BIOS or EFI. The initvm is BIOS-based, so fix the resulting
- # shim installation.
+ # grub-install is heavily dependent on the running system
+ # having a BIOS or EFI. The initvm is BIOS-based,
+ # so fix the resulting shim installation.
do("chroot %s /bin/bash -c '"
"cp -r /boot/efi/EFI/BOOT /boot/efi/EFI/debian && "
"cd /usr/lib/shim && f=( shim*.efi.signed ) && cp "
- "${f[0]} /boot/efi/EFI/debian/${f[0]%%.signed}'" %
+ "${f[0]} /boot/efi/EFI/debian/${f[0]%%.signed}'" %
imagemnt)
if not self.fw_type or "bios" in self.fw_type:
do("chroot %s grub-install --no-floppy /dev/poop0" %
diff --git a/elbepack/rfs.py b/elbepack/rfs.py
index 4b1127b5..680c1ce7 100644
--- a/elbepack/rfs.py
+++ b/elbepack/rfs.py
@@ -9,8 +9,8 @@
import os
import urlparse
-import urllib2
import logging
+import textwrap
from elbepack.efilesystem import BuildImgFs
from elbepack.templates import (write_pack_template, get_preseed,
@@ -20,7 +20,7 @@ from elbepack.shellhelper import CommandError, do, chroot, get_command_out
def create_apt_prefs(xml, rfs):
- filename = "etc/apt/preferences"
+ filename = "etc/apt/preferences"
if rfs.lexists(filename):
rfs.remove(filename)
@@ -62,7 +62,8 @@ class DebootstrapException (Exception):
class BuildEnv (object):
- def __init__(self, xml, path, build_sources=False, clean=False, arch="default"):
+ def __init__(self, xml, path, build_sources=False,
+ clean=False, arch="default"):
# pylint: disable=too-many-arguments
@@ -184,13 +185,14 @@ class BuildEnv (object):
host_arch = get_command_out("dpkg --print-architecture").strip()
includepkgs = None
- strapcmd = 'debootstrap '
+ strapcmd = 'debootstrap '
if self.xml.has("target/debootstrapvariant"):
bootstrapvariant = self.xml.text("target/debootstrapvariant")
- includepkgs = self.xml.node("target/debootstrapvariant").et.get("includepkgs")
+ includepkgs = self.xml.node("target/debootstrap"
+ "variant").et.get("includepkgs")
strapcmd += '--variant="%s" ' % bootstrapvariant
- if includepkgs and not "gnupg" in includepkgs.split(','):
+ if includepkgs and "gnupg" not in includepkgs.split(','):
includepkgs += ",gnupg"
if not includepkgs:
includepkgs = "gnupg"
@@ -248,7 +250,8 @@ class BuildEnv (object):
if self.xml.has("project/noauth"):
chroot(self.rfs.path,
- '/debootstrap/debootstrap --no-check-gpg --second-stage')
+ '/debootstrap/debootstrap '
+ '--no-check-gpg --second-stage')
else:
chroot(self.rfs.path,
'/debootstrap/debootstrap --second-stage')
@@ -289,9 +292,15 @@ class BuildEnv (object):
# I could make a none global 'noauth' flag for mirrors
for url in self.xml.node('project/mirror/url-list'):
if url.has('raw-key'):
- key = "\n".join(line.strip(" \t") for line in url.text('raw-key').splitlines()[1:-1])
+ for line in url.text('raw-key'):
+ key = self.key_strip(line)
self.add_key(key)
+ def key_strip(self, k):
+ key = textwrap.dedent(k)
+ key = key.strip('\n')
+ return key
+
def initialize_dirs(self, build_sources=False):
mirror = self.xml.create_apt_sources_list(build_sources=build_sources)
@@ -310,7 +319,6 @@ class BuildEnv (object):
self.rfs.fname("var/cache/elbe/preseed.txt"))
chroot(self.rfs.path, cmd)
-
def seed_etc(self):
passwd = self.xml.text("target/passwd")
stdin = "%s\n%s\n" % (passwd, passwd)
@@ -323,7 +331,7 @@ class BuildEnv (object):
chroot(self.rfs.path,
"""/bin/sh -c 'echo "127.0.1.1 %s %s elbe-daemon" >> """
- """/etc/hosts'""" % (fqdn,hostname))
+ """/etc/hosts'""" % (fqdn, hostname))
chroot(self.rfs.path,
"""/bin/sh -c 'echo "%s" > /etc/hostname'""" % hostname)
@@ -338,15 +346,16 @@ class BuildEnv (object):
if serial_baud:
chroot(self.rfs.path,
"""/bin/sh -c '[ -f /etc/inittab ] && """
- """echo "T0:23:respawn:/sbin/getty -L %s %s vt100" >> """
+ """echo "T0:23:respawn:/sbin/getty """
+ """-L %s %s vt100" >> """
"""/etc/inittab'""" % (serial_con, serial_baud),
allow_fail=True)
chroot(self.rfs.path,
"""/bin/sh -c """
- """'[ -f /lib/systemd/system/serial-getty at .service ] && """
- """ln -s /lib/systemd/system/serial-getty at .service """
- """/etc/systemd/system/getty.target.wants/"""
+ """'[ -f /lib/systemd/system/serial-getty at .service ] """
+ """&& ln -s /lib/systemd/system/serial-getty at .service"""
+ """ /etc/systemd/system/getty.target.wants/"""
"""serial-getty@%s.service'""" % serial_con,
allow_fail=True)
else:
--
2.20.1
More information about the elbe-devel
mailing list