Received: from eggs.gnu.org ([2001:4830:134:3::10]:55675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmP81-0005uR-Qt for qemu-devel@nongnu.org; Tue, 20 Sep 2016 13:46:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmP7y-0005z9-JK for qemu-devel@nongnu.org; Tue, 20 Sep 2016 13:46:45 -0400 Received: from roura.ac.upc.edu ([147.83.33.10]:47180 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmP7y-0005yi-7U for qemu-devel@nongnu.org; Tue, 20 Sep 2016 13:46:42 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <1474296549-29171-1-git-send-email-berrange@redhat.com> <1474296549-29171-18-git-send-email-berrange@redhat.com> <87intr4ut0.fsf@fimbulvetr.bsc.es> <20160920135548.GN25490@redhat.com> Date: Tue, 20 Sep 2016 19:46:41 +0200 In-Reply-To: <20160920135548.GN25490@redhat.com> (Daniel P. Berrange's message of "Tue, 20 Sep 2016 14:55:48 +0100") Message-ID: <87eg4ev4zi.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 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: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Stefan Hajnoczi Daniel P Berrange writes: > 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_na= me]) >>=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 in= 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" Oh, I'm sorry. I should've looked more closely into the code. Cheers, Lluis