[elbe-devel] [PATCH 11/32] Add logging to stdout for command fetch_initvm_pkgs

dion at linutronix.de dion at linutronix.de
Fri Jun 14 22:13:25 CEST 2019


From: Olivier Dion <dion at linutronix.de>

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/commands/fetch_initvm_pkgs.py | 44 +++++++++++-----------------------
 1 file changed, 14 insertions(+), 30 deletions(-)

diff --git a/elbepack/commands/fetch_initvm_pkgs.py b/elbepack/commands/fetch_initvm_pkgs.py
index b252179f..564616d4 100644
--- a/elbepack/commands/fetch_initvm_pkgs.py
+++ b/elbepack/commands/fetch_initvm_pkgs.py
@@ -14,10 +14,11 @@ from apt import Cache
 
 from elbepack.elbexml import ElbeXML, ValidationError
 from elbepack.repomanager import CdromInitRepo, CdromSrcRepo
-from elbepack.asciidoclog import StdoutLog
 from elbepack.dump import get_initvm_pkglist
 from elbepack.aptprogress import ElbeAcquireProgress
 from elbepack.filesystem import hostfs
+from elbepack.log import log
+from elbepack.shellhelper import do
 
 
 def run_command(argv):
@@ -72,11 +73,11 @@ def run_command(argv):
         print("xml validation failed. Bailing out")
         sys.exit(20)
 
-    log = StdoutLog()
+    log.stdout()
 
     if opt.cdrom_path:
         if opt.cdrom_device:
-            log.do('mount "%s" "%s"' % (opt.cdrom_device, opt.cdrom_path))
+            do('mount "%s" "%s"' % (opt.cdrom_device, opt.cdrom_path))
 
         # a cdrom build is identified by the cdrom option
         # the xml file that is copied into the initvm
@@ -98,6 +99,7 @@ def run_command(argv):
         cache = Cache()
         cache.open()
         for pkg in pkglist:
+            pkg_id = "%s-%s" % (pkg.name, pkg.installed_version)
             try:
                 p = cache[pkg.name]
                 pkgver = p.installed
@@ -105,21 +107,12 @@ def run_command(argv):
                                           ElbeAcquireProgress(cb=None))
                 repo.includedeb(deb, 'main')
             except ValueError:
-                log.printo("No Package " + pkg.name +
-                           "-" + str(pkg.installed_version))
+                log.error('No package "%s"' % pkg_id)
             except FetchError:
-                log.printo(
-                    "Package " +
-                    pkg.name +
-                    "-" +
-                    pkgver.version +
-                    " could not be downloaded")
+                log.error('Package "%s-%s" could not be downloaded' % (pkg.name,
+                                                                       pkgver.version))
             except TypeError:
-                log.printo("Package " +
-                           pkg.name +
-                           "-" +
-                           str(pkg.installed_version) +
-                           " missing name or version")
+                log.error('Package "%s" missing name or version' % pkg_id)
 
     repo.finalize()
 
@@ -137,6 +130,7 @@ def run_command(argv):
 
     if opt.build_sources:
         for pkg in pkglist:
+            pkg_id = "%s-%s" % (pkg.name, pkg.installed_version)
             try:
                 p = cache[pkg.name]
                 pkgver = p.installed
@@ -145,23 +139,13 @@ def run_command(argv):
                                           unpack=False)
                 repo.include_init_dsc(dsc, 'initvm')
             except ValueError:
-                log.printo("No Package " + pkg.name +
-                           "-" + str(pkg.installed_version))
+                log.error('No package "%s"' % pkg_id)
             except FetchError:
-                log.printo(
-                    "Package " +
-                    pkg.name +
-                    "-" +
-                    pkgver.version +
-                    " could not be downloaded")
+                log.error('Package "%s-%s" could not be downloaded', % (pkg.name, pkgver.version))
             except TypeError:
-                log.printo("Package " +
-                           pkg.name +
-                           "-" +
-                           str(pkg.installed_version) +
-                           " missing name or version")
+                log.error('Package "%s" missing name or version' % pkg_id)
 
     repo.finalize()
 
     if opt.cdrom_device:
-        log.do('umount "%s"' % opt.cdrom_device)
+        do('umount "%s"' % opt.cdrom_device)
-- 
2.11.0




More information about the elbe-devel mailing list