From d050c77bfbe55feaebc98fc56943033248957d4c Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 15 Jul 2020 12:28:34 +0200 Subject: [PATCH] osbuild: make monitor configurable via comandline Introduce two new command line arguments, which can be used to specify which monitor class to use (`--monitor`) and what file descriptor to use for monitoring (`--monitor-fd`). The latter defaults to standard out. The monitor class, if not specified, is depended on the `--json` argument. --- osbuild/main_cli.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osbuild/main_cli.py b/osbuild/main_cli.py index 0a353e9c..786d8a76 100644 --- a/osbuild/main_cli.py +++ b/osbuild/main_cli.py @@ -80,6 +80,10 @@ def parse_arguments(sys_argv): help="directory where result objects are stored") parser.add_argument("--inspect", action="store_true", help="return the manifest in JSON format including all the ids") + parser.add_argument("--monitor", metavar="NAME", default=None, + help="Name of the monitor to be used") + parser.add_argument("--monitor-fd", metavar="FD", type=int, default=sys.stdout.fileno(), + help="File descriptor to be used for the monitor") parser.add_argument("--stage-timeout", type=int, default=None, help="set the maximal time (in seconds) each stage is allowed to run") @@ -140,8 +144,10 @@ def osbuild_cli(): print("Need --output-directory for --export") return 1 - monitor_name = "NullMonitor" if args.json else "LogMonitor" - monitor = osbuild.monitor.make(monitor_name, sys.stdout.fileno()) + monitor_name = args.monitor + if not monitor_name: + monitor_name = "NullMonitor" if args.json else "LogMonitor" + monitor = osbuild.monitor.make(monitor_name, args.monitor_fd) try: with ObjectStore(args.store) as object_store: