[elbe-devel] [PATCH v3 27/52] Add logging to opt.log for command mkcdrom
dion at linutronix.de
dion at linutronix.de
Thu Jun 27 14:44:41 CEST 2019
From: Olivier Dion <dion at linutronix.de>
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/commands/mkcdrom.py | 104 +++++++++++++++++++++----------------------
1 file changed, 51 insertions(+), 53 deletions(-)
diff --git a/elbepack/commands/mkcdrom.py b/elbepack/commands/mkcdrom.py
index f00e9645..6387bd17 100644
--- a/elbepack/commands/mkcdrom.py
+++ b/elbepack/commands/mkcdrom.py
@@ -11,11 +11,12 @@ from __future__ import print_function
from optparse import OptionParser
import sys
import os
+import logging
from elbepack.elbeproject import ElbeProject
from elbepack.elbexml import ValidationError
-from elbepack.asciidoclog import StdoutLog, ASCIIDocLog
from elbepack.efilesystem import ChRootFilesystem
+from elbepack.log import elbe_logging
from elbepack.cdroms import mk_source_cdrom, mk_binary_cdrom, CDROM_SIZE
@@ -61,56 +62,53 @@ def run_command(argv):
oparser.print_help()
sys.exit(20)
- if not opt.rfs_only:
- try:
- project = ElbeProject(args[0], logpath=opt.log,
- override_buildtype=opt.buildtype,
- skip_validate=opt.skip_validation)
- except ValidationError as e:
- print(str(e), file=sys.stderr)
- print("xml validation failed. Bailing out", file=sys.stderr)
- sys.exit(20)
-
- builddir = project.builddir
- rfs = project.buildenv.rfs
- xml = project.xml
- arch = xml.text("project/arch", key="arch")
- codename = xml.text("project/suite")
- log = project.log
- init_codename = xml.get_initvm_codename()
- else:
- builddir = os.path.abspath(os.path.curdir)
- rfs = ChRootFilesystem(args[0])
- arch = opt.arch
- codename = opt.codename
- init_codename = opt.init_codename
- xml = None
- if opt.log:
- log = ASCIIDocLog(opt.log)
+ stdout = True
+ if opt.log:
+ stdout = False
+
+ with elbe_logging(builddir=opt.log, stdout=stdout):
+
+ if not opt.rfs_only:
+ try:
+ project = ElbeProject(args[0], logpath=opt.log,
+ override_buildtype=opt.buildtype,
+ skip_validate=opt.skip_validation)
+ except ValidationError:
+ logging.exception("XML validation failed. Bailing out")
+ sys.exit(20)
+
+ builddir = project.builddir
+ rfs = project.buildenv.rfs
+ xml = project.xml
+ arch = xml.text("project/arch", key="arch")
+ codename = xml.text("project/suite")
+ init_codename = xml.get_initvm_codename()
else:
- log = StdoutLog()
-
- generated_files = []
- if opt.source:
- with rfs:
- generated_files += mk_source_cdrom(rfs, arch, codename,
- init_codename, builddir, log,
- opt.cdrom_size)
-
- if opt.binary:
- with rfs:
- generated_files += mk_binary_cdrom(rfs,
- arch,
- codename,
- init_codename,
- xml,
- builddir,
- log,
- opt.cdrom_size)
-
- print("")
- print("Image Build finished !")
- print("")
- print("Files generated:")
- for f in generated_files:
- print(" %s" % f)
+ builddir = os.path.abspath(os.path.curdir)
+ rfs = ChRootFilesystem(args[0])
+ arch = opt.arch
+ codename = opt.codename
+ init_codename = opt.init_codename
+ xml = None
+
+ generated_files = []
+ if opt.source:
+ with rfs:
+ generated_files += mk_source_cdrom(rfs, arch, codename,
+ init_codename, builddir, log,
+ opt.cdrom_size)
+
+ if opt.binary:
+ with rfs:
+ generated_files += mk_binary_cdrom(rfs,
+ arch,
+ codename,
+ init_codename,
+ xml,
+ builddir,
+ log,
+ opt.cdrom_size)
+
+ logging.info("Image Build finished.\n")
+ logging.info("Files generated:\n%s",
+ "\n".join([str(f) for f in generated_files]))
--
2.11.0
More information about the elbe-devel
mailing list