[elbe-devel] [PATCH 15/37] Clean up the code to match python PEP8 standard
Benedikt Spranger
b.spranger at linutronix.de
Wed Feb 7 15:28:42 CET 2024
From: Eduard Krein <eduard.krein at linutronix.de>
Big spring clean adressing flake8 code complains. The line length is
in contrast to PEP8 adjusted to 100 characters. The following command
was used to perform the tests:
flake8 --max-line-length 100
No functional change.
Signed-off-by: Eduard Krein <eduard.krein at linutronix.de>
Signed-off-by: Benedikt Spranger <b.spranger at linutronix.de>
---
docs/conf.py | 6 +--
elbepack/aptpkgutils.py | 6 +++
elbepack/archivedir.py | 10 ++++-
elbepack/asyncworker.py | 19 ++++++----
elbepack/cdroms.py | 5 ++-
elbepack/changelogxml.py | 1 +
elbepack/commands/add.py | 1 +
elbepack/commands/adjustpkgs.py | 3 +-
elbepack/commands/buildsdk.py | 2 +-
elbepack/commands/buildsysroot.py | 2 +-
elbepack/commands/check-build.py | 51 ++++++++++++++------------
elbepack/commands/chg_archive.py | 1 +
elbepack/commands/chroot.py | 2 +-
elbepack/commands/control.py | 3 +-
elbepack/commands/fetch_initvm_pkgs.py | 2 +-
elbepack/commands/gen_update.py | 4 +-
elbepack/commands/hdimg.py | 2 +-
elbepack/commands/init.py | 3 +-
elbepack/commands/mkcdrom.py | 2 +-
elbepack/commands/preprocess.py | 1 +
elbepack/commands/show.py | 1 -
elbepack/commands/test.py | 24 +++++++-----
elbepack/commands/toolchainextract.py | 2 +-
elbepack/commands/xsdtoasciidoc.py | 1 -
elbepack/config.py | 1 +
elbepack/daemons/soap/__init__.py | 1 +
elbepack/db.py | 50 +++++++++++++------------
elbepack/dbaction.py | 1 +
elbepack/debinstaller.py | 4 +-
elbepack/directories.py | 4 +-
elbepack/dump.py | 9 ++---
elbepack/efilesystem.py | 11 +++---
elbepack/egpg.py | 12 +++++-
elbepack/elbeproject.py | 17 +++++----
elbepack/elbexml.py | 8 +++-
elbepack/filesystem.py | 2 +
elbepack/finetuning.py | 10 +++--
elbepack/fstab.py | 1 +
elbepack/hashes.py | 1 +
elbepack/hdimg.py | 15 +++++---
elbepack/initvmaction.py | 30 ++++++++-------
elbepack/junit.py | 5 ++-
elbepack/licencexml.py | 4 +-
elbepack/log.py | 10 +++--
elbepack/packers.py | 1 +
elbepack/pbuilder.py | 12 ++++--
elbepack/pbuilderaction.py | 4 +-
elbepack/pkgarchive.py | 3 +-
elbepack/pkgutils.py | 1 +
elbepack/projectmanager.py | 2 +
elbepack/repodir.py | 7 +++-
elbepack/repomanager.py | 4 +-
elbepack/rfs.py | 15 +++++---
elbepack/rpcaptcache.py | 6 +--
elbepack/shellhelper.py | 13 ++++---
elbepack/soapclient.py | 18 +++++++--
elbepack/templates.py | 1 +
elbepack/tests/test_doctest.py | 3 +-
elbepack/tests/test_efilesystem.py | 1 +
elbepack/tests/test_preproc.py | 4 +-
elbepack/tests/test_pylint.py | 7 +++-
elbepack/tests/test_version.py | 1 +
elbepack/tests/test_xml.py | 6 ++-
elbepack/toolchain.py | 1 +
elbepack/treeutils.py | 2 +
elbepack/updated.py | 3 ++
elbepack/updated_monitors.py | 2 +
elbepack/validate.py | 11 +++---
elbepack/virtapt.py | 4 +-
elbepack/xmldefaults.py | 2 +
elbepack/xmlpreprocess.py | 15 ++++++--
test/updated.py | 1 +
72 files changed, 319 insertions(+), 181 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index 7fffcca6..cf08c1c8 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -50,7 +50,7 @@ master_doc = 'index'
# General information about the project.
project = u'ELBE'
-copyright = u'2017, Linutronix GmbH' #pylint: disable=redefined-builtin
+copyright = u'2017, Linutronix GmbH' # pylint: disable=redefined-builtin
author = u'Torben Hohn, Manuel Traut'
# The version info for the project you're documenting, acts as replacement for
@@ -58,10 +58,10 @@ author = u'Torben Hohn, Manuel Traut'
# built documents.
#
# The short X.Y version.
-#pylint: disable=unused-import,wrong-import-position
+# pylint: disable=unused-import,wrong-import-position
from elbepack.version import elbe_version as version
# The full version, including alpha/beta/rc tags.
-#pylint: disable=reimported,wrong-import-position
+# pylint: disable=reimported,wrong-import-position
from elbepack.version import elbe_version as release
# The language for content autogenerated by Sphinx. Refer to documentation
diff --git a/elbepack/aptpkgutils.py b/elbepack/aptpkgutils.py
index 4fbc1832..112f56ff 100644
--- a/elbepack/aptpkgutils.py
+++ b/elbepack/aptpkgutils.py
@@ -27,6 +27,7 @@ statestring = {
NOTINSTALLED: "NOT INSTALLED"
}
+
def apt_pkg_md5(pkg):
# pylint: disable=protected-access
hashes = pkg._records.hashes
@@ -37,6 +38,7 @@ def apt_pkg_md5(pkg):
return h.split(':')[1]
return ""
+
def apt_pkg_sha256(pkg):
# pylint: disable=protected-access
hashes = pkg._records.hashes
@@ -47,6 +49,7 @@ def apt_pkg_sha256(pkg):
return h.split(':')[1]
return ""
+
def getdeps(pkg):
for dd in pkg.dependencies:
for d in dd:
@@ -95,6 +98,7 @@ def pkgorigin(pkg):
return origin
+
def _file_is_same(path, size, sha256):
# type: (str, int, str) -> bool
"""Return ``True`` if the file is the same."""
@@ -103,6 +107,7 @@ def _file_is_same(path, size, sha256):
return apt_pkg.sha256sum(fobj) == sha256
return False
+
def fetch_binary(version, destdir='', progress=None):
# type: (str, AcquireProgress) -> str
"""Fetch the binary version of the package.
@@ -149,6 +154,7 @@ def fetch_binary(version, destdir='', progress=None):
return os.path.abspath(destfile)
+
class PackageBase:
# pylint: disable=too-many-instance-attributes
diff --git a/elbepack/archivedir.py b/elbepack/archivedir.py
index 2a5aee1a..67338822 100644
--- a/elbepack/archivedir.py
+++ b/elbepack/archivedir.py
@@ -7,7 +7,7 @@ import os
import re
import sys
-from urllib.parse import urljoin,urlparse
+from urllib.parse import urljoin, urlparse
from base64 import encodebytes, standard_b64decode
from subprocess import CalledProcessError
@@ -21,6 +21,7 @@ from elbepack.filesystem import TmpdirFilesystem
class ArchivedirError(Exception):
pass
+
def enbase(fname, compress=True):
with open(fname, "rb") as infile:
s = infile.read()
@@ -28,6 +29,7 @@ def enbase(fname, compress=True):
s = bz2.compress(s)
return encodebytes(s)
+
def collect(tararchive, path, keep):
if keep:
cmd = 'tar rf ' + tararchive + ' -C '
@@ -36,6 +38,7 @@ def collect(tararchive, path, keep):
cmd += path + ' .'
system(cmd)
+
def chg_archive(xml, path, keep):
if os.path.isdir(path):
archive = '.archive.tar'
@@ -69,6 +72,7 @@ def prepare_path(url):
path = url.geturl().replace(f"{url.scheme}://", "", 1)
return re.sub(r'/$', "", path)
+
def get_and_append_local(url, tararchive, keep):
if urlparse(url).netloc:
msg = f"Reject suspicious file:// URI \"{url}\". "
@@ -77,16 +81,19 @@ def get_and_append_local(url, tararchive, keep):
raise ArchivedirError(msg)
collect(tararchive, prepare_path(url), keep)
+
def get_and_append_unknown(url, _archive):
msg = f"unhandled scheme \"{urlparse(url).scheme}://\""
raise NotImplementedError(msg)
+
def get_and_append_method(url):
return {
'': get_and_append_local,
'file': get_and_append_local,
}.get(urlparse(url).scheme, get_and_append_unknown)
+
def _combinearchivedir(xml, xpath, use_volume):
elbexml = etree(None)
elbexml.et = xml
@@ -113,7 +120,6 @@ def _combinearchivedir(xml, xpath, use_volume):
arch = parent.ensure_child("archive")
fname_suffix = ''
-
get_and_append = get_and_append_method(archiveurl)
archname = tmp.fname(f"archive{fname_suffix}.tar.bz2")
diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
index 29faed58..9e902b8c 100644
--- a/elbepack/asyncworker.py
+++ b/elbepack/asyncworker.py
@@ -21,9 +21,9 @@ from elbepack.log import elbe_logging, read_maxlevel, reset_level
class AsyncWorkerJob:
- build_done = "build_done"
+ build_done = "build_done"
build_failed = "build_failed"
- has_changes = "has_changes"
+ has_changes = "has_changes"
def __init__(self, project):
self.project = project
@@ -128,6 +128,7 @@ class BuildCDROMsJob(AsyncWorkerJob):
db.update_project_files(self.project)
db.reset_busy(self.project.builddir, success)
+
class BuildChrootTarJob(AsyncWorkerJob):
def __init__(self, project):
AsyncWorkerJob.__init__(self, project)
@@ -187,7 +188,7 @@ class BuildJob(AsyncWorkerJob):
elif isinstance(e, AptCacheCommitError):
err = "Failed to commit the AptCache changes."
elif isinstance(e, AptCacheUpdateError):
- err ="Failed to build the Apt Cache."
+ err = "Failed to build the Apt Cache."
logging.exception("%s\n"
"Probable cause might be:\n"
@@ -206,12 +207,13 @@ class BuildJob(AsyncWorkerJob):
db.update_project_files(self.project)
db.reset_busy(self.project.builddir, success)
+
class PdebuildJob(AsyncWorkerJob):
def __init__(self, project, cpuset=-1, profile="", cross=False):
AsyncWorkerJob.__init__(self, project)
- self.cpuset=cpuset
- self.profile=profile
- self.cross=cross
+ self.cpuset = cpuset
+ self.profile = profile
+ self.cross = cross
def enqueue(self, queue, db):
db.set_busy(self.project.builddir,
@@ -238,6 +240,7 @@ class PdebuildJob(AsyncWorkerJob):
db.update_project_files(self.project)
db.reset_busy(self.project.builddir, success)
+
class CreatePbuilderJob(AsyncWorkerJob):
def __init__(self, project, ccachesize, cross=False, noccache=False):
AsyncWorkerJob.__init__(self, project)
@@ -327,6 +330,7 @@ class APTUpdateJob(AsyncWorkerJob):
finally:
db.reset_busy(self.project.builddir, success)
+
class APTUpdUpgrJob(AsyncWorkerJob):
def __init__(self, project):
AsyncWorkerJob.__init__(self, project)
@@ -356,6 +360,7 @@ class APTUpdUpgrJob(AsyncWorkerJob):
finally:
db.reset_busy(self.project.builddir, success)
+
class APTCommitJob(AsyncWorkerJob):
def __init__(self, project):
AsyncWorkerJob.__init__(self, project)
@@ -578,7 +583,7 @@ class AsyncWorker(Thread):
job = self.queue.get()
if job is not None:
with savecwd():
- with elbe_logging({"projects":job.project.builddir}):
+ with elbe_logging({"projects": job.project.builddir}):
job.execute(self.db)
else:
loop = False
diff --git a/elbepack/cdroms.py b/elbepack/cdroms.py
index d0eb49d2..497b989e 100644
--- a/elbepack/cdroms.py
+++ b/elbepack/cdroms.py
@@ -21,6 +21,7 @@ from elbepack.isooptions import get_iso_options
CDROM_SIZE = 640 * 1000 * 1000
+
# pylint: disable=too-many-arguments
def add_source_pkg(repo, component, cache, pkg, version, forbid):
if pkg in forbid:
@@ -36,6 +37,7 @@ def add_source_pkg(repo, component, cache, pkg, version, forbid):
except FetchError as e:
logging.error("Source for package '%s' could not be downloaded: %s", pkg_id, str(e))
+
def mk_source_cdrom(components, codename,
init_codename, target,
cdrom_size=CDROM_SIZE, xml=None,
@@ -81,7 +83,7 @@ def mk_source_cdrom(components, codename,
initvm_repo = Filesystem('/var/cache/elbe/sources')
- for _ , dsc_real in initvm_repo.walk_files():
+ for _, dsc_real in initvm_repo.walk_files():
if not dsc_real.endswith('.dsc'):
continue
@@ -117,6 +119,7 @@ def mk_source_cdrom(components, codename,
return [(repo.buildiso(os.path.join(target, f"src-cdrom-{component}.iso"),
options=options)) for component, repo in repos.items()]
+
def mk_binary_cdrom(rfs, arch, codename, init_codename, xml, target):
# pylint: disable=too-many-arguments
# pylint: disable=too-many-locals
diff --git a/elbepack/changelogxml.py b/elbepack/changelogxml.py
index 22750d16..fc615b97 100644
--- a/elbepack/changelogxml.py
+++ b/elbepack/changelogxml.py
@@ -4,6 +4,7 @@
from elbepack.treeutils import etree
+
class changelogs_xml:
def __init__(self):
self.outxml = etree(None)
diff --git a/elbepack/commands/add.py b/elbepack/commands/add.py
index 562e9c23..7bbe9b66 100644
--- a/elbepack/commands/add.py
+++ b/elbepack/commands/add.py
@@ -8,6 +8,7 @@ from optparse import OptionParser
from elbepack.elbexml import ElbeXML, ValidationError
+
def run_command(argv):
oparser = OptionParser(
diff --git a/elbepack/commands/adjustpkgs.py b/elbepack/commands/adjustpkgs.py
index a1f8b477..50fc8faa 100644
--- a/elbepack/commands/adjustpkgs.py
+++ b/elbepack/commands/adjustpkgs.py
@@ -97,8 +97,7 @@ def run_command(argv):
buildenv_pkgs.extend([p.et.text for p in xml.node(
"project/buildimage/pkg-list")])
-
- with elbe_logging({"files":opt.output}):
+ with elbe_logging({"files": opt.output}):
logging.info("ELBE Report for Project %s", opt.name)
return set_pkgs(xml_pkgs + buildenv_pkgs)
diff --git a/elbepack/commands/buildsdk.py b/elbepack/commands/buildsdk.py
index ac5a015a..d9174c1b 100644
--- a/elbepack/commands/buildsdk.py
+++ b/elbepack/commands/buildsdk.py
@@ -27,7 +27,7 @@ def run_command(argv):
oparser.print_help()
sys.exit(39)
- with elbe_logging({"streams":sys.stdout}):
+ with elbe_logging({"streams": sys.stdout}):
try:
project = ElbeProject(args[0], override_buildtype=opt.buildtype,
skip_validate=opt.skip_validation)
diff --git a/elbepack/commands/buildsysroot.py b/elbepack/commands/buildsysroot.py
index e11d87bf..410b0f2f 100644
--- a/elbepack/commands/buildsysroot.py
+++ b/elbepack/commands/buildsysroot.py
@@ -27,7 +27,7 @@ def run_command(argv):
oparser.print_help()
sys.exit(99)
- with elbe_logging({"streams":sys.stdout}):
+ with elbe_logging({"streams": sys.stdout}):
try:
project = ElbeProject(args[0], override_buildtype=opt.buildtype,
skip_validate=opt.skip_validation)
diff --git a/elbepack/commands/check-build.py b/elbepack/commands/check-build.py
index 11f37c76..01d7d31b 100644
--- a/elbepack/commands/check-build.py
+++ b/elbepack/commands/check-build.py
@@ -20,6 +20,7 @@ from elbepack.filesystem import TmpdirFilesystem
DEVNULL = open(os.devnull, "w")
+
def run_command(argv):
oparser = optparse.OptionParser(usage="usage: %prog check-build <cmd> <build-dir>")
@@ -42,9 +43,9 @@ def run_command(argv):
os.sys.exit(64)
total_cnt = 0
- fail_cnt = 0
+ fail_cnt = 0
- with elbe_logging({"streams":None}):
+ with elbe_logging({"streams": None}):
for test in tests:
@@ -62,9 +63,11 @@ def run_command(argv):
os.sys.exit(fail_cnt)
+
class CheckException(Exception):
pass
+
class CheckBase:
tests = dict()
@@ -78,7 +81,7 @@ class CheckBase:
except CheckException as E:
logging.exception(E)
self.ret = 1
- except: # pylint: disable=bare-except
+ except: # pylint: disable=bare-except
logging.error(traceback.format_exc())
self.ret = 1
return self.ret
@@ -99,6 +102,7 @@ class CheckBase:
def fail(self, reason):
raise CheckException(reason)
+
@CheckBase.register("cdrom")
class CheckCdroms(CheckBase):
@@ -134,7 +138,7 @@ class CheckCdroms(CheckBase):
# pylint: disable=too-many-locals
# pylint: disable=too-many-branches
- iso_it = glob.iglob("src-cdrom*")
+ iso_it = glob.iglob("src-cdrom*")
src_cnt = 0
# For every src-cdrom*, extract it to a temporary directory
@@ -148,7 +152,7 @@ class CheckCdroms(CheckBase):
infos = self.dpkg_get_infos(realpath,
["Source", "Version"])
- src_name = None
+ src_name = None
src_version = None
for info in infos.split('\n'):
@@ -176,7 +180,7 @@ class CheckCdroms(CheckBase):
sources[src_name].remove(version)
src_cnt += 1
- match = True
+ match = True
break
@@ -239,12 +243,12 @@ class CheckCdroms(CheckBase):
xml = etree("source.xml")
# Initial statistics fo the build
- bin_cnt = 0
- src_cnt = 0
+ bin_cnt = 0
+ src_cnt = 0
bin_total = 0
binaries = {}
- sources = {}
+ sources = {}
# Create a dictionnary of the form {"bin-name": [versions ..]}
# from the source.xml. We do this by iterating over all <pkg>
@@ -273,13 +277,13 @@ class CheckCdroms(CheckBase):
continue
# Extract informations from .deb
- infos = self.dpkg_get_infos(realpath, ["Package",
- "Source",
- "Version",
- "Built-Using"])
- src_name = None
+ infos = self.dpkg_get_infos(realpath, ["Package",
+ "Source",
+ "Version",
+ "Built-Using"])
+ src_name = None
src_version = None
- bin_name = None
+ bin_name = None
bin_version = None
for line in infos.split('\n'):
@@ -331,10 +335,9 @@ class CheckCdroms(CheckBase):
src_cnt += 1
sources[name] = {version}
-
# No source was found
if src_name is None:
- src_name = bin_name
+ src_name = bin_name
src_version = bin_version
# No source version was found
@@ -384,6 +387,7 @@ class CheckCdroms(CheckBase):
self.do_src(sources, src_cnt)
return self.ret
+
@CheckBase.register("img")
class CheckImage(CheckBase):
@@ -406,12 +410,12 @@ class CheckImage(CheckBase):
# pylint: disable=attribute-defined-outside-init
self.xml = etree("source.xml")
- fail_cnt = 0
+ fail_cnt = 0
total_cnt = 0
# For all image
for tag in self.xml.all(".//check-image-list/check"):
- fail_cnt += self.do_img(tag)
+ fail_cnt += self.do_img(tag)
total_cnt += 1
logging.info("Succesfully validate %d images out of %d",
@@ -422,7 +426,7 @@ class CheckImage(CheckBase):
def do_img(self, tag):
img_name = tag.text("./img")
- qemu = tag.text("./interpreter")
+ qemu = tag.text("./interpreter")
with self.open_img(img_name) as img:
@@ -444,7 +448,6 @@ class CheckImage(CheckBase):
# No valid action!
return 1
-
def do_login(self, _element, img_name, qemu, opts):
passwd = "root"
@@ -478,9 +481,9 @@ class CheckImage(CheckBase):
def do_comm(self, img_name, qemu, opts, comm):
- child = pexpect.spawn(qemu + " " + opts)
+ child = pexpect.spawn(qemu + " " + opts)
transcript = []
- ret = 0
+ ret = 0
try:
for action, text in comm:
@@ -535,6 +538,7 @@ class CheckImage(CheckBase):
return ret or child.exitstatus
+
@CheckBase.register("sdk")
class CheckSDK(CheckBase):
"""Check if SDK is working"""
@@ -615,6 +619,7 @@ exit 1
for sdk in glob.glob("setup-elbe-sdk*"):
self.do_sdk(sdk)
+
@CheckBase.register("rebuild")
class CheckRebuild(CheckBase):
diff --git a/elbepack/commands/chg_archive.py b/elbepack/commands/chg_archive.py
index cdd02d7e..a279bcce 100644
--- a/elbepack/commands/chg_archive.py
+++ b/elbepack/commands/chg_archive.py
@@ -9,6 +9,7 @@ from optparse import OptionParser
from elbepack.archivedir import chg_archive
from elbepack.treeutils import etree
+
def run_command(argv):
oparser = OptionParser(
diff --git a/elbepack/commands/chroot.py b/elbepack/commands/chroot.py
index 12c72efa..5c52d521 100644
--- a/elbepack/commands/chroot.py
+++ b/elbepack/commands/chroot.py
@@ -32,7 +32,7 @@ def run_command(argv):
oparser.print_help()
sys.exit(72)
- with elbe_logging({"streams":sys.stdout}):
+ with elbe_logging({"streams": sys.stdout}):
try:
project = ElbeProject(args[0],
override_buildtype=opt.buildtype,
diff --git a/elbepack/commands/control.py b/elbepack/commands/control.py
index 3b83d737..27beb762 100644
--- a/elbepack/commands/control.py
+++ b/elbepack/commands/control.py
@@ -72,7 +72,8 @@ def run_command(argv):
help="Only list/download pbuilder Files")
oparser.add_option("--cpuset", default=-1, type="int",
- help="Limit cpuset of pbuilder commands (bitmask) (defaults to -1 for all CPUs)")
+ help="Limit cpuset of pbuilder commands (bitmask)"
+ "(defaults to -1 for all CPUs)")
oparser.add_option("--profile", dest="profile", default="",
help="Make pbuilder commands build the specified profile")
diff --git a/elbepack/commands/fetch_initvm_pkgs.py b/elbepack/commands/fetch_initvm_pkgs.py
index 01239107..979c2a56 100644
--- a/elbepack/commands/fetch_initvm_pkgs.py
+++ b/elbepack/commands/fetch_initvm_pkgs.py
@@ -81,7 +81,7 @@ def run_command(argv):
print("xml validation failed. Bailing out")
sys.exit(47)
- with elbe_logging({"streams":sys.stdout}):
+ with elbe_logging({"streams": sys.stdout}):
if opt.cdrom_path:
if opt.cdrom_device:
diff --git a/elbepack/commands/gen_update.py b/elbepack/commands/gen_update.py
index a3ddd733..3bacd9f2 100644
--- a/elbepack/commands/gen_update.py
+++ b/elbepack/commands/gen_update.py
@@ -68,7 +68,7 @@ def run_command(argv):
else:
buildtype = None
- with elbe_logging({"streams":sys.stdout}):
+ with elbe_logging({"streams": sys.stdout}):
try:
project = ElbeProject(opt.target, name=opt.name,
override_buildtype=buildtype,
@@ -93,7 +93,7 @@ def run_command(argv):
if len(args) >= 1:
update_xml = args[0]
- with elbe_logging({"projects":project.builddir}):
+ with elbe_logging({"projects": project.builddir}):
try:
gen_update_pkg(project, update_xml, opt.output, buildtype,
opt.skip_validation, opt.debug,
diff --git a/elbepack/commands/hdimg.py b/elbepack/commands/hdimg.py
index c7450344..dffd7a96 100644
--- a/elbepack/commands/hdimg.py
+++ b/elbepack/commands/hdimg.py
@@ -61,7 +61,7 @@ def run_command(argv):
oparser.print_help()
sys.exit(68)
- with elbe_logging({"files":opt.output}):
+ with elbe_logging({"files": opt.output}):
try:
project = ElbeProject(opt.target,
override_buildtype=opt.buildtype,
diff --git a/elbepack/commands/init.py b/elbepack/commands/init.py
index 536112fc..8d21de07 100644
--- a/elbepack/commands/init.py
+++ b/elbepack/commands/init.py
@@ -208,7 +208,6 @@ def run_command(argv):
shutil.copyfile(args[0],
os.path.join(out_path, "source.xml"))
-
keys = []
for key in xml.all(".//initvm/mirror/url-list/url/raw-key"):
keys.append(key.et.text)
@@ -255,7 +254,7 @@ def run_command(argv):
("vmlinuz", ""),
("preseed.cfg", "")]
- elbe_in = Filesystem(out_path)
+ elbe_in = Filesystem(out_path)
if opt.devel:
to_cpy.append(("elbe-devel.tar.bz2", ""))
diff --git a/elbepack/commands/mkcdrom.py b/elbepack/commands/mkcdrom.py
index fcbb0eb8..464e8644 100644
--- a/elbepack/commands/mkcdrom.py
+++ b/elbepack/commands/mkcdrom.py
@@ -58,7 +58,7 @@ def run_command(argv):
oparser.print_help()
sys.exit(74)
- with elbe_logging({"files":opt.log}):
+ with elbe_logging({"files": opt.log}):
if not opt.rfs_only:
try:
diff --git a/elbepack/commands/preprocess.py b/elbepack/commands/preprocess.py
index e42fe857..61b5b184 100644
--- a/elbepack/commands/preprocess.py
+++ b/elbepack/commands/preprocess.py
@@ -21,6 +21,7 @@ def add_pass_through_options(oparser):
default=9,
help="gzip compression level 1-9 (0: no compression)")
+
def run_command(argv):
oparser = OptionParser(usage="usage: %prog preprocess [options] <xmlfile>")
oparser.add_option("-o", "--output", dest="output",
diff --git a/elbepack/commands/show.py b/elbepack/commands/show.py
index 2f5f2984..47130d3f 100644
--- a/elbepack/commands/show.py
+++ b/elbepack/commands/show.py
@@ -10,7 +10,6 @@ from elbepack.treeutils import etree
from elbepack.validate import validate_xml
-
def run_command(argv):
# pylint: disable=too-many-branches
diff --git a/elbepack/commands/test.py b/elbepack/commands/test.py
index cfa49f7a..2f3e76ef 100644
--- a/elbepack/commands/test.py
+++ b/elbepack/commands/test.py
@@ -15,11 +15,13 @@ import junit_xml as junit
from elbepack.shellhelper import command_out
+
class ElbeTestLevel(enum.IntEnum):
- BASE = enum.auto()
+ BASE = enum.auto()
EXTEND = enum.auto()
INITVM = enum.auto()
- FULL = enum.auto()
+ FULL = enum.auto()
+
class ElbeTestException(Exception):
@@ -35,11 +37,13 @@ class ElbeTestException(Exception):
def __str__(self):
return f"ElbeTestException: \"{self.cmd}\" returns {self.ret}"
+
def system(cmd, allow_fail=False):
ret, out = command_out(cmd)
if ret != 0 and not allow_fail:
raise ElbeTestException(cmd, ret, out)
+
class ElbeTestCase(unittest.TestCase):
level = ElbeTestLevel.BASE
@@ -59,10 +63,11 @@ class ElbeTestCase(unittest.TestCase):
def parameterize(self, param):
return self.__class__(methodName=self.methodName, param=param)
+
class ElbeTestSuite:
# This must be a list not a set!!!
- tests = []
+ tests = []
def __init__(self, tests):
@@ -92,7 +97,7 @@ class ElbeTestSuite:
node_id, N = parallel.split(',')
node_id = int(node_id)
- N = int(N)
+ N = int(N)
elected = []
@@ -123,6 +128,7 @@ class ElbeTestSuite:
for test in self:
print(test)
+
class ElbeTestResult(unittest.TestResult):
def __init__(self):
@@ -209,7 +215,7 @@ def run_command(argv):
# pylint: disable=too-many-locals
this_dir = os.path.dirname(os.path.realpath(__file__))
- top_dir = os.path.join(this_dir, "..", "..")
+ top_dir = os.path.join(this_dir, "..", "..")
oparser = optparse.OptionParser(usage="usage: %prog [options]")
@@ -222,8 +228,8 @@ def run_command(argv):
help="Set test level threshold")
oparser.add_option("-i", "--invert", dest="invert_re",
- action="store_true", default=False,
- help="Invert the matching of --filter")
+ action="store_true", default=False,
+ help="Invert the matching of --filter")
oparser.add_option("-d", "--dry-run", dest="dry_run",
action="store_true", default=False,
@@ -249,9 +255,9 @@ def run_command(argv):
ElbeTestCase.level = ElbeTestLevel[opt.level]
# Find all tests
- loader = unittest.defaultTestLoader
+ loader = unittest.defaultTestLoader
loader.suiteClass = ElbeTestSuite
- suite = loader.discover(top_dir)
+ suite = loader.discover(top_dir)
# then filter them
suite.filter_test(opt.parallel, opt.filter, opt.invert_re)
diff --git a/elbepack/commands/toolchainextract.py b/elbepack/commands/toolchainextract.py
index b09f0f9e..7966976f 100644
--- a/elbepack/commands/toolchainextract.py
+++ b/elbepack/commands/toolchainextract.py
@@ -67,7 +67,7 @@ def run_command(argv):
pkgs = os.listdir(tmpdir)
- with elbe_logging({"streams":sys.stdout}):
+ with elbe_logging({"streams": sys.stdout}):
repo = ToolchainRepo(defaults["arch"],
opt.codename,
diff --git a/elbepack/commands/xsdtoasciidoc.py b/elbepack/commands/xsdtoasciidoc.py
index bb706e4a..e3ce15b6 100644
--- a/elbepack/commands/xsdtoasciidoc.py
+++ b/elbepack/commands/xsdtoasciidoc.py
@@ -11,7 +11,6 @@ from elbepack.directories import xsdtoasciidoc_mako_fname
from elbepack.templates import write_template
-
def run_command(argv):
oparser = OptionParser(
usage="usage: %prog xsdtoasciidoc [options] <xsdfile>")
diff --git a/elbepack/config.py b/elbepack/config.py
index 578cb090..b3a46a02 100644
--- a/elbepack/config.py
+++ b/elbepack/config.py
@@ -45,4 +45,5 @@ class Config(dict):
if 'ELBE_MIRROR_SED' in os.environ:
self['mirrorsed'] = os.environ['ELBE_MIRROR_SED']
+
cfg = Config()
diff --git a/elbepack/daemons/soap/__init__.py b/elbepack/daemons/soap/__init__.py
index 6aa53679..3b92caa3 100644
--- a/elbepack/daemons/soap/__init__.py
+++ b/elbepack/daemons/soap/__init__.py
@@ -23,6 +23,7 @@ logging.getLogger('spyne').setLevel(logging.INFO)
warnings.simplefilter('ignore', category=PendingDeprecationWarning)
warnings.simplefilter('ignore', category=ResourceWarning)
+
class EsoapApp(Application):
def __init__(self, *args, **kargs):
Application.__init__(self, *args, **kargs)
diff --git a/elbepack/db.py b/elbepack/db.py
index 451e4fb7..10470e98 100644
--- a/elbepack/db.py
+++ b/elbepack/db.py
@@ -92,6 +92,7 @@ def _update_project_file(s, builddir, name, mime_type, description):
return filename
+
class ElbeDB:
# pylint: disable=too-many-public-methods
@@ -171,7 +172,7 @@ class ElbeDB:
dos2unix(builddir + "/postbuild.sh")
return _update_project_file(s, builddir,
- "postbuild.sh", "application/sh", "postbuild script")
+ "postbuild.sh", "application/sh", "postbuild script")
def set_savesh(self, builddir, savesh_file):
if not os.path.exists(builddir):
@@ -631,8 +632,8 @@ class ElbeDB:
s.add(v)
_update_project_file(s, builddir, versionxmlname,
- "application/xml",
- f"source.xml for version {version}")
+ "application/xml",
+ f"source.xml for version {version}")
def set_version_description(self, builddir, version, description):
with session_scope(self.session) as s:
@@ -757,7 +758,7 @@ class ElbeDB:
f"project {builddir} is not registered in the database")
_update_project_file(s, builddir, name, mime_type,
- description)
+ description)
def update_project_files(self, ep):
with session_scope(self.session) as s:
@@ -786,8 +787,8 @@ class ElbeDB:
# Add other generated files
_update_project_file(s, p.builddir, "source.xml",
- "application/xml",
- "Current source.xml of the project")
+ "application/xml",
+ "Current source.xml of the project")
for name in ["chroot", "target", "sysroot-target", "sysroot-host"]:
@@ -800,20 +801,20 @@ class ElbeDB:
"xml License file")
_update_project_file(s, p.builddir, "validation.txt",
- "text/plain; charset=utf-8",
- "Package list validation result")
+ "text/plain; charset=utf-8",
+ "Package list validation result")
_update_project_file(s, p.builddir, "elbe-report.txt",
- "text/plain; charset=utf-8",
- "Report")
+ "text/plain; charset=utf-8",
+ "Report")
_update_project_file(s, p.builddir, "log.txt",
- "text/plain; charset=utf-8",
- "Log file")
+ "text/plain; charset=utf-8",
+ "Log file")
_update_project_file(s, p.builddir, "sysroot.tar.xz",
- "application/x-xz-compressed-tar",
- "sysroot for cross-toolchains")
+ "application/x-xz-compressed-tar",
+ "sysroot for cross-toolchains")
sdk = glob.glob(os.path.join(p.builddir, "setup-elbe-sdk-*.sh"))
try:
@@ -822,21 +823,21 @@ class ElbeDB:
sdkname = sdk[0].split('/')[-1]
_update_project_file(s, p.builddir, sdkname,
- "application/x-shellscript",
- "SDK Installer")
+ "application/x-shellscript",
+ "SDK Installer")
except IndexError:
pass
_update_project_file(s, p.builddir, "chroot.tar.xz",
- "application/x-xz-compressed-tar",
- "chroot for 'native' development")
+ "application/x-xz-compressed-tar",
+ "chroot for 'native' development")
# Add Repository iso images
for img in ep.repo_images:
name = os.path.basename(img)
_update_project_file(s, p.builddir, name,
- "application/octet-stream",
- "Repository IsoImage")
+ "application/octet-stream",
+ "Repository IsoImage")
# Scan pbuilder/build directory if that exists
if os.path.exists(os.path.join(p.builddir, "pbuilder", "result")):
@@ -851,9 +852,8 @@ class ElbeDB:
for f in os.listdir(pbresult_path):
pfile = os.path.join(pfile_path, f)
_update_project_file(s, p.builddir, pfile,
- "application/octet-stream",
- "Pbuilder artifact")
-
+ "application/octet-stream",
+ "Pbuilder artifact")
def add_user(self, name, fullname, password, email, admin):
@@ -1003,6 +1003,7 @@ class User(Base):
admin = Column(Boolean)
projects = relationship("Project", backref="owner")
+
class UserData:
def __init__(self, user):
self.id = int(user.id)
@@ -1025,6 +1026,7 @@ class Project (Base):
versions = relationship("ProjectVersion", backref="project")
files = relationship("ProjectFile", backref="project")
+
class ProjectData:
def __init__(self, project):
self.builddir = str(project.builddir)
@@ -1047,6 +1049,7 @@ class ProjectVersion (Base):
description = Column(String)
timestamp = Column(DateTime, default=datetime.utcnow)
+
class ProjectVersionData:
def __init__(self, pv):
self.builddir = str(pv.builddir)
@@ -1075,6 +1078,7 @@ class ProjectFile (Base):
mime_type = Column(String, nullable=False)
description = Column(String)
+
class ProjectFileData:
def __init__(self, pf):
self.name = str(pf.name)
diff --git a/elbepack/dbaction.py b/elbepack/dbaction.py
index 2d4a4ba8..c7cbeab5 100644
--- a/elbepack/dbaction.py
+++ b/elbepack/dbaction.py
@@ -9,6 +9,7 @@ from getpass import getpass
from shutil import copyfileobj
from elbepack.db import ElbeDB, ElbeDBError
+
class DbAction:
actiondict = {}
diff --git a/elbepack/debinstaller.py b/elbepack/debinstaller.py
index 8fe25f63..fb014207 100644
--- a/elbepack/debinstaller.py
+++ b/elbepack/debinstaller.py
@@ -113,8 +113,8 @@ def verify_release(tmp, base_url):
# the Release.gpg signature.
ctx = core.Context()
ctx.set_engine_info(PROTOCOL_OpenPGP,
- None,
- tmp.fname('/'))
+ None,
+ tmp.fname('/'))
# validate signature.
# open downloaded plaintext file, and
diff --git a/elbepack/directories.py b/elbepack/directories.py
index 36c9b0d1..da6d8133 100644
--- a/elbepack/directories.py
+++ b/elbepack/directories.py
@@ -15,8 +15,8 @@ elbe_dir = None
def init_directories(elbe_relpath):
# set global variables that are used in other modules via imports
# this is the very first function that is called by 'elbe'
- global elbe_exe #pylint: disable=global-statement
- global elbe_dir #pylint: disable=global-statement
+ global elbe_exe # pylint: disable=global-statement
+ global elbe_dir # pylint: disable=global-statement
elbe_exe = os.path.abspath(os.path.realpath(elbe_relpath))
elbe_dir = os.path.dirname(elbe_exe)
diff --git a/elbepack/dump.py b/elbepack/dump.py
index f1e19816..cb25d911 100644
--- a/elbepack/dump.py
+++ b/elbepack/dump.py
@@ -19,6 +19,7 @@ from elbepack.shellhelper import do
report = logging.getLogger("report")
validation = logging.getLogger("validation")
+
def get_initvm_pkglist():
cache = Cache()
cache.open()
@@ -78,7 +79,6 @@ def check_full_pkgs(pkgs, fullpkgs, cache):
# pylint: disable=too-many-statements
# pylint: disable=too-many-branches
-
validation.info("ELBE Package validation")
validation.info("=======================")
validation.info("")
@@ -163,7 +163,7 @@ def check_full_pkgs(pkgs, fullpkgs, cache):
if not md5 and not sha256:
validation.error("Package '%s' has no hash setup in package list.",
name)
- error += 1
+ errors += 1
for cp in cache.get_installed_pkgs():
if cp.name not in pindex:
@@ -234,8 +234,6 @@ def elbe_report(xml, buildenv, cache, targetfs):
else:
mt_index_post_fine = mt_index_postarch
-
-
report.info("")
report.info("File List")
report.info("---------")
@@ -267,7 +265,6 @@ def elbe_report(xml, buildenv, cache, targetfs):
report.info("|+%s+|%s", fpath, pkg)
-
report.info("")
report.info("Deleted Files")
report.info("-------------")
@@ -318,7 +315,7 @@ def elbe_report(xml, buildenv, cache, targetfs):
for fpath in list(mt_index_postarch.keys()):
if (fpath not in mt_index or
- mt_index_postarch[fpath] != mt_index[fpath]):
+ mt_index_postarch[fpath] != mt_index[fpath]):
if fpath not in mt_index_post_fine:
validation.warning("Archive file %s deleted in finetuning",
fpath)
diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index ca17b15b..817a0668 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -27,7 +27,7 @@ def copy_filelist(src, file_lst, dst):
# pylint: disable=too-many-branches
- files = set()
+ files = set()
copied = set()
# Make sure to copy parent directories
@@ -125,7 +125,7 @@ def extract_target(src, xml, dst, cache):
f"var/lib/dpkg/info/{line}:{arch}.conffiles")
file_list = sorted(set(file_list),
- key = lambda k: k[4:] if k.startswith('/usr') else k)
+ key=lambda k: k[4:] if k.startswith('/usr') else k)
copy_filelist(src, file_list, dst)
else:
# first copy most diretories
@@ -196,16 +196,16 @@ class ElbeFilesystem(Filesystem):
if os.path.isfile(copyright_fname):
try:
with io.open(copyright_fname, "r",
- encoding='utf-8', errors='replace') as lic:
+ encoding='utf-8', errors='replace') as lic:
lic_text = lic.read()
except IOError as e:
logging.exception("Error while processing license file %s",
- copyright_fname)
+ copyright_fname)
lic_text = u"Error while processing license file %s: '%s'" % (
copyright_file, e.strerror)
else:
logging.warning("License file does not exist, skipping %s",
- copyright_fname)
+ copyright_fname)
continue
# in Python2 'pkg' is a binary string whereas in Python3 it is a
# unicode string. So make sure that pkg ends up as a unicode string
@@ -226,6 +226,7 @@ class ElbeFilesystem(Filesystem):
if xml_fname is not None:
licence_xml.write(xml_fname)
+
class Excursion:
RFS = {}
diff --git a/elbepack/egpg.py b/elbepack/egpg.py
index 6109f91f..d761dd93 100644
--- a/elbepack/egpg.py
+++ b/elbepack/egpg.py
@@ -25,6 +25,7 @@ elbe_internal_key_param = """
</GnupgKeyParms>
"""
+
# pylint: disable=too-many-instance-attributes
class OverallStatus:
@@ -156,7 +157,7 @@ def unsign_file(fname):
overall_status = OverallStatus()
try:
- infile = core.Data(file=fname)
+ infile = core.Data(file=fname)
outfile = core.Data(file=outfilename)
except (GPGMEError, ValueError) as E:
print(f"Error: Opening file {fname} or {outfilename} - {E}")
@@ -176,6 +177,7 @@ def unsign_file(fname):
return None
+
def unlock_key(fingerprint):
ctx = core.Context()
ctx.set_engine_info(PROTOCOL_OpenPGP,
@@ -187,6 +189,7 @@ def unlock_key(fingerprint):
f"--preset -P requiredToAvoidUserInput {keygrip}",
env_add={"GNUPGHOME": "/var/cache/elbe/gnupg"})
+
def sign(infile, outfile, fingerprint):
ctx = core.Context()
@@ -229,10 +232,12 @@ def sign(infile, outfile, fingerprint):
with open(outfile, 'w') as fd:
fd.write(signature)
+
def sign_file(fname, fingerprint):
outfilename = fname + '.gpg'
sign(fname, outfilename, fingerprint)
+
def get_fingerprints():
ctx = core.Context()
ctx.set_engine_info(PROTOCOL_OpenPGP,
@@ -250,7 +255,11 @@ def get_fingerprints():
# default-cache-ttl and max-cache-ttl values. Thus we're setting the
# least maximum value of the type unsigned long to ensure that the
# passphrase is 'never' removed from gpg-agent.
+
+
EOT = 4294967295
+
+
def generate_elbe_internal_key():
hostfs.mkdir_p("/var/cache/elbe/gnupg")
hostfs.write_file("/var/cache/elbe/gnupg/gpg-agent.conf", 0o600,
@@ -271,6 +280,7 @@ def export_key(fingerprint, outfile):
system(f"/usr/bin/gpg -a -o {outfile} --export {fingerprint}",
env_add={"GNUPGHOME": "/var/cache/elbe/gnupg"})
+
def unarmor_openpgp_keyring(armored):
"""
Unarmors one ascii-armored (string) OpenPGP keyring.
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index e83934dd..5703e324 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -108,6 +108,7 @@ def gen_sdk_scripts(triplet,
return sdkname
+
class ElbeProject:
# pylint: disable=too-many-instance-attributes
@@ -315,7 +316,6 @@ class ElbeProject:
f"tar cfJ {self.builddir}/sysroot.tar.xz "
f"-C {self.sysrootpath} -T {sysrootfilelist}")
-
def build_host_sysroot(self, pkgs, hostsysrootpath):
do(f'rm -rf {hostsysrootpath}; mkdir "{hostsysrootpath}"')
@@ -492,7 +492,7 @@ class ElbeProject:
# Target component
cache = self.get_rpcaptcache(env=self.buildenv)
tgt_lst = cache.get_corresponding_source_packages(pkg_lst=tgt_pkg_lst)
- components = {"target":(self.buildenv.rfs, cache, tgt_lst)}
+ components = {"target": (self.buildenv.rfs, cache, tgt_lst)}
# Main component
main_lst = []
@@ -529,8 +529,8 @@ class ElbeProject:
# Using kwargs here allows us to avoid making
# special case for when self.xml is None
kwargs = {
- "cdrom_size":cdrom_size,
- "xml":self.xml
+ "cdrom_size": cdrom_size,
+ "xml": self.xml
}
if self.xml is not None:
@@ -772,9 +772,11 @@ class ElbeProject:
formatfile = ""
if os.path.exists(os.path.join(pdebuilder_current, "debian", "source", "format")):
- formatfile = open(os.path.join(pdebuilder_current, "debian", "source", "format"), "r").read()
+ formatfile = open(os.path.join(pdebuilder_current,
+ "debian", "source", "format"), "r").read()
- src_pkg_name = open(os.path.join(pdebuilder_current, "debian", "changelog"), "r").readline().split()[0]
+ src_pkg_name = open(os.path.join(pdebuilder_current,
+ "debian", "changelog"), "r").readline().split()[0]
if "3.0 (quilt)" in formatfile and not self.orig_files:
do(f"cd {pdebuilder_current}; origtargz --download-only --tar-only")
@@ -1006,7 +1008,7 @@ class ElbeProject:
# to workaround debian bug no. 872543
if self.xml.prj.has('noauth'):
- inrelease = glob.glob(f"{self.chrootpath}/var/lib/apt/lists/*InRelease" )
+ inrelease = glob.glob(f"{self.chrootpath}/var/lib/apt/lists/*InRelease")
release_gpg = glob.glob(f"{self.chrootpath}/var/lib/apt/lists/*.gpg")
if inrelease:
system(f"rm {inrelease[0]};")
@@ -1046,7 +1048,6 @@ class ElbeProject:
"But it does not contain an initvm node")
self.copy_initvmnode()
-
# Seed /etc, we need /etc/hosts for hostname -f to work correctly
if not buildenv:
target.seed_etc()
diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index 91891dda..cb86dc93 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -18,6 +18,7 @@ from elbepack.xmldefaults import ElbeDefaults
from elbepack.version import elbe_version, is_devel
+
class ValidationError(Exception):
def __init__(self, validation):
Exception.__init__(self)
@@ -39,11 +40,13 @@ class ValidationError(Exception):
class NoInitvmNode(Exception):
pass
+
class ValidationMode:
NO_CHECK = 1
CHECK_BINARIES = 2
CHECK_ALL = 0
+
def replace_localmachine(mirror, initvm=True):
if initvm:
localmachine = "10.0.2.2"
@@ -52,6 +55,7 @@ def replace_localmachine(mirror, initvm=True):
return mirror.replace("LOCALMACHINE", localmachine)
+
class ElbeXML:
# pylint: disable=too-many-public-methods
@@ -150,8 +154,8 @@ class ElbeXML:
return "# no mirrors configured"
goptions = []
- mirrors = []
- suite = self.prj.text("suite")
+ mirrors = []
+ suite = self.prj.text("suite")
if self.prj.has("mirror/primary_host"):
diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index 2eba2c84..2b65528d 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -13,6 +13,7 @@ import gzip
from elbepack.shellhelper import do
+
def size_to_int(size):
if size[-1] in digits:
return int(size)
@@ -47,6 +48,7 @@ def size_to_int(size):
return int(s) * unit
+
class Filesystem:
# pylint: disable=too-many-public-methods
diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index 26f0e251..90e6398c 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -25,6 +25,7 @@ from elbepack.shellhelper import chroot, do, get_command_out
class FinetuningException(Exception):
pass
+
class FinetuningAction:
actiondict = {}
@@ -381,8 +382,8 @@ class CmdAction(ImageFinetuningAction):
for line
in self.node.et.text.strip("\n").splitlines())
- mnt = os.path.join(builddir, 'imagemnt')
- dev = f"{loop_dev}p{self.node.et.attrib['part']}"
+ mnt = os.path.join(builddir, 'imagemnt')
+ dev = f"{loop_dev}p{self.node.et.attrib['part']}"
if self.node.bool_attr('nomount'):
do("/bin/sh", stdin=script,
@@ -509,14 +510,14 @@ class ArtifactAction(FinetuningAction):
target.images.append('target' + self.node.et.text)
else:
logging.error("The specified artifact: '%s' doesn't exist",
- self.node.et.text)
+ self.node.et.text)
def execute_prj(self, _buildenv, target, _builddir):
if os.path.isfile("../" + self.node.et.text):
target.images.append(self.node.et.text)
else:
logging.error("The specified artifact: '%s' doesn't exist",
- self.node.et.text)
+ self.node.et.text)
@FinetuningAction.register('rm_artifact')
@@ -688,6 +689,7 @@ class CopyToPartition(ImageFinetuningAction):
fname = mnt_fs.fname(self.node.et.text)
do(f'cp -av "{os.path.join(builddir, aname)}" "{fname}"')
+
@FinetuningAction.register('set_partition_type')
class SetPartitionTypeAction(ImageFinetuningAction):
diff --git a/elbepack/fstab.py b/elbepack/fstab.py
index e194c64b..1a5d0a84 100644
--- a/elbepack/fstab.py
+++ b/elbepack/fstab.py
@@ -68,6 +68,7 @@ class mountpoint_dict (dict):
return [self[x] for x in mplist]
+
class hdpart:
def __init__(self):
# These attributes are filled later
diff --git a/elbepack/hashes.py b/elbepack/hashes.py
index a8db70b7..690f2320 100644
--- a/elbepack/hashes.py
+++ b/elbepack/hashes.py
@@ -22,6 +22,7 @@ def validate_sha256(fname, expected_hash):
f'file "{fname}" failed to verify ! got: "{m.hexdigest()}" '
f'expected: "{expected_hash}"')
+
class HashValidator:
def __init__(self, base_url):
self.hashes = {}
diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index 48e62163..ef2e8e3a 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -292,6 +292,7 @@ class grubinstaller97(grubinstaller_base):
do(f"kpartx -d {poopdev}", allow_fail=True)
do(f"losetup -d {poopdev}", allow_fail=True)
+
class simple_fstype:
def __init__(self, typ):
self.type = typ
@@ -327,8 +328,7 @@ def create_partition(
else:
ppart = parted.Partition(disk, ptype, geometry=g)
- if disk.type == "gpt" and \
- part.has("name"):
+ if disk.type == "gpt" and part.has("name"):
ppart.set_name(part.text("name"))
cons = parted.Constraint(exactGeom=g)
@@ -378,6 +378,7 @@ def create_label(disk, part, ppart, fslabel, target, grub):
return ppart
+
def _execute_fs_commands(commands, replacements):
for command in commands:
try:
@@ -387,6 +388,7 @@ def _execute_fs_commands(commands, replacements):
except Exception as E:
logging.error('Filesystem finetuning command failed: %s', E)
+
def create_binary(disk, part, ppart, target):
entry = hdpart()
@@ -406,6 +408,7 @@ def create_binary(disk, part, ppart, target):
finally:
do(f'losetup -d "{loopdev}"')
+
def create_logical_partitions(disk,
extended,
epart,
@@ -586,8 +589,8 @@ def do_hdimg(xml, target, rfs, grub_version, grub_fw_type=None):
do(f'mkdir -p "{rfs.fname("")}{l.mountpoint}"')
if rfs.listdir(l.mountpoint):
do(
- f'mv "{rfs.fname(l.mountpoint)}"/* '
- f'"{os.path.join(fspath, l.id)}"',
+ f'mv "{rfs.fname(l.mountpoint)}"/* '
+ f'"{os.path.join(fspath, l.id)}"',
allow_fail=True)
try:
@@ -618,8 +621,8 @@ def do_hdimg(xml, target, rfs, grub_version, grub_fw_type=None):
for i in fslist:
if len(os.listdir(os.path.join(fspath, i.id))) > 0:
do(
- f'mv "{os.path.join(fspath, i.id)}"/* '
- f'"{rfs.fname(i.mountpoint)}"',
+ f'mv "{os.path.join(fspath, i.id)}"/* '
+ f'"{rfs.fname(i.mountpoint)}"',
allow_fail=True)
# Files are now moved back. ubinize needs files in place, so we run it now.
diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index 99240a73..869cc32b 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -19,12 +19,14 @@ from elbepack.config import cfg
from elbepack.repodir import RepodirError, Repodir
from elbepack.xmlpreprocess import PreprocessWrapper
+
def is_soap_local():
return cfg["soaphost"] in ("localhost", "127.0.0.1")
+
def cmd_exists(x):
return any(os.access(os.path.join(path, x), os.X_OK)
- for path in os.environ["PATH"].split(os.pathsep))
+ for path in os.environ["PATH"].split(os.pathsep))
# Create download directory with timestamp,
# if necessary
@@ -42,6 +44,7 @@ class InitVMError(Exception):
def __init__(self, msg):
Exception.__init__(self, msg)
+
class InitVMAction:
actiondict = {}
@@ -69,7 +72,6 @@ class InitVMAction:
self.conn = None
self.node = node
-
# initvm might be running on a different host. Thus there's
# no need to talk with libvirt
if not is_soap_local():
@@ -100,7 +102,6 @@ class InitVMAction:
if self.conn:
break
-
if not self.conn:
print("", file=sys.stderr)
print("Accessing libvirt provider system not possible.", file=sys.stderr)
@@ -112,7 +113,8 @@ class InitVMAction:
elif verr.args[0].startswith('authentication unavailable'):
print("", file=sys.stderr)
print("Accessing libvirt provider system not allowed.", file=sys.stderr)
- print("Users which want to use elbe need to be members of the 'libvirt' group.", file=sys.stderr)
+ print("Users which want to use elbe"
+ "need to be members of the 'libvirt' group.", file=sys.stderr)
print("'gpasswd -a <user> libvirt' and logging in again,", file=sys.stderr)
print("should fix the problem.", file=sys.stderr)
sys.exit(119)
@@ -139,7 +141,6 @@ class InitVMAction:
if not self.initvm and initvmNeeded:
sys.exit(121)
-
def execute(self, _initvmdir, _opt, _args):
raise NotImplementedError('execute() not implemented')
@@ -224,7 +225,6 @@ class EnsureAction(InitVMAction):
sys.exit(124)
-
@InitVMAction.register('stop')
class StopAction(InitVMAction):
@@ -277,7 +277,6 @@ class AttachAction(InitVMAction):
system(f'virsh --connect qemu:///system console {cfg["initvm_domain"]}')
-
def submit_with_repodir_and_dl_result(xmlfile, cdrom, opt):
fname = f'elbe-repodir-{time.time_ns()}.xml'
preprocess_xmlfile = os.path.join(os.path.dirname(xmlfile), fname)
@@ -368,7 +367,7 @@ def submit_and_dl_result(xmlfile, cdrom, opt):
file=sys.stderr)
print(
f'{elbe_exe} control get_files --output "{opt.outdir}" "{prjdir}"',
- file=sys.stderr)
+ file=sys.stderr)
print("", file=sys.stderr)
print('The project can then be removed using:',
file=sys.stderr)
@@ -404,7 +403,7 @@ def submit_and_dl_result(xmlfile, cdrom, opt):
print(
f'{elbe_exe} control get_files --output "{opt.outdir}" '
f'"{prjdir}"',
- file=sys.stderr)
+ file=sys.stderr)
print("", file=sys.stderr)
print('The project can then be removed using:',
file=sys.stderr)
@@ -469,6 +468,7 @@ def submit_and_dl_result(xmlfile, cdrom, opt):
file=sys.stderr)
sys.exit(139)
+
def extract_cdrom(cdrom):
""" Extract cdrom iso image
returns a TmpdirFilesystem() object containing
@@ -542,7 +542,7 @@ class CreateAction(InitVMAction):
"ELBE_INITVM_DOMAIN environment variable to an unused domain name.\n")
print("Note:")
print("\t1) You can reimport your old initvm via "
- "`virsh --connect qemu:///system define <file>`")
+ "`virsh --connect qemu:///system define <file>`")
print("\t where <file> is the corresponding libvirt.xml")
print("\t2) virsh --connect qemu:///system undefine does not delete the image "
"of your old initvm.")
@@ -551,9 +551,9 @@ class CreateAction(InitVMAction):
# Upgrade from older versions which used tmux
try:
system("tmux has-session -t ElbeInitVMSession 2>/dev/null")
- print ("ElbeInitVMSession exists in tmux. "
- "It may belong to an old elbe version. "
- "Please stop it to prevent interfering with this version.", file=sys.stderr)
+ print("ElbeInitVMSession exists in tmux. "
+ "It may belong to an old elbe version. "
+ "Please stop it to prevent interfering with this version.", file=sys.stderr)
sys.exit(143)
except CommandError:
pass
@@ -630,7 +630,8 @@ class CreateAction(InitVMAction):
self.conn.defineXML(xml)
except CommandError:
print('Registering initvm in libvirt failed', file=sys.stderr)
- print(f"Try `virsh --connect qemu:///system undefine {cfg['initvm_domain']}` to delete existing initvm",
+ print(f"Try `virsh --connect qemu:///system undefine {cfg['initvm_domain']}`"
+ "to delete existing initvm",
file=sys.stderr)
sys.exit(146)
@@ -706,6 +707,7 @@ class SubmitAction(InitVMAction):
submit_with_repodir_and_dl_result(xmlfile, cdrom, opt)
+
@InitVMAction.register('sync')
class SyncAction(InitVMAction):
diff --git a/elbepack/junit.py b/elbepack/junit.py
index 1176878f..65e37632 100644
--- a/elbepack/junit.py
+++ b/elbepack/junit.py
@@ -6,9 +6,11 @@
import junit_xml as junit
from junit_xml import to_xml_report_file
+
class TestException(Exception):
pass
+
class TestSuite:
test_dict = {}
@@ -44,11 +46,12 @@ class TestSuite:
try:
test_cases.append(self.do_test(test, self.target))
except TestException:
- pass # TODO - Handle me!
+ pass # TODO - Handle me!
ts = junit.TestSuite(name=self.node.et.attrib["name"],
test_cases=test_cases)
return ts
+
@TestSuite.register("BaseTest", register=False)
class BaseTest:
diff --git a/elbepack/licencexml.py b/elbepack/licencexml.py
index 31a1576c..24cb1e9b 100644
--- a/elbepack/licencexml.py
+++ b/elbepack/licencexml.py
@@ -9,7 +9,8 @@ import re
import warnings
import logging
-from debian.copyright import Copyright, LicenseParagraph, NotMachineReadableError, MachineReadableFormatError
+from debian.copyright import Copyright, LicenseParagraph, \
+ NotMachineReadableError, MachineReadableFormatError
from elbepack.treeutils import etree
warnings.simplefilter('error')
@@ -41,6 +42,7 @@ def get_heuristics_license_list(c):
return set(licenses)
+
class copyright_xml:
def __init__(self):
self.outxml = etree(None)
diff --git a/elbepack/log.py b/elbepack/log.py
index 8d315e4f..d4302bb4 100644
--- a/elbepack/log.py
+++ b/elbepack/log.py
@@ -65,6 +65,7 @@ class QHandler(logging.Handler):
except (IndexError, KeyError):
pass
+
def read_loggingQ(proj):
return QHandler.pop(proj)
@@ -72,9 +73,11 @@ def read_loggingQ(proj):
def read_maxlevel(proj):
return QHandler.max_level(proj)
+
def reset_level(proj):
QHandler.reset_level(proj)
+
class ThreadFilter(logging.Filter):
def __init__(self, allowed, *args, **kwargs):
@@ -218,6 +221,7 @@ def close_logging():
h.close()
local.handlers = []
+
class AsyncLogging:
def __init__(self, atmost, stream, block):
@@ -243,7 +247,7 @@ class AsyncLogging:
while True:
- buf = os.read(self.fd, self.atmost).decode("utf-8", errors="replace")
+ buf = os.read(self.fd, self.atmost).decode("utf-8", errors="replace")
# Pipe broke
if not buf:
@@ -251,7 +255,7 @@ class AsyncLogging:
buf = rest + buf
cnt = 0
- j = 0
+ j = 0
# Line buffering
for i in range(len(buf)):
@@ -265,7 +269,7 @@ class AsyncLogging:
logbuf = "\n".join(self.lines[-cnt:])
# filter out ansi sequences.
- logbuf = re.sub('\u001b\[.*?[@-~]', '', logbuf)
+ logbuf = re.sub('\u001b[.*?[@-~]', '', logbuf)
logbuf = re.sub('\u0008', '', logbuf)
self.stream.info(logbuf)
diff --git a/elbepack/packers.py b/elbepack/packers.py
index 782ff254..2ec8b57a 100644
--- a/elbepack/packers.py
+++ b/elbepack/packers.py
@@ -5,6 +5,7 @@
import os
from elbepack.shellhelper import CommandError, do
+
class Packer:
def pack_file(self, _builddir, _fname):
diff --git a/elbepack/pbuilder.py b/elbepack/pbuilder.py
index 51b62fb6..d5462680 100644
--- a/elbepack/pbuilder.py
+++ b/elbepack/pbuilder.py
@@ -8,6 +8,7 @@ from urllib.request import urlopen
from elbepack.filesystem import Filesystem
+
def pbuilder_write_config(builddir, xml, noccache):
distname = xml.prj.text('suite')
pbuilderrc_fname = os.path.join(builddir, "pbuilderrc")
@@ -33,7 +34,8 @@ def pbuilder_write_config(builddir, xml, noccache):
if xml.prj.has('noauth'):
fp.write(
'DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" "--no-check-gpg")\n')
- fp.write("""for i in "${!DEBOOTSTRAPOPTS[@]}"; do if [[ ${DEBOOTSTRAPOPTS[i]} == "--force-check-gpg" ]]; then unset 'DEBOOTSTRAPOPTS[i]'; break; fi done\n""")
+ fp.write("""for i in "${!DEBOOTSTRAPOPTS[@]}"; do if [[ ${DEBOOTSTRAPOPTS[i]}
+ == "--force-check-gpg" ]]; then unset 'DEBOOTSTRAPOPTS[i]'; break; fi done\n""")
fp.write('export ALLOWUNTRUSTED="yes"\n')
# aptitude segfaults with armhf changeroots, great! :)
@@ -49,6 +51,7 @@ def pbuilder_write_config(builddir, xml, noccache):
fp.write('BINDMOUNTS="${CCACHE_DIR}"')
fp.close()
+
def pbuilder_write_cross_config(builddir, xml, noccache):
distname = xml.prj.text('suite')
pbuilderrc_fname = os.path.join(builddir, "cross_pbuilderrc")
@@ -71,7 +74,8 @@ def pbuilder_write_cross_config(builddir, xml, noccache):
if xml.prj.has('noauth'):
fp.write(
'DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" "--no-check-gpg")\n')
- fp.write("""for i in "${!DEBOOTSTRAPOPTS[@]}"; do if [[ ${DEBOOTSTRAPOPTS[i]} == "--force-check-gpg" ]]; then unset 'DEBOOTSTRAPOPTS[i]'; break; fi done\n""")
+ fp.write("""for i in "${!DEBOOTSTRAPOPTS[@]}"; do if [[ ${DEBOOTSTRAPOPTS[i]} ==
+ "--force-check-gpg" ]]; then unset 'DEBOOTSTRAPOPTS[i]'; break; fi done\n""")
fp.write('export ALLOWUNTRUSTED="yes"\n')
if not noccache:
@@ -109,6 +113,7 @@ def pbuilder_write_apt_conf(builddir, xml):
fp.write('Aptitude::CmdLine::Ignore-Trust-Violations "true";\n')
fp.close()
+
def mirror_script_add_key_url(key_url):
key_url = key_url.replace("LOCALMACHINE", "10.0.2.2")
key_conn = urlopen(key_url, None, 10)
@@ -147,6 +152,7 @@ def pbuilder_write_repo_hook(builddir, xml, cross):
f.write("apt-get update\n")
+
def get_apt_keys(builddir, xml):
if xml.prj is None:
@@ -155,7 +161,7 @@ def get_apt_keys(builddir, xml):
if not xml.prj.has("mirror") and not xml.prj.has("mirror/cdrom"):
return (["# No mirrors configured"], [])
- keys = [Filesystem(builddir).read_file("repo/repo.pub")]
+ keys = [Filesystem(builddir).read_file("repo/repo.pub")]
if xml.prj.has("mirror/primary_host") and xml.prj.has("mirror/url-list"):
diff --git a/elbepack/pbuilderaction.py b/elbepack/pbuilderaction.py
index 8725ec7b..6019be92 100644
--- a/elbepack/pbuilderaction.py
+++ b/elbepack/pbuilderaction.py
@@ -30,6 +30,7 @@ class PBuilderError(Exception):
def __init__(self, msg):
Exception.__init__(self, msg)
+
class PBuilderAction:
actiondict = {}
@@ -114,7 +115,8 @@ class CreateAction(PBuilderAction):
print("Creating pbuilder")
try:
- system(f'{sys.executable} {elbe_exe} control build_pbuilder "{prjdir}" {crossopt} {ccacheopt} {ccachesize}')
+ system(f"""'{sys.executable} {elbe_exe} control
+ build_pbuilder "{prjdir}" {crossopt} {ccacheopt} {ccachesize}'""")
except CommandError:
print("elbe control build_pbuilder Failed", file=sys.stderr)
print("Giving up", file=sys.stderr)
diff --git a/elbepack/pkgarchive.py b/elbepack/pkgarchive.py
index 38d3a037..7a63573a 100644
--- a/elbepack/pkgarchive.py
+++ b/elbepack/pkgarchive.py
@@ -56,7 +56,8 @@ def gen_binpkg_archive(ep, repodir):
if not path.isfile(abs_path):
# Package file does not exist, download it and adjust path name
- logging.warning('Package file "%s" not found in var/cache/apt/archives, downloading it',
+ logging.warning('Package file "%s" not found'
+ 'in var/cache/apt/archives, downloading it',
filename)
abs_path = ep.buildenv.rfs.fname(rel_path)
pkg_id = f"{pkg.name}-{pkg.installed_version}"
diff --git a/elbepack/pkgutils.py b/elbepack/pkgutils.py
index f198b71b..f5058a66 100644
--- a/elbepack/pkgutils.py
+++ b/elbepack/pkgutils.py
@@ -64,6 +64,7 @@ def get_dsc_size(fname):
return sz
+
class ChangelogNeedsDependency(Exception):
def __init__(self, pkgname):
Exception.__init__(
diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
index a807d797..716e481e 100644
--- a/elbepack/projectmanager.py
+++ b/elbepack/projectmanager.py
@@ -50,12 +50,14 @@ class InvalidState(ProjectManagerError):
def __init__(self, message):
ProjectManagerError.__init__(self, message)
+
class OpenProjectFile:
def __init__(self, pfd, mode='r'):
self.path = path.join(pfd.builddir, pfd.name)
self.mime_type = pfd.mime_type
self.fobj = open(self.path, mode)
+
class ProjectManager:
# pylint: disable=too-many-public-methods
diff --git a/elbepack/repodir.py b/elbepack/repodir.py
index 4fa9b941..aed240dd 100644
--- a/elbepack/repodir.py
+++ b/elbepack/repodir.py
@@ -14,6 +14,7 @@ from lxml.etree import XMLParser, parse, Element, XMLSyntaxError
class RepodirError(Exception):
pass
+
def preprocess_repodir(xml, xmldir):
"""Replaces each <repodir>, which points to a directory containing a Debian
repository, with a valid <url> element.
@@ -26,10 +27,12 @@ def preprocess_repodir(xml, xmldir):
for repodir in xml.iterfind('.//mirror/url-list/repodir'):
repo = repodir.text.split(maxsplit=1)
if len(repo) != 2:
- raise RepodirError("A <repodir> must consist of a file path, a suite name, and components")
+ raise RepodirError("A <repodir> must consist of a file path,"
+ "a suite name, and components")
hostdir = os.path.join(xmldir, repo[0])
- httpd = HTTPServer(('localhost', 0), functools.partial(SimpleHTTPRequestHandler, directory=hostdir))
+ httpd = HTTPServer(('localhost', 0),
+ functools.partial(SimpleHTTPRequestHandler, directory=hostdir))
url_element = Element("url")
# Keep the variant attribute for later processing
diff --git a/elbepack/repomanager.py b/elbepack/repomanager.py
index 52a9dc5b..fd784f0f 100644
--- a/elbepack/repomanager.py
+++ b/elbepack/repomanager.py
@@ -12,6 +12,7 @@ from elbepack.pkgutils import get_dsc_size
from elbepack.egpg import generate_elbe_internal_key, export_key, unlock_key
from elbepack.shellhelper import CommandError, do
+
class RepoAttributes:
def __init__(self, codename, arch, components,
mirror='http://ftp.de.debian.org/debian'):
@@ -41,6 +42,7 @@ class RepoAttributes:
return [RepoAttributes(self.codename, ret_arch, ret_comp, self.mirror)]
+
class RepoBase:
# pylint: disable=too-many-instance-attributes
@@ -286,7 +288,6 @@ class RepoBase:
for pp in p['Binary'].split():
self._removedeb(pp, codename, components)
-
def _includedsc(self, path, codename, components=None):
if self.maxsize:
new_size = self.fs.disk_usage("") + get_dsc_size(path)
@@ -358,6 +359,7 @@ class RepoBase:
def volume_indexes(self):
return range(self.volume_count + 1)
+
class UpdateRepo(RepoBase):
def __init__(self, xml, path):
self.xml = xml
diff --git a/elbepack/rfs.py b/elbepack/rfs.py
index 6c505786..d622175d 100644
--- a/elbepack/rfs.py
+++ b/elbepack/rfs.py
@@ -17,7 +17,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)
@@ -57,8 +57,10 @@ class DebootstrapException (Exception):
def __init__(self):
Exception.__init__(self, "Debootstrap Failed")
+
class BuildEnv:
- def __init__(self, xml, path, build_sources=False, clean=False, arch="default", hostsysroot=False):
+ def __init__(self, xml, path, build_sources=False,
+ clean=False, arch="default", hostsysroot=False):
# pylint: disable=too-many-arguments
@@ -125,7 +127,8 @@ class BuildEnv:
if self.xml.has("project/mirror/cdrom"):
self.convert_asc_to_gpg('/cdrom/repo.pub', '/etc/apt/trusted.gpg.d/elbe-cdrepo.gpg')
- self.convert_asc_to_gpg('/cdrom/targetrepo/repo.pub', '/etc/apt/trusted.gpg.d/elbe-cdtargetrepo.gpg')
+ self.convert_asc_to_gpg('/cdrom/targetrepo/repo.pub',
+ '/etc/apt/trusted.gpg.d/elbe-cdtargetrepo.gpg')
if os.path.exists(os.path.join(self.rfs.path, 'repo/pool')):
self.convert_asc_to_gpg('/repo/repo.pub', '/etc/apt/trusted.gpg.d/elbe-localrepo.gpg')
@@ -175,7 +178,7 @@ class BuildEnv:
host_arch = get_command_out("dpkg --print-architecture").strip().decode()
- strapcmd = "debootstrap"
+ strapcmd = "debootstrap"
# Should we use a special bootstrap variant?
if self.xml.has("target/debootstrap/variant"):
@@ -304,7 +307,6 @@ class BuildEnv:
cmd = (f'debconf-set-selections < {self.rfs.fname("var/cache/elbe/preseed.txt")}')
chroot(self.rfs.path, cmd)
-
def seed_etc(self):
passwd = self.xml.text("target/passwd_hashed")
stdin = f"root:{passwd}"
@@ -335,7 +337,8 @@ class BuildEnv:
if serial_baud:
chroot(self.rfs.path,
"""/bin/sh -c '[ -f /etc/inittab ] && """
- f"""echo "T0:23:respawn:/sbin/getty -L {serial_con} {serial_baud} vt100" >> """
+ f"""echo "T0:23:respawn:/sbin/getty -L
+ {serial_con} {serial_baud} vt100" >> """
"""/etc/inittab'""",
allow_fail=True)
diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index b2765db5..c3a4dee6 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -55,6 +55,7 @@ class MyMan(BaseManager):
super(MyMan, self).start(MyMan.redirect_outputs, [r, w])
async_logging(r, w, soap, log)
+
class InChRootObject:
def __init__(self, rfs):
self.rfs = rfs
@@ -152,7 +153,7 @@ class RPCAPTCache(InChRootObject):
if name_no_suffix in version_dict:
- version = version_dict[name_no_suffix]
+ version = version_dict[name_no_suffix]
candidate = pkg.versions.get(version)
if candidate:
@@ -204,7 +205,6 @@ class RPCAPTCache(InChRootObject):
mark_install(dbgsym_lst, "-dbgsym")
-
def cleanup(self, exclude_pkgs):
for p in self.cache:
if p.is_installed and not \
@@ -393,7 +393,7 @@ class RPCAPTCache(InChRootObject):
src = os.path.basename(_file.path)
dst = os.path.join(dest_dir, src)
- if 'dsc' == _file.type:
+ if 'dsc' == _file.type:
dsc = dst
if not (allow_untrusted or _file.hashes.usable):
diff --git a/elbepack/shellhelper.py b/elbepack/shellhelper.py
index c275fae0..8bcacea6 100644
--- a/elbepack/shellhelper.py
+++ b/elbepack/shellhelper.py
@@ -26,6 +26,7 @@ class CommandError(Exception):
def __str__(self):
return f"Error: {self.returncode} returned from Command {self.cmd}"
+
def system(cmd, allow_fail=False, env_add=None):
"""system() - Execute cmd in a shell.
@@ -239,7 +240,7 @@ def do(cmd, allow_fail=False, stdin=None, env_add=None):
if isinstance(stdin, str):
stdin = stdin.encode()
- logging.info(cmd, extra={"context":"[CMD] "})
+ logging.info(cmd, extra={"context": "[CMD] "})
r, w = os.pipe()
@@ -255,7 +256,6 @@ def do(cmd, allow_fail=False, stdin=None, env_add=None):
raise CommandError(cmd, p.returncode)
-
def chroot(directory, cmd, env_add=None, **kwargs):
"""chroot() - Wrapper around do().
@@ -273,13 +273,14 @@ def chroot(directory, cmd, env_add=None, **kwargs):
elbepack.shellhelper.CommandError: ...
"""
- new_env = {"LANG":"C",
- "LANGUAGE":"C",
- "LC_ALL":"C"}
+ new_env = {"LANG": "C",
+ "LANGUAGE": "C",
+ "LC_ALL": "C"}
if env_add:
new_env.update(env_add)
do(f"chroot {directory} {cmd}", env_add=new_env, **kwargs)
+
def get_command_out(cmd, stdin=None, allow_fail=False, env_add=None):
"""get_command_out() - Like do() but returns stdout.
@@ -317,7 +318,7 @@ def get_command_out(cmd, stdin=None, allow_fail=False, env_add=None):
if isinstance(stdin, str):
stdin = stdin.encode()
- logging.info(cmd, extra={"context":"[CMD] "})
+ logging.info(cmd, extra={"context": "[CMD] "})
r, w = os.pipe()
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index 0655ba05..29e6f65f 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -25,6 +25,7 @@ from elbepack.filesystem import Filesystem
from elbepack.elbexml import ElbeXML, ValidationMode
from elbepack.version import elbe_version, elbe_initvm_packagelist
+
def set_suds_debug(debug):
if debug:
logging.basicConfig(level=logging.INFO)
@@ -39,6 +40,7 @@ def set_suds_debug(debug):
logging.getLogger('suds.umx.typed').setLevel(logging.ERROR)
logging.getLogger('suds.client').setLevel(logging.CRITICAL)
+
class ElbeSoapClient:
def __init__(self, host, port, user, passwd, retries=10, debug=False):
@@ -112,6 +114,7 @@ class ElbeSoapClient:
fp.write(binascii.a2b_base64(ret))
part = part + 1
+
class ClientAction:
actiondict = {}
@@ -213,6 +216,7 @@ class ListUsersAction(ClientAction):
ClientAction.register(ListUsersAction)
+
class AddUserAction(ClientAction):
tag = 'add_user'
@@ -226,10 +230,10 @@ class AddUserAction(ClientAction):
file=sys.stderr)
sys.exit(173)
- name = args[0]
+ name = args[0]
fullname = args[1]
password = args[2]
- email = args[3]
+ email = args[3]
try:
client.service.add_user(name, fullname, password, email, False)
@@ -243,8 +247,10 @@ class AddUserAction(ClientAction):
# when we get here, the user we wanted to create already exists.
# that is fine, and we dont need to do anything now.
+
ClientAction.register(AddUserAction)
+
class CreateProjectAction(ClientAction):
tag = 'create_project'
@@ -562,7 +568,7 @@ class GetFilesAction(ClientAction):
for f in files[0]:
if (opt.pbuilder_only and not f.name.startswith('pbuilder_cross')
- and not f.name.startswith('pbuilder')):
+ and not f.name.startswith('pbuilder')):
continue
if opt.matches and not fnmatch.fnmatch(f.name, opt.matches):
@@ -638,6 +644,7 @@ class WaitProjectBusyAction(ClientAction):
file=sys.stderr)
sys.exit(191)
+
ClientAction.register(WaitProjectBusyAction)
@@ -663,6 +670,7 @@ class SetCdromAction(ClientAction):
self.upload_file(client.service.append_cdrom, builddir, filename)
client.service.finish_cdrom(builddir)
+
ClientAction.register(SetCdromAction)
@@ -688,6 +696,7 @@ class SetOrigAction(ClientAction):
self.upload_file(client.service.append_upload_orig, builddir, filename)
client.service.finish_upload_orig(builddir)
+
ClientAction.register(SetOrigAction)
@@ -781,6 +790,7 @@ class UpdatePbuilderAction(ClientAction):
ClientAction.register(UpdatePbuilderAction)
+
class InstallElbeVersion(ClientAction):
tag = 'install_elbe_version'
@@ -813,6 +823,7 @@ class InstallElbeVersion(ClientAction):
ClientAction.register(InstallElbeVersion)
+
class RepoAction(ClientAction):
repoactiondict = {}
@@ -833,6 +844,7 @@ class RepoAction(ClientAction):
def execute(self, _client, _opt, _args):
raise NotImplementedError('execute() not implemented')
+
class ListPackagesAction(RepoAction):
tag = 'list_packages'
diff --git a/elbepack/templates.py b/elbepack/templates.py
index 94517785..0908749e 100644
--- a/elbepack/templates.py
+++ b/elbepack/templates.py
@@ -10,6 +10,7 @@ from mako import exceptions
from elbepack.treeutils import etree
from elbepack.directories import mako_template_dir, default_preseed_fname
+
def fix_linebreak_escapes(s):
return s.replace('\\\n', '${"\\\\"}\n')
diff --git a/elbepack/tests/test_doctest.py b/elbepack/tests/test_doctest.py
index a875e871..fb346d03 100644
--- a/elbepack/tests/test_doctest.py
+++ b/elbepack/tests/test_doctest.py
@@ -9,6 +9,7 @@ import elbepack.filesystem as filesystem
from elbepack.commands.test import ElbeTestCase
+
class ElbeDocTest(ElbeTestCase):
# This is an example of a callable parametrization
@@ -21,7 +22,7 @@ class ElbeDocTest(ElbeTestCase):
self.kwargs = {}
if self.param is filesystem:
- self.kwargs["extraglobs"] = {"this":filesystem.TmpdirFilesystem()}
+ self.kwargs["extraglobs"] = {"this": filesystem.TmpdirFilesystem()}
def tearDown(self):
diff --git a/elbepack/tests/test_efilesystem.py b/elbepack/tests/test_efilesystem.py
index a62519f9..e840bc12 100644
--- a/elbepack/tests/test_efilesystem.py
+++ b/elbepack/tests/test_efilesystem.py
@@ -7,6 +7,7 @@ import unittest
from elbepack.filesystem import TmpdirFilesystem
from elbepack.efilesystem import copy_filelist
+
class TestCopyFilelist(unittest.TestCase):
def setUp(self):
diff --git a/elbepack/tests/test_preproc.py b/elbepack/tests/test_preproc.py
index 54cdde5f..d623368c 100644
--- a/elbepack/tests/test_preproc.py
+++ b/elbepack/tests/test_preproc.py
@@ -8,6 +8,7 @@ import sys
from elbepack.commands.test import ElbeTestCase, system, ElbeTestException
from elbepack.directories import elbe_exe, elbe_dir
+
class TestPreproc(ElbeTestCase):
failure_set = {os.path.join(elbe_dir, path)
@@ -34,4 +35,5 @@ class TestPreproc(ElbeTestCase):
raise
else:
if self.param in TestPreproc.failure_set:
- raise Exception(f"Preproc test for {self.param} is expected to fail, but did not !")
+ raise Exception(f"Preproc test for {self.param}"
+ "is expected to fail, but did not !")
diff --git a/elbepack/tests/test_pylint.py b/elbepack/tests/test_pylint.py
index cf16cb79..7338f262 100644
--- a/elbepack/tests/test_pylint.py
+++ b/elbepack/tests/test_pylint.py
@@ -8,6 +8,7 @@ from elbepack.commands.test import ElbeTestCase, system, ElbeTestException
from elbepack.shellhelper import system_out
from elbepack.directories import pack_dir, elbe_exe, elbe_dir
+
class TestPylint(ElbeTestCase):
pylint_opts = ["--reports=n",
@@ -21,8 +22,10 @@ class TestPylint(ElbeTestCase):
"daemons/soap/esoap.py",
# FIXME: This one is an actual bug to be fixed
- # 274:30: W0631: Using possibly undefined loop variable 'entry' (undefined-loop-variable)
- # 276:26: W0631: Using possibly undefined loop variable 'entry' (undefined-loop-variable)
+ # 274:30: W0631: Using possibly undefined loop variable
+ # 'entry' (undefined-loop-variable)
+ # 276:26: W0631: Using possibly undefined loop variable
+ # 'entry' (undefined-loop-variable)
"hdimg.py",
"initvmaction.py",
diff --git a/elbepack/tests/test_version.py b/elbepack/tests/test_version.py
index c3ef07a6..3daf13d0 100644
--- a/elbepack/tests/test_version.py
+++ b/elbepack/tests/test_version.py
@@ -6,6 +6,7 @@ import unittest
from elbepack.version import elbe_version
+
# Since this is just an example on how to make tests, we skip them
class TestElbepackVersion(unittest.TestCase):
diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
index 980e4351..915ea16d 100644
--- a/elbepack/tests/test_xml.py
+++ b/elbepack/tests/test_xml.py
@@ -10,6 +10,7 @@ import tempfile
from elbepack.directories import elbe_dir, elbe_exe
from elbepack.commands.test import ElbeTestCase, ElbeTestLevel, system
+
@unittest.skipIf(ElbeTestCase.level < ElbeTestLevel.INITVM,
"Test level not set to INITVM")
class TestSimpleXML(ElbeTestCase):
@@ -23,7 +24,7 @@ class TestSimpleXML(ElbeTestCase):
with tempfile.TemporaryDirectory(prefix="elbe-test-simple-xml-") as build_dir:
- prj = os.path.join(build_dir, "uuid.prj")
+ prj = os.path.join(build_dir, "uuid.prj")
uuid = None
try:
@@ -50,6 +51,7 @@ class TestSimpleXML(ElbeTestCase):
system(
f'{sys.executable} {elbe_exe} control del_project {uuid}', allow_fail=True)
+
@unittest.skipIf(ElbeTestCase.level < ElbeTestLevel.INITVM,
"Test level not set to INITVM")
class TestPbuilder(ElbeTestCase):
@@ -63,7 +65,7 @@ class TestPbuilder(ElbeTestCase):
with tempfile.TemporaryDirectory(prefix="elbe-test-pbuilder-xml-") as build_dir:
- prj = os.path.join(build_dir, "uuid.prj")
+ prj = os.path.join(build_dir, "uuid.prj")
uuid = None
try:
diff --git a/elbepack/toolchain.py b/elbepack/toolchain.py
index d42fe378..f274f132 100644
--- a/elbepack/toolchain.py
+++ b/elbepack/toolchain.py
@@ -9,6 +9,7 @@ import os
arch2triple = {"armhf": "arm-linux-gnueabihf", "armel": "arm-linux-gnueabi"}
+
class Toolchain:
libc_path = "${triple}/libc"
gcc_libpath = "${triple}/lib"
diff --git a/elbepack/treeutils.py b/elbepack/treeutils.py
index 5c7d14ef..01d860d2 100644
--- a/elbepack/treeutils.py
+++ b/elbepack/treeutils.py
@@ -9,6 +9,7 @@ from lxml.etree import XMLParser, parse
# ElementTree helpers
+
class eiter:
def __init__(self, it):
self.it = it
@@ -26,6 +27,7 @@ class eiter:
return elem(n)
+
class ebase:
def __init__(self, et):
self.et = et
diff --git a/elbepack/updated.py b/elbepack/updated.py
index 36c3cb83..38d41d5b 100644
--- a/elbepack/updated.py
+++ b/elbepack/updated.py
@@ -32,6 +32,7 @@ from elbepack.egpg import unsign_file
from elbepack.treeutils import etree
from elbepack.shellhelper import CommandError, system
+
class UpdateStatus:
# pylint: disable=too-many-instance-attributes
@@ -142,6 +143,7 @@ class UpdateService (ServiceBase):
self.app.status.monitor = Client(wsdl_url, timeout=cfg['soaptimeout'])
self.app.status.log("connection established")
+
class rw_access_file:
def __init__(self, filename, status):
self.filename = filename
@@ -158,6 +160,7 @@ class rw_access_file:
self.f.close()
self.rw.__exit__(typ, value, traceback)
+
class rw_access:
def __init__(self, directory, status):
self.status = status
diff --git a/elbepack/updated_monitors.py b/elbepack/updated_monitors.py
index 3d2385c0..36869d1c 100644
--- a/elbepack/updated_monitors.py
+++ b/elbepack/updated_monitors.py
@@ -10,6 +10,7 @@ import pyudev
from elbepack.updated import is_update_file, handle_update_file
+
class UpdateMonitor:
def __init__(self, status):
self.status = status
@@ -83,6 +84,7 @@ class USBMonitor (UpdateMonitor):
pass
return None
+
class FileMonitor (UpdateMonitor):
class EventHandler (pyinotify.ProcessEvent):
diff --git a/elbepack/validate.py b/elbepack/validate.py
index c8b29728..8baed754 100644
--- a/elbepack/validate.py
+++ b/elbepack/validate.py
@@ -31,6 +31,7 @@ def error_log_to_strings(error_log):
"behaviour, please specify <install-recommends /> !\n")
return errors
+
def validate_xml(fname):
if os.path.getsize(fname) > (1 << 30):
return [f"{fname} is greater than 1 GiB. "
@@ -65,7 +66,7 @@ def validate_xml_content(xml):
# we are probably fine
bootstrap_include = xml.findtext("/target/debootstrap/include", "")
if ("apt-transport-https" not in bootstrap_include
- and "ca-certificates" not in bootstrap_include):
+ and "ca-certificates" not in bootstrap_include):
# Check if primary mirror is using https
primary_proto = xml.findtext("/project/mirror/primary_proto", "")
@@ -82,9 +83,9 @@ def validate_xml_content(xml):
if is_primary_proto_https or has_https_urls:
errors.append("\nThe XML contains an HTTPS mirror. "
- "Use debootstrap/include "
- "to make apt-transport-https (stretch and older) "
- "or ca-certificates (buster and newer) available "
- "in debootstrap.\n")
+ "Use debootstrap/include "
+ "to make apt-transport-https (stretch and older) "
+ "or ca-certificates (buster and newer) available "
+ "in debootstrap.\n")
return errors
diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
index 4ada75c4..99965cba 100644
--- a/elbepack/virtapt.py
+++ b/elbepack/virtapt.py
@@ -62,6 +62,7 @@ def lookup_uri(v, d, target_pkg):
return target_pkg, uri, hashval
+
class VirtApt:
def __init__(self, xml):
@@ -156,7 +157,8 @@ class VirtApt:
# I could make a none global 'noauth' flag for mirrors
for i, url in enumerate(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])
+ key = "\n".join(line.strip(" \t")
+ for line in url.text('raw-key').splitlines()[1:-1])
self.add_key(unarmor_openpgp_keyring(key), f"elbe-virtapt-raw-key{i}.gpg")
def start(self):
diff --git a/elbepack/xmldefaults.py b/elbepack/xmldefaults.py
index a275c743..c8c03e06 100644
--- a/elbepack/xmldefaults.py
+++ b/elbepack/xmldefaults.py
@@ -185,6 +185,7 @@ defaults = {"armel": armel_defaults,
"riscv64": riscv64_defaults,
"nodefaults": {}}
+
def get_random_mac():
binaddr = [random.randint(0, 255) for _ in range(6)]
binaddr[0] &= 0xfe
@@ -193,6 +194,7 @@ def get_random_mac():
return ':'.join(s)
+
class ElbeDefaults:
def __init__(self, build_type):
diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
index bbd47ba6..dae12df4 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -11,7 +11,7 @@ import time
from optparse import OptionGroup
from itertools import islice
-from urllib.error import HTTPError,URLError
+from urllib.error import HTTPError, URLError
from urllib.request import urlopen
from passlib.hash import sha512_crypt
@@ -53,6 +53,7 @@ def preprocess_pgp_key(xml):
raise XMLPreprocessError(
f"Problem with PGP Key URL in <key> tag: {keyurl}")
+
def preprocess_bootstrap(xml):
"Replaces a maybe existing debootstrapvariant element with debootstrap"
@@ -76,6 +77,7 @@ def preprocess_bootstrap(xml):
old_node.getparent().replace(old_node, bootstrap)
+
def preprocess_tune2fs(xml):
"Replaces all maybe existing tune2fs elements with fs-finetuning command"
@@ -93,6 +95,7 @@ def preprocess_tune2fs(xml):
fs_node.remove(old_node)
+
def preprocess_iso_option(xml):
src_opts = xml.find(".//src-cdrom/src-opts")
@@ -137,6 +140,7 @@ def preprocess_initvm_ports(xml):
host.text == cfg['soapport'] and benv.text == '7588'):
forward.getparent().remove(forward)
+
def preprocess_proxy_add(xml, opt_proxy=None):
"""Add proxy to mirrors from CLI arguments or environment variable"""
@@ -159,11 +163,12 @@ def preprocess_proxy_add(xml, opt_proxy=None):
continue
# Add proxy to mirror
- proxy_e = Element(proxy_tag)
+ proxy_e = Element(proxy_tag)
proxy_e.text = set_proxy
mirror.append(proxy_e)
+
def preprocess_mirror_replacement(xml):
"""Do search and replace on mirror urls
The sed patterns are a space separate list
@@ -194,6 +199,7 @@ def preprocess_mirror_replacement(xml):
for r in replacements:
u.attrib['value'] = u.attrib['value'].replace(r[0], r[1])
+
def preprocess_mirrors(xml):
"""Insert a trusted=yes mirror option for all mirrors if <noauth> is
present. Also convert binary option <binary> [opts] url </binary>
@@ -256,14 +262,14 @@ def preprocess_mirrors(xml):
node.text = m.group(2)
# No <options>? Create it
- parent = node.getparent()
+ parent = node.getparent()
options = parent.find("options")
if options is None:
options = etree.Element("options")
parent.append(options)
# Adding subelement <option>
- option = etree.Element("option")
+ option = etree.Element("option")
option.text = opt
options.append(option)
@@ -294,6 +300,7 @@ def preprocess_passwd(xml):
"The generated sha512crypt hash only applies 5000 rounds for "
"backwards compatibility reasons. This is considered insecure nowadays.")
+
def xmlpreprocess(xml_input_file, xml_output_file, variants=None, proxy=None, gzip=9):
"""Preprocesses the input XML data to make sure the `output`
can be validated against the current schema.
diff --git a/test/updated.py b/test/updated.py
index 7395ed3b..3685f339 100755
--- a/test/updated.py
+++ b/test/updated.py
@@ -18,6 +18,7 @@ from spyne.server.wsgi import WsgiApplication
from suds.client import Client
+
class MonitorService (ServiceBase):
@rpc(String)
def msg(self, m):
--
2.43.0
More information about the elbe-devel
mailing list