[elbe-devel] [PATCH v4 13/41] Add logging to stdout and project for command gen_update
Torben Hohn
torben.hohn at linutronix.de
Wed Aug 7 12:02:01 CEST 2019
On Mon, Jul 08, 2019 at 05:18:09PM +0200, dion at linutronix.de wrote:
> From: Olivier Dion <dion at linutronix.de>
>
> make use of the new logging system, and replace all print() with
> functions from logging and wrap it in
> "with elbe_logging({"streams":sys.stdout}):" and
> "with elbe_logging({"projects":project.builddir}):"
>
> Signed-off-by: Olivier Dion <dion at linutronix.de>
Acked-by: Torben Hohn <torben.hohn at linutronix.de>
logging to project from a command is useful, but its confusing,
if the command does not output stuff to stdout.
please prepare a patch, that also makes it log the project stuff to
stdout.
but since time is precious now, we dont want to have this queue delayed
by this...
> ---
> elbepack/commands/gen_update.py | 46 +++++++++++++++++++++--------------------
> 1 file changed, 24 insertions(+), 22 deletions(-)
>
> diff --git a/elbepack/commands/gen_update.py b/elbepack/commands/gen_update.py
> index bc5e3bd2..8e9dac81 100644
> --- a/elbepack/commands/gen_update.py
> +++ b/elbepack/commands/gen_update.py
> @@ -10,11 +10,13 @@ from __future__ import print_function
>
> from optparse import OptionParser
> import sys
> -import os.path
> +import os
> +import logging
>
> 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,24 +74,24 @@ 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({"streams":sys.stdout}):
> + try:
> + project = ElbeProject(opt.target, name=opt.name,
> + override_buildtype=buildtype,
> + skip_validate=opt.skip_validation)
> + except ValidationError:
> + logging.exception("XML validation failed. Bailing out")
> + sys.exit(20)
>
> if opt.presh_file:
> if not os.path.isfile(opt.presh_file):
> - print('pre.sh file does not exist')
> + logging.error('pre.sh file does not exist')
> sys.exit(20)
> project.presh_file = opt.presh_file
>
> if opt.postsh_file:
> if not os.path.isfile(opt.postsh_file):
> - print('post.sh file does not exist')
> + logging.error('post.sh file does not exist')
> sys.exit(20)
> project.postsh_file = opt.postsh_file
>
> @@ -97,15 +99,15 @@ 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({"projects":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:
> + logging.exception("XML validation failed. Bailing out")
> + sys.exit(20)
> + except MissingData:
> + logging.exception("Missing Data")
> + sys.exit(20)
> --
> 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