[elbe-devel] [PATCH 8/8] elbepack: log: use kwargs
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Fri Aug 9 14:47:23 CEST 2024
The logging setup function always take a single dict as argument.
This is the same as kwargs which are shorter and use less syntax.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/asyncworker.py | 2 +-
elbepack/commands/check-build.py | 2 +-
elbepack/commands/chroot.py | 2 +-
elbepack/commands/fetch_initvm_pkgs.py | 2 +-
elbepack/commands/gen_update.py | 4 ++--
elbepack/log.py | 2 +-
elbepack/shellhelper.py | 8 ++++----
7 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
index 126ae79b6943..b009ab6cb9ec 100644
--- a/elbepack/asyncworker.py
+++ b/elbepack/asyncworker.py
@@ -554,7 +554,7 @@ class AsyncWorker(Thread):
job = self.queue.get()
if job is not None:
with savecwd():
- with elbe_logging({'projects': job.project.builddir}):
+ with elbe_logging(projects=job.project.builddir):
job.execute(self.db)
else:
loop = False
diff --git a/elbepack/commands/check-build.py b/elbepack/commands/check-build.py
index 68cba1b1c34a..ff6f44e267c7 100644
--- a/elbepack/commands/check-build.py
+++ b/elbepack/commands/check-build.py
@@ -46,7 +46,7 @@ def run_command(argv):
directory = pathlib.Path(args.build_dir)
- with elbe_logging({'streams': None}):
+ with elbe_logging(streams=None):
for test in tests:
diff --git a/elbepack/commands/chroot.py b/elbepack/commands/chroot.py
index 4c05f0ed7057..ae54069b7094 100644
--- a/elbepack/commands/chroot.py
+++ b/elbepack/commands/chroot.py
@@ -28,7 +28,7 @@ def run_command(argv):
args = aparser.parse_args(argv)
- with elbe_logging({'streams': sys.stdout}):
+ with elbe_logging(streams=sys.stdout):
try:
project = ElbeProject(args.builddir,
override_buildtype=args.buildtype,
diff --git a/elbepack/commands/fetch_initvm_pkgs.py b/elbepack/commands/fetch_initvm_pkgs.py
index 2dd712a1f40c..51f500e1af27 100644
--- a/elbepack/commands/fetch_initvm_pkgs.py
+++ b/elbepack/commands/fetch_initvm_pkgs.py
@@ -70,7 +70,7 @@ def run_command(argv):
print('xml validation failed. Bailing out')
sys.exit(47)
- with elbe_logging({'streams': sys.stdout}), contextlib.ExitStack() as stack:
+ with elbe_logging(streams=sys.stdout), contextlib.ExitStack() as stack:
if args.cdrom_path:
if args.cdrom_device:
diff --git a/elbepack/commands/gen_update.py b/elbepack/commands/gen_update.py
index 7effc8201f34..d92b7a8d61e6 100644
--- a/elbepack/commands/gen_update.py
+++ b/elbepack/commands/gen_update.py
@@ -57,7 +57,7 @@ def run_command(argv):
if not args.output:
aparser.error('No output file specified')
- with elbe_logging({'streams': sys.stdout}):
+ with elbe_logging(streams=sys.stdout):
try:
project = ElbeProject(args.target, name=args.name,
override_buildtype=args.buildtype,
@@ -82,7 +82,7 @@ def run_command(argv):
if len(args) >= 1:
update_xml = args[0]
- with elbe_logging({'projects': project.builddir}):
+ with elbe_logging(projects=project.builddir):
try:
gen_update_pkg(project, update_xml, args.output, args.uildtype,
args.skip_validation, args.debug,
diff --git a/elbepack/log.py b/elbepack/log.py
index 22cda34a7dc7..afcf604d3afc 100644
--- a/elbepack/log.py
+++ b/elbepack/log.py
@@ -150,7 +150,7 @@ def elbe_logging(*args, **kwargs):
close_logging()
-def open_logging(targets):
+def open_logging(**targets):
close_logging()
diff --git a/elbepack/shellhelper.py b/elbepack/shellhelper.py
index ac68e84d8dcc..42ba8299fa30 100644
--- a/elbepack/shellhelper.py
+++ b/elbepack/shellhelper.py
@@ -43,7 +43,7 @@ def run(cmd, /, *, check=True, log_cmd=None, **kwargs):
>>> import os
>>> import sys
>>> from elbepack.log import open_logging
- >>> open_logging({"streams":os.devnull})
+ >>> open_logging(streams=os.devnull)
>>> run(['echo', 'ELBE'])
CompletedProcess(args=['echo', 'ELBE'], returncode=0)
@@ -68,7 +68,7 @@ def run(cmd, /, *, check=True, log_cmd=None, **kwargs):
Let's redirect the loggers to current stdout
>>> from elbepack.log import open_logging
- >>> open_logging({"streams":sys.stdout})
+ >>> open_logging(streams=sys.stdout)
>>> run(['echo', 'ELBE'], stdout=ELBE_LOGGING)
[CMD] echo ELBE
@@ -105,7 +105,7 @@ def do(cmd, /, *, env_add=None, **kwargs):
Let's redirect the loggers to current stdout
>>> import sys
>>> from elbepack.log import open_logging
- >>> open_logging({"streams":sys.stdout})
+ >>> open_logging(streams=sys.stdout)
>>> do("true")
[CMD] true
@@ -144,7 +144,7 @@ def chroot(directory, cmd, /, *, env_add=None, **kwargs):
>>> import sys
>>> from elbepack.log import open_logging
- >>> open_logging({"streams":sys.stdout})
+ >>> open_logging(streams=sys.stdout)
>>> chroot("/", "true") # doctest: +ELLIPSIS
Traceback (most recent call last):
--
2.46.0
More information about the elbe-devel
mailing list