[elbe-devel] [PATCH v2 20/28] Nuke ASCIIDocLog from finetuning

Torben Hohn torben.hohn at linutronix.de
Wed Jun 26 16:06:54 CEST 2019


On Fri, Jun 21, 2019 at 07:40:12PM +0200, dion at linutronix.de wrote:
> From: Olivier Dion <dion at linutronix.de>
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>


> ---
>  elbepack/dump.py        |   2 +-
>  elbepack/elbeproject.py |   1 -
>  elbepack/finetuning.py  | 265 +++++++++++++++++++++++-------------------------
>  3 files changed, 127 insertions(+), 141 deletions(-)
> 
> diff --git a/elbepack/dump.py b/elbepack/dump.py
> index d73b3789..20b0bf4b 100644
> --- a/elbepack/dump.py
> +++ b/elbepack/dump.py
> @@ -217,7 +217,7 @@ def elbe_report(xml, buildenv, cache, reportname, errorname, targetfs):
>      outf.verbatim_start()
>  
>      if xml.has("target/finetuning"):
> -        do_finetuning(xml, outf, buildenv, targetfs)
> +        do_finetuning(xml, buildenv, targetfs)
>          mt_index_post_fine = targetfs.mtime_snap()
>      else:
>          mt_index_post_fine = mt_index_postarch
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index 046bcbf5..0269a638 100644
> --- a/elbepack/elbeproject.py
> +++ b/elbepack/elbeproject.py
> @@ -651,7 +651,6 @@ class ElbeProject (object):
>                  allow_fail=True)
>  
>          do_prj_finetuning(self.xml,
> -                          self.log,
>                            self.buildenv,
>                            self.targetfs,
>                            self.builddir)
> diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
> index 5da50b1f..d1ddf5fe 100644
> --- a/elbepack/finetuning.py
> +++ b/elbepack/finetuning.py
> @@ -11,6 +11,7 @@ from __future__ import print_function
>  import os
>  import errno
>  import base64
> +import logging
>  
>  from shutil import rmtree
>  from gpg import core
> @@ -23,6 +24,7 @@ from elbepack.shellhelper import CommandError
>  from elbepack.filesystem import ImgMountFilesystem
>  from elbepack.packers import default_packer, packers
>  from elbepack.egpg import unlock_key
> +from elbepack.shellhelper import chroot, do, get_command_out
>  
>  
>  class FinetuningException(Exception):
> @@ -44,11 +46,11 @@ class FinetuningAction(object):
>      def __init__(self, node):
>          self.node = node
>  
> -    def execute(self, _log, _buildenv, _target):
> +    def execute(self, _buildenv, _target):
>          raise NotImplementedError('execute() not implemented')
>  
> -    def execute_prj(self, log, buildenv, target, _builddir):
> -        self.execute(log, buildenv, target)
> +    def execute_prj(self, buildenv, target, _builddir):
> +        self.execute(buildenv, target)
>  
>  
>  class ImageFinetuningAction(FinetuningAction):
> @@ -58,11 +60,11 @@ class ImageFinetuningAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, _log, _buildenv, _target):
> +    def execute(self, _buildenv, _target):
>          raise NotImplementedError("<%s> may only be "
>                                    "used in <image-finetuning>" % self.tag)
>  
> -    def execute_img(self, _log, _buildenv, _target, _builddir, _loop_dev):
> +    def execute_img(self, _buildenv, _target, _builddir, _loop_dev):
>          raise NotImplementedError('execute_img() not implemented')
>  
>  
> @@ -73,7 +75,7 @@ class RmAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          files = target.glob(self.node.et.text)
>  
>          if 'exclude' in self.node.et.attrib:
> @@ -85,7 +87,7 @@ class RmAction(FinetuningAction):
>              if os.path.basename(f) in exclude:
>                  continue
>  
> -            log.do("rm -rvf '%s'" % f)
> +            do("rm -rvf '%s'" % f)
>  
>  
>  FinetuningAction.register(RmAction)
> @@ -98,8 +100,8 @@ class MkdirAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> -        log.do("mkdir -p " + target.fname(self.node.et.text))
> +    def execute(self, _buildenv, target):
> +        do("mkdir -p %s" % target.fname(self.node.et.text))
>  
>  
>  FinetuningAction.register(MkdirAction)
> @@ -112,13 +114,10 @@ class MknodAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> -        log.do(
> -            "mknod " +
> -            target.fname(
> -                self.node.et.text) +
> -            " " +
> -            self.node.et.attrib['opts'])
> +    def execute(self, _buildenv, target):
> +        cmd = "mknod %s %s" % (target.fname(self.node.et.text),
> +                               self.node.et.attrib['opts'])
> +        do(cmd)
>  
>  
>  FinetuningAction.register(MknodAction)
> @@ -131,8 +130,8 @@ class BuildenvMkdirAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, buildenv, _target):
> -        log.do("mkdir -p " + buildenv.rfs.fname(self.node.et.text))
> +    def execute(self, buildenv, _target):
> +        do("mkdir -p %s" % buildenv.rfs.fname(self.node.et.text))
>  
>  
>  FinetuningAction.register(BuildenvMkdirAction)
> @@ -145,10 +144,11 @@ class CpAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          src = target.glob(self.node.et.attrib['path'])
>          for f in src:
> -            log.do("cp -av " + f + " " + target.fname(self.node.et.text))
> +            cmd = "cp -av %s %s" % (f, target.fname(self.node.et.text))
> +            do(cmd)
>  
>  
>  FinetuningAction.register(CpAction)
> @@ -161,10 +161,14 @@ class BuildenvCpAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, buildenv, _target):
> +    def execute(self, buildenv, _target):
>          src = buildenv.glob(self.node.et.attrib['path'])
>          for f in src:
> -            log.do("cp -av " + f + " " + buildenv.rfs.fname(self.node.et.text))
> +            # Does buildenv.rfs.fname(self.node.et.text) change in the
> +            # loop?  If not we can format the cmd outside of the loop
> +            # outside and make a smaller format in the loop.
> +            cmd = "cp -av %s %s" % (f, buildenv.rfs.fname(self.node.et.text))
> +            do(cmd)
>  
>  
>  FinetuningAction.register(BuildenvCpAction)
> @@ -177,10 +181,11 @@ class B2TCpAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, buildenv, target):
> +    def execute(self, buildenv, target):
>          src = buildenv.rfs.glob(self.node.et.attrib['path'])
>          for f in src:
> -            log.do("cp -av " + f + " " + target.fname(self.node.et.text))
> +            cmd = "cp -av %s %s" % (f, target.fname(self.node.et.text))
> +            do(cmd)
>  
>  
>  FinetuningAction.register(B2TCpAction)
> @@ -193,10 +198,11 @@ class T2BCpAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, buildenv, target):
> +    def execute(self, buildenv, target):
>          src = target.glob(self.node.et.attrib['path'])
>          for f in src:
> -            log.do("cp -av " + f + " " + buildenv.rfs.fname(self.node.et.text))
> +            cmd = "cp -av %s %s" % (f, buildenv.rfs.fname(self.node.et.text))
> +            do(cmd)
>  
>  
>  FinetuningAction.register(T2BCpAction)
> @@ -209,7 +215,7 @@ class T2PMvAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          if self.node.et.text[0] == '/':
>              dest = self.node.et.text[1:]
>          else:
> @@ -217,8 +223,9 @@ class T2PMvAction(FinetuningAction):
>          dest = os.path.join('..', dest)
>  
>          src = target.glob(self.node.et.attrib['path'])
> +        cmd = "mv -v %s {}".format(dest)
>          for f in src:
> -            log.do("mv -v " + f + " " + dest)
> +            do(cmd % f)
>  
>  
>  FinetuningAction.register(T2PMvAction)
> @@ -231,10 +238,11 @@ class MvAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          src = target.glob(self.node.et.attrib['path'])
>          for f in src:
> -            log.do("mv -v " + f + " " + target.fname(self.node.et.text))
> +            cmd = "mv -v %s %s" % (f, target.fname(self.node.et.text))
> +            do(cmd)
>  
>  
>  FinetuningAction.register(MvAction)
> @@ -247,12 +255,11 @@ class LnAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          with target:
> -            log.chroot(
> -                target.path, """/bin/sh -c 'ln -s %s "%s"' """ %
> -                (self.node.et.attrib['path'], self.node.et.text))
> -
> +            cmd = """/bin/sh -c 'ln -s %s "%s"' """ % (self.node.et.attrib['path'],
> +                                                       self.node.et.text)
> +            chroot(target.path, cmd)
>  
>  FinetuningAction.register(LnAction)
>  
> @@ -264,11 +271,11 @@ class BuildenvMvAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, buildenv, _target):
> +    def execute(self, buildenv, _target):
>          src = buildenv.rfs.glob(self.node.et.attrib['path'])
> +        cmd = "mv -v %s %s"
>          for f in src:
> -            log.do("mv -v " + f + " " + buildenv.rfs.fname(self.node.et.text))
> -
> +            do(cmd % (f, buildenv.rfs.fname(self.node.et.text)))
>  
>  FinetuningAction.register(BuildenvMvAction)
>  
> @@ -280,7 +287,7 @@ class AddUserAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          with target:
>              att = self.node.et.attrib
>              options = ""
> @@ -305,18 +312,14 @@ class AddUserAction(FinetuningAction):
>              else:
>                  options += '-U '
>  
> -            log.chroot(
> -                target.path,
> -                '/usr/sbin/useradd %s "%s"' %
> -                (options,
> -                 self.node.et.text))
> +            cmd =  '/usr/sbin/useradd %s "%s"' % (options,
> +                                                  self.node.et.text)
> +            chroot(target.path, cmd)
>  
>              if 'passwd' in att:
> -                log.chroot(target.path,
> -                           """/bin/sh -c 'echo "%s\\n%s\\n" | passwd %s'""" % (
> -                               att['passwd'],
> -                               att['passwd'],
> -                               self.node.et.text))
> +                cmd = "passwd %s" % self.node.et.text
> +                stdin = "%s\n%s\n" % (att["passwd"], att["passwd"])
> +                chroot(target.path, cmd, stdin=stdin)
>  
>  
>  FinetuningAction.register(AddUserAction)
> @@ -329,7 +332,7 @@ class AddGroupAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          with target:
>              att = self.node.et.attrib
>              # we use -f always
> @@ -338,9 +341,9 @@ class AddGroupAction(FinetuningAction):
>                  options += '-g "%s" ' % att['gid']
>              if 'system' in att and att['system'] == 'True':
>                  options += '-r'
> -            log.chroot(target.path, '/usr/sbin/groupadd %s "%s"' % (
> -                options,
> -                self.node.et.text))
> +            cmd = '/usr/sbin/groupadd %s "%s"' % (options,
> +                                                  self.node.et.text)
> +            chroot(target.path, cmd)
>  
>  
>  FinetuningAction.register(AddGroupAction)
> @@ -365,7 +368,7 @@ class AddFileAction(FinetuningAction):
>              raise FinetuningException("Invalid encoding %s" % encoding)
>          return msg
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>  
>          att = self.node.et.attrib
>          dst = att["dst"]
> @@ -398,13 +401,13 @@ class AddFileAction(FinetuningAction):
>              target.write_file(dst, None, content)
>  
>          if owner is not None:
> -            log.chroot(target.path, 'chown "%s" "%s"' % (owner, dst))
> +            chroot(target.path, "chown %s %s" % (owner, dst))
>  
>          if group is not None:
> -            log.chroot(target.path, 'chgrp "%s" "%s"' % (group, dst))
> +            chroot(target.path, "chgrp %s %s" % (group, dst))
>  
>          if mode is not None:
> -            log.chroot(target.path, 'chmod "%s" "%s"' % (mode, dst))
> +            chroot(target.path, "chmod %s %s" % (mode, dst))
>  
>  FinetuningAction.register(AddFileAction)
>  
> @@ -416,9 +419,9 @@ class RawCmdAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          with target:
> -            log.chroot(target.path, self.node.et.text)
> +            chroot(target.path, self.node.et.text)
>  
>  
>  FinetuningAction.register(RawCmdAction)
> @@ -431,9 +434,9 @@ class CmdAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          with target:
> -            log.chroot(target.path, "/bin/sh", stdin=self.node.et.text)
> +            chroot(target.path, "/bin/sh", stdin=self.node.et.text)
>  
>  
>  FinetuningAction.register(CmdAction)
> @@ -446,9 +449,9 @@ class BuildenvCmdAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, buildenv, _target):
> +    def execute(self, buildenv, _target):
>          with buildenv:
> -            log.chroot(buildenv.path, "/bin/sh", stdin=self.node.et.text)
> +            chroot(buildenv.path, "/bin/sh", stdin=self.node.et.text)
>  
>  
>  FinetuningAction.register(BuildenvCmdAction)
> @@ -461,9 +464,9 @@ class PurgeAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          with target:
> -            log.chroot(target.path, "dpkg --purge " + self.node.et.text)
> +            chroot(target.path, "dpkg --purge %s" % (self.node.et.text))
>  
>  
>  FinetuningAction.register(PurgeAction)
> @@ -476,13 +479,14 @@ class UpdatedAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, log, buildenv, target):
> +    def execute(self, buildenv, target):
>  
>          # pylint: disable=too-many-locals
>  
>          if self.node.et.text:
>              fp = self.node.et.text
> -            log.printo("transfer gpg key to target: " + fp)
> +
> +            logging.info("transfert gpg key to target: %s" % fp)
>  
>              gpgdata = core.Data()
>              ctx = core.Context()
> @@ -495,22 +499,23 @@ class UpdatedAction(FinetuningAction):
>              gpgdata.seek(0, os.SEEK_SET)
>              key = gpgdata.read()
>  
> -            log.printo(str(key))
> +            logging.info(str(key))
>              with open((target.path + '/pub.key'), 'wb') as tkey:
>                  tkey.write(key)
>  
>              target.mkdir_p("/var/cache/elbe/gnupg", mode=0o700)
>              with target:
>                  env_add = {'GNUPGHOME': target.path + "/var/cache/elbe/gnupg"}
> -                log.do("gpg --import " + target.path + "/pub.key",
> -                       env_add=env_add)
> +                cmd = "gpg --import %s%s" % (target.path, "/pub.key")
> +                do(cmd, env_add=env_add)
> +
> +        logging.info("generate base repo")
>  
> -        log.printo("generate base repo")
>          arch = target.xml.text("project/arch", key="arch")
>  
>          buildenv.rfs.mkdir_p('/tmp/pkgs')
>          with buildenv:
> -            cache = get_rpcaptcache(buildenv.rfs, "updated-repo.log", arch)
> +            cache = get_rpcaptcache(buildenv.rfs, arch)
>  
>              pkglist = cache.get_installed_pkgs()
>              for pkg in pkglist:
> @@ -518,26 +523,14 @@ class UpdatedAction(FinetuningAction):
>                      cache.download_binary(
>                          pkg.name, '/tmp/pkgs', pkg.installed_version)
>                  except ValueError:
> -                    log.printo(
> -                        "No Package " +
> -                        pkg.name +
> -                        "-" +
> -                        pkg.installed_version)
> +                    logging.exception("No package %s-%s" % (pkg.name,
> +                                                            pkg.installed_version))
>                  except FetchError:
> -                    log.printo(
> -                        "Package " +
> -                        pkg.name +
> -                        "-" +
> -                        pkg.installed_version +
> -                        " could not be downloaded")
> +                    logging.exception("Package %s-%s could not be downloaded" % (pkg.name,
> +                                                                         pkg.installed_version))
>                  except TypeError:
> -                    log.printo(
> -                        "Package " +
> -                        pkg.name +
> -                        "-" +
> -                        pkg.installed_version +
> -                        " missing name or version")
> -
> +                    logging.exception("Package %s-%s missing name or version" % (pkg.name,
> +                                                                                 pkg.installed_version))
>          r = UpdateRepo(target.xml,
>                         target.path + '/var/cache/elbe/repos/base')
>  
> @@ -569,10 +562,10 @@ class ArtifactAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, _log, _buildenv, target):
> +    def execute(self, _buildenv, target):
>          target.images.append('target' + self.node.et.text)
>  
> -    def execute_prj(self, _log, _buildenv, target, _builddir):
> +    def execute_prj(self, _buildenv, target, _builddir):
>          target.images.append(self.node.et.text)
>  
>  
> @@ -586,11 +579,11 @@ class RmArtifactAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, _log, _buildenv, _target):
> +    def execute(self, _buildenv, _target):
>          raise NotImplementedError("<rm_artifact> may only be "
>                                    "used in <project-finetuning>")
>  
> -    def execute_prj(self, _log, _buildenv, target, _builddir):
> +    def execute_prj(self, _buildenv, target, _builddir):
>          target.images.remove(self.node.et.text)
>  
>  
> @@ -604,23 +597,23 @@ class LosetupAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, _log, _buildenv, _target):
> +    def execute(self, _buildenv, _target):
>          raise NotImplementedError("<losetup> may only be "
>                                    "used in <project-finetuning>")
>  
> -    def execute_prj(self, log, buildenv, target, builddir):
> +    def execute_prj(self, buildenv, target, builddir):
>          imgname = self.node.et.attrib['img']
>          imgpath = os.path.join(builddir, imgname)
>          cmd = 'losetup --find --show --partscan "%s"' % imgpath
>  
> -        loop_dev = log.get_command_out(cmd).strip()
> +        loop_dev = get_command_out(cmd).strip()
>          try:
>              for i in self.node:
>                  action = ImageFinetuningAction(i)
> -                action.execute_img(log, buildenv, target, builddir, loop_dev)
> +                action.execute_img(buildenv, target, builddir, loop_dev)
>          finally:
>              cmd = 'losetup --detach "%s"' % loop_dev
> -            log.do(cmd)
> +            do(cmd)
>  
>  
>  FinetuningAction.register(LosetupAction)
> @@ -633,20 +626,18 @@ class ImgConvertAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, _log, _buildenv, _target):
> +    def execute(self, _buildenv, _target):
>          raise NotImplementedError("<img_convert> may only be "
>                                    "used in <project-finetuning>")
>  
> -    def execute_prj(self, log, _buildenv, target, builddir):
> +    def execute_prj(self, _buildenv, target, builddir):
>          src = self.node.et.text
>          dst = self.node.et.attrib['dst']
>          fmt = self.node.et.attrib['fmt']
>  
>          if src not in target.images:
> -            log.printo("Error: Artifact '%s' does not exist." % src)
> -            log.printo("Valid Artifacts are:")
> -            for i in target.images:
> -                log.printo(i)
> +            logging.error("Error: Artifact '%s' does not exist.\n Valid Artifcact are: %s" % (
> +                      src, ", ".join([str(i) for i in target.images])))
>              raise FinetuningException("Artifact '%s' does not exist" % src)
>  
>          src_fname = os.path.join(builddir, src)
> @@ -655,7 +646,7 @@ class ImgConvertAction(FinetuningAction):
>          cmd = 'qemu-img convert -O "%s" "%s" "%s"' % (fmt,
>                                                        src_fname,
>                                                        dst_fname)
> -        log.do(cmd)
> +        do(cmd)
>  
>          target.images.append(dst)
>          target.image_packers[dst] = default_packer
> @@ -675,11 +666,11 @@ class SetPackerAction(FinetuningAction):
>      def __init__(self, node):
>          FinetuningAction.__init__(self, node)
>  
> -    def execute(self, _log, _buildenv, _target):
> +    def execute(self, _buildenv, _target):
>          raise NotImplementedError("<set_packer> may only be "
>                                    "used in <project-finetuning>")
>  
> -    def execute_prj(self, _log, _buildenv, target, _builddir):
> +    def execute_prj(self, _buildenv, target, _builddir):
>          img = self.node.et.text
>          packer = self.node.et.attrib['packer']
>  
> @@ -696,17 +687,17 @@ class ExtractPartitionAction(ImageFinetuningAction):
>      def __init__(self, node):
>          ImageFinetuningAction.__init__(self, node)
>  
> -    def execute(self, _log, _buildenv, _target):
> +    def execute(self, _buildenv, _target):
>          raise NotImplementedError("<extract_partition> may only be "
>                                    "used in <mount_drive>")
>  
> -    def execute_img(self, log, _buildenv, target, builddir, loop_dev):
> +    def execute_img(self, _buildenv, target, builddir, loop_dev):
>          part_nr = self.node.et.attrib['part']
>          imgname = os.path.join(builddir, self.node.et.text)
>  
>          cmd = 'dd if=%sp%s of="%s"' % (loop_dev, part_nr, imgname)
>  
> -        log.do(cmd)
> +        do(cmd)
>  
>          target.images.append(self.node.et.text)
>          target.image_packers[self.node.et.text] = default_packer
> @@ -722,32 +713,30 @@ class CopyFromPartition(ImageFinetuningAction):
>      def __init__(self, node):
>          ImageFinetuningAction.__init__(self, node)
>  
> -    def execute(self, _log, _buildenv, _target):
> +    def execute(self, _buildenv, _target):
>          raise NotImplementedError("<copy_from_partition> may only be "
>                                    "used in <mount_drive>")
>  
> -    def execute_img(self, log, _buildenv, target, builddir, loop_dev):
> +    def execute_img(self, _buildenv, target, builddir, loop_dev):
>          part_nr = self.node.et.attrib['part']
>          aname = self.node.et.attrib['artifact']
>  
>          img_mnt = os.path.join(builddir, 'imagemnt')
>          device = "%sp%s" % (loop_dev, part_nr)
>  
> -        with ImgMountFilesystem(img_mnt, device, log) as mnt_fs:
> +        with ImgMountFilesystem(img_mnt, device) as mnt_fs:
>              fname = mnt_fs.glob(self.node.et.text)
>  
>              if not fname:
> -                log.printo('No file matching "%s" found' % self.node.et.text)
> +                logging.error('No file matching "%s" found' % self.node.et.text)
>                  raise FinetuningException('No File found')
>  
>              if len(fname) > 1:
> -                log.printo('Pattern "%s" matches %d files' % (
> -                    self.node.et.text,
> -                    len(fname)))
> +                logging.info('Pattern "%s" matches %d files' % (self.node.et.text, len(fname)))
>                  raise FinetuningException('Patter matches too many files')
>  
>              cmd = 'cp "%s" "%s"' % (fname[0], os.path.join(builddir, aname))
> -            log.do(cmd)
> +            do(cmd)
>  
>              target.images.append(aname)
>  
> @@ -762,28 +751,27 @@ class CopyToPartition(ImageFinetuningAction):
>      def __init__(self, node):
>          ImageFinetuningAction.__init__(self, node)
>  
> -    def execute(self, _log, _buildenv, _target):
> +    def execute(self, _buildenv, _target):
>          raise NotImplementedError("<copy_to_partition> may only be "
>                                    "used in <mount_drive>")
>  
> -    def execute_img(self, log, _buildenv, _target, builddir, loop_dev):
> +    def execute_img(self, _buildenv, _target, builddir, loop_dev):
>          part_nr = self.node.et.attrib['part']
>          aname = self.node.et.attrib['artifact']
>  
>          img_mnt = os.path.join(builddir, 'imagemnt')
>          device = "%sp%s" % (loop_dev, part_nr)
>  
> -        with ImgMountFilesystem(img_mnt, device, log) as mnt_fs:
> +        with ImgMountFilesystem(img_mnt, device) as mnt_fs:
>              fname = mnt_fs.fname(self.node.et.text)
> -
>              cmd = 'cp "%s" "%s"' % (os.path.join(builddir, aname), fname)
> -            log.do(cmd)
> +            do(cmd)
>  
>  
>  FinetuningAction.register(CopyToPartition)
>  
>  
> -def do_finetuning(xml, log, buildenv, target):
> +def do_finetuning(xml, buildenv, target):
>  
>      if not xml.has('target/finetuning'):
>          return
> @@ -791,17 +779,16 @@ def do_finetuning(xml, log, buildenv, target):
>      for i in xml.node('target/finetuning'):
>          try:
>              action = FinetuningAction(i)
> -            action.execute(log, buildenv, target)
> +            action.execute(buildenv, target)
>          except KeyError:
> -            print("Unimplemented finetuning action '%s'" % (i.et.tag))
> +            logging.exception("Unimplemented finetuning action '%s'" % (i.et.tag))
>          except CommandError:
> -            log.printo("Finetuning Error, trying to continue anyways")
> -        except FinetuningException as e:
> -            log.printo("Finetuning Error: %s" % str(e))
> -            log.printo("trying to continue anyways")
> -
> +            logging.exception("Finetuning Error, trying to continue anyways")
> +        except FinetuningException:
> +            logging.exception("Finetuning Error\n"
> +                              "Trying to continue anyways")
>  
> -def do_prj_finetuning(xml, log, buildenv, target, builddir):
> +def do_prj_finetuning(xml, buildenv, target, builddir):
>  
>      if not xml.has('target/project-finetuning'):
>          return
> @@ -809,11 +796,11 @@ def do_prj_finetuning(xml, log, buildenv, target, builddir):
>      for i in xml.node('target/project-finetuning'):
>          try:
>              action = FinetuningAction(i)
> -            action.execute_prj(log, buildenv, target, builddir)
> +            action.execute_prj(buildenv, target, builddir)
>          except KeyError:
> -            print("Unimplemented project-finetuning action '%s'" % (i.et.tag))
> +            logging.exception("Unimplemented project-finetuning action '%s'" % (i.et.tag))
>          except CommandError:
> -            log.printo("ProjectFinetuning Error, trying to continue anyways")
> -        except FinetuningException as e:
> -            log.printo("ProjectFinetuning Error: %s" % e.message)
> -            log.printo("trying to continue anyways")
> +            logging.exception("ProjectFinetuning Error, trying to continue anyways")
> +        except FinetuningException:
> +            logging.exception("Finetuning Error\n"
> +                              "Trying to continue anyways")
> -- 
> 2.11.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