[elbe-devel] [PATCH v2 11/28] Add logging to stdout for command gen_update

dion at linutronix.de dion at linutronix.de
Fri Jun 21 19:40:03 CEST 2019


From: Olivier Dion <dion at linutronix.de>

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/commands/gen_update.py | 43 ++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/elbepack/commands/gen_update.py b/elbepack/commands/gen_update.py
index bc5e3bd2..d569673a 100644
--- a/elbepack/commands/gen_update.py
+++ b/elbepack/commands/gen_update.py
@@ -10,11 +10,12 @@ from __future__ import print_function
 
 from optparse import OptionParser
 import sys
-import os.path
+import os
 
 from elbepack.elbeproject import ElbeProject
 from elbepack.elbexml import ValidationError
 from elbepack.updatepkg import gen_update_pkg, MissingData
+from elbepack.log import elbe_logging
 
 
 def run_command(argv):
@@ -72,14 +73,15 @@ def run_command(argv):
     else:
         buildtype = None
 
-    try:
-        project = ElbeProject(opt.target, name=opt.name,
-                              override_buildtype=buildtype,
-                              skip_validate=opt.skip_validation)
-    except ValidationError as e:
-        print(str(e))
-        print("xml validation failed. Bailing out")
-        sys.exit(20)
+    with elbe_logging(stdout=True):
+        try:
+            project = ElbeProject(opt.target, name=opt.name,
+                                  override_buildtype=buildtype,
+                                  skip_validate=opt.skip_validation)
+        except ValidationError as e:
+            print(str(e))
+            print("xml validation failed. Bailing out")
+            sys.exit(20)
 
     if opt.presh_file:
         if not os.path.isfile(opt.presh_file):
@@ -97,15 +99,16 @@ def run_command(argv):
     if len(args) >= 1:
         update_xml = args[0]
 
-    try:
-        gen_update_pkg(project, update_xml, opt.output, buildtype,
-                       opt.skip_validation, opt.debug,
-                       cfg_dir=opt.cfg_dir, cmd_dir=opt.cmd_dir)
+    with elbe_logging(project.builddir):
+        try:
+            gen_update_pkg(project, update_xml, opt.output, buildtype,
+                           opt.skip_validation, opt.debug,
+                           cfg_dir=opt.cfg_dir, cmd_dir=opt.cmd_dir)
 
-    except ValidationError as e:
-        print(str(e))
-        print("xml validation failed. Bailing out")
-        sys.exit(20)
-    except MissingData as e:
-        print(str(e))
-        sys.exit(20)
+        except ValidationError as e:
+            print(str(e))
+            print("xml validation failed. Bailing out")
+            sys.exit(20)
+        except MissingData as e:
+            print(str(e))
+            sys.exit(20)
-- 
2.11.0




More information about the elbe-devel mailing list