From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmLWf-0008Ur-NT for qemu-devel@nongnu.org; Tue, 20 Sep 2016 09:56:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmLWa-0000rh-Bb for qemu-devel@nongnu.org; Tue, 20 Sep 2016 09:55:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmLWa-0000rH-4D for qemu-devel@nongnu.org; Tue, 20 Sep 2016 09:55:52 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 865D27F7CB for ; Tue, 20 Sep 2016 13:55:51 +0000 (UTC) Date: Tue, 20 Sep 2016 14:55:48 +0100 From: "Daniel P. Berrange" Message-ID: <20160920135548.GN25490@redhat.com> Reply-To: "Daniel P. Berrange" References: <1474296549-29171-1-git-send-email-berrange@redhat.com> <1474296549-29171-18-git-send-email-berrange@redhat.com> <87intr4ut0.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87intr4ut0.fsf@fimbulvetr.bsc.es> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 17/18] trace: pass trace-events to tracetool as a positional param List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Stefan Hajnoczi On Mon, Sep 19, 2016 at 08:18:51PM +0200, Llu=C3=ADs Vilanova wrote: > Daniel P Berrange writes: >=20 > > Instead of reading the contents of 'trace-events' from stdin, > > accept the filename as a positional parameter. This also > > allows for reading from multiple files, though this facility > > is not used at this time. >=20 > > Signed-off-by: Daniel P. Berrange > > --- > > Makefile.target | 6 +++--- > > scripts/tracetool.py | 5 ++++- > > trace/Makefile.objs | 18 +++++++++--------- > > 3 files changed, 16 insertions(+), 13 deletions(-) >=20 > > diff --git a/scripts/tracetool.py b/scripts/tracetool.py > > index 6accbbf..f66e767 100755 > > --- a/scripts/tracetool.py > > +++ b/scripts/tracetool.py > > @@ -129,7 +129,10 @@ def main(args): > > if probe_prefix is None: > > probe_prefix =3D ".".join(["qemu", target_type, target_n= ame]) > =20 > > - events =3D tracetool.read_events(sys.stdin) > > + if len(args) !=3D 1: > > + error_opt("missing trace-events filepath") > > + with open(args[0], "r") as fh: > > + events =3D tracetool.read_events(fh) > =20 > I'm not sure that's the proper way to check for a positional argument i= n getopt > (iff it accepts optional args mingled with positional ones). 'args' comes from the return value of getopt.getopt(sys.argv) which is documented as: "The return value consists of two elements: the first is a list of (option, value) pairs; the second is the list of program arguments left after the option list was stripped (this is a trailing slice of args" Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|