From 1dc30cc60a5d78e2a8f56fda7842262b55187e08 Mon Sep 17 00:00:00 2001 From: Caleb Connolly <caleb.connolly@linaro.org> Date: Sun, 11 Feb 2024 16:08:40 +0000 Subject: [PATCH] Use stderr for status prints (MR 2) This allows ttq to be used in scripts more easily. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org> --- ttq/args.py | 2 +- ttq/print.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ttq/args.py b/ttq/args.py index c447bfa..411e4c9 100644 --- a/ttq/args.py +++ b/ttq/args.py @@ -55,7 +55,7 @@ def parse_args_query_soc(): for soc in ttq.wiki.SOCS: if search_str in soc.lower(): devices = ttq.wiki.parse_soc_devices(soc) - print(f"Found {len(devices)} device(s) with {soc}") + print(f"Found {len(devices)} device(s) with {soc}", file=sys.stderr) ARGS_QUERY_SOCS[soc] = devices # Put devices in ARGS_QUERY_DEVICES so ttq.match.by_device() can use it diff --git a/ttq/print.py b/ttq/print.py index d521e94..1174787 100644 --- a/ttq/print.py +++ b/ttq/print.py @@ -1,5 +1,7 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later + +import sys import ttq.match @@ -22,7 +24,8 @@ def by_ui(): print() print(f"Matched {len(ttq.match.UIS_MATCHED)} user interfaces," - f" {len(ttq.match.USERS_MATCHED)} {ttq.args.ARGS_USER_TYPE} users.") + f" {len(ttq.match.USERS_MATCHED)} {ttq.args.ARGS_USER_TYPE} users.", + file=sys.stderr) def by_device(): @@ -32,7 +35,8 @@ def by_device(): print() print(f"Matched {len(ttq.match.DEVICES_MATCHED)} devices," - f" {len(ttq.match.USERS_MATCHED)} {ttq.args.ARGS_USER_TYPE} users.") + f" {len(ttq.match.USERS_MATCHED)} {ttq.args.ARGS_USER_TYPE} users.", + file=sys.stderr) def by_soc(): @@ -45,7 +49,8 @@ def by_soc(): print() print(f"Matched {len(ttq.match.SOCS_MATCHED)} SoCs," f" {len(ttq.match.DEVICES_MATCHED)} devices," - f" {len(ttq.match.USERS_MATCHED)} {ttq.args.ARGS_USER_TYPE} users.") + f" {len(ttq.match.USERS_MATCHED)} {ttq.args.ARGS_USER_TYPE} users.", + file=sys.stderr) def notes(): notes = ttq.match.NOTES_MATCHED -- GitLab