[elbe-devel] [PATCH 09/13] commands/validate: check number of arguments

Torben Hohn torben.hohn at linutronix.de
Mon Dec 11 08:50:10 CET 2017


On Fri, Dec 08, 2017 at 05:42:35PM +0100, Manuel Traut wrote:
> 
> On Tue, Dec 05, 2017 at 04:57:55PM +0100, Torben Hohn wrote:
> > On Thu, Nov 30, 2017 at 03:15:11PM +0100, Manuel Traut wrote:
> > > to avoid outofindex exception if no filename is given
> > > 
> > > Signed-off-by: Manuel Traut <manut at linutronix.de>
> > > ---
> > >  elbepack/commands/validate.py | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > > 
> > > diff --git a/elbepack/commands/validate.py b/elbepack/commands/validate.py
> > > index f9ff4e86..99a6368b 100644
> > > --- a/elbepack/commands/validate.py
> > > +++ b/elbepack/commands/validate.py
> > > @@ -30,6 +30,10 @@ def run_command( argv ):
> > >  
> > >      (opt,args) = oparser.parse_args(sys.argv)
> > this is not good. ^^
> > the elbe commands are supposed to parse their argv parameter.
> > should be:  (opt,args) = oparser.parse_args(argv)
> > 
> > getting these straight, means, that the following gets:
> > 
> > s/3/1/
> > s/2/0/
> 
> yeah, that's nicer.
> 
> > >  
> > > +    if len(args) < 3:
> > > +        oparser.print_help()
> > > +        sys.exit(20)
> > > +
> > >      if not os.path.exists(args[2]):
> > >          print ("%s - file not found" % args[2])
> > >          oparser.print_help()
> > 
> > I see several sys.argv cargo culted:
> > 
> > elbepack/commands/control.py:    (opt,args) = oparser.parse_args (sys.argv)
> > elbepack/commands/initvm.py:    (opt,args) = oparser.parse_args (sys.argv)
> > elbepack/commands/pbuilder.py:    (opt,args) = oparser.parse_args (sys.argv)
> > elbepack/commands/prjrepo.py:    (opt, args) = oparser.parse_args(sys.argv)
> > elbepack/commands/validate.py:    (opt,args) = oparser.parse_args(sys.argv)
> > 
> > All of them need fixes.
> 
> nope; they use
> 
> (opt,args) = oparser.parse_args (sys.argv)
> args = args[2:]

yes. and that works currently. But thats not how its SUPPOSED to work.
run_command has a parameter. and thats where its supposed to get its
arguments from.




> 
> but, using argv in parse_args is better
> 
> i'll post a v2 with the proper fix for all files.
> 
> > 
> > -- 
> > Mit freundlichen Grüßen
> > Torben Hohn
> > 
> > Linutronix GmbH
> > 
> > Standort: Bremen
> > 
> > Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
> > 
> > Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
> > Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
> > Nr. / Trade register no.: 700 806
> > 
> > Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner
> > 
> > Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
> > benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
> > möglich ist, durch Antwort-Mail. Vielen Dank!
> 
> 

-- 
Mit freundlichen Grüßen
Torben Hohn

Linutronix GmbH

Standort: Bremen

Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806

Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner

Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20171211/3bf137f7/attachment.sig>


More information about the elbe-devel mailing list