From nobody Mon Feb 9 17:34:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608049582; cv=none; d=zohomail.com; s=zohoarc; b=npOy8ftZrTt028bNDbmPt2AG8Q/V/D4LIIR3g+/+bnxPU9ZW8poVWzyAw3SoM//yVnZPf8OXF+wBR6LFG2t4Yn79qVcQVH3Nk/dZaexEwuI58aEAOdroPHfzE7wvQ7JwrD4cT82nVdWMlbQOg/J+imTmt9LEduGMFqKgKwv6BPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608049582; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6fh1oxxD7PEBP0gC3Eqzh38ifholsjTFIm5VQG9tz0Y=; b=Y7GlLbLBvHWuVTJ4ZN9FrrNzM79Astreh5FRwWFFZKlvc+niQrxsViPIVjalZq3ZPrztc16w6zWksMj1VB8hfgAmynVXtwHNDpe4+XLUCNHUeySCVonpmlst2AZ5vbQX05rK+eLpcmb/WOI6vpIdMtxVSb7TNrLqLAzhJ/j+2Ow= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1608049582844675.3761780964953; Tue, 15 Dec 2020 08:26:22 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-335-QLcxpp2ZMw66LgJo1qLHOQ-1; Tue, 15 Dec 2020 11:26:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 76A4410051A8; Tue, 15 Dec 2020 16:26:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F6035C224; Tue, 15 Dec 2020 16:26:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 12A7D1809CA0; Tue, 15 Dec 2020 16:26:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BFGPmWx025901 for ; Tue, 15 Dec 2020 11:25:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 06FEF5D9E3; Tue, 15 Dec 2020 16:25:48 +0000 (UTC) Received: from work.redhat.com (ovpn-114-20.ams2.redhat.com [10.36.114.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 477E55DA34; Tue, 15 Dec 2020 16:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608049579; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6fh1oxxD7PEBP0gC3Eqzh38ifholsjTFIm5VQG9tz0Y=; b=b2lKP3hTLFjSjFFkfsSzKltxlChx25oO1abOESVK1ZxmvSdnD60bVwSRJbMCj+KhBITWNv mXDH66hrQe7Ttg97mCMk2ed3wzqTBcTLW1esHHrPTklLKKif7fO11y9YYwHk1ZGwwAbCsZ 69ww8+wwyNxlRvC9kMZagUXR/c5Iz9A= X-MC-Unique: QLcxpp2ZMw66LgJo1qLHOQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 27/29] cpu-gather: Allow gathering and parsing data in one step. Date: Tue, 15 Dec 2020 17:25:13 +0100 Message-Id: <20201215162515.53742-28-twiederh@redhat.com> In-Reply-To: <20201215162515.53742-1-twiederh@redhat.com> References: <20201215162515.53742-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Make ./cpu-gather.py --gather --parse an alias of ./cpu-gather.py [--gather] | ./cpu-gather.py --parse Signed-off-by: Tim Wiederhake --- tests/cputestdata/cpu-gather.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/cputestdata/cpu-gather.py b/tests/cputestdata/cpu-gather= .py index fe660c486e..46997c8a48 100755 --- a/tests/cputestdata/cpu-gather.py +++ b/tests/cputestdata/cpu-gather.py @@ -282,9 +282,7 @@ def output_json(data, filename): f.write("\n") =20 =20 -def parse(args): - data =3D json.load(sys.stdin) - +def parse(data): filename =3D parse_filename(data) filename_xml =3D "{}.xml".format(filename) filename_json =3D "{}.json".format(filename) @@ -320,16 +318,16 @@ def main(): help=3D"Path to qemu. " "If unset, will try '/usr/bin/qemu-system-x86_64', " "'/usr/bin/qemu-kvm', and '/usr/libexec/qemu-kvm'.") - - mode =3D parser.add_mutually_exclusive_group() - mode.add_argument( + parser.add_argument( "--gather", action=3D"store_true", - help=3D"Acquire data on target system. This is the default.") - mode.add_argument( + help=3D"Acquire data on target system. This is the default. " + "If '--parse' is not set, outputs data on stdout.") + parser.add_argument( "--parse", action=3D"store_true", - help=3D"Parse data for libvirt use.") + help=3D"Parse data for libvirt use. " + "If '--gather' is not set, expects input on stdin.") =20 args =3D parser.parse_args() =20 @@ -348,9 +346,13 @@ def main(): =20 if args.gather: data =3D gather(args) - json.dump(data, sys.stdout, indent=3D2) - else: - parse(args) + if not args.parse: + json.dump(data, sys.stdout, indent=3D2) + + if args.parse: + if not args.gather: + data =3D json.load(sys.stdin) + parse(data) =20 =20 if __name__ =3D=3D "__main__": --=20 2.26.2