[elbe-devel] [PATCH v3 21/52] Add logging to stdout for command gen_update
Torben Hohn
torben.hohn at linutronix.de
Fri Jul 5 11:03:09 CEST 2019
On Thu, Jun 27, 2019 at 02:44:35PM +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(stdout=True):"
> Signed-off-by: Olivier Dion <dion at linutronix.de>
Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> 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..224ddf98 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(stdout=True):
> + 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(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