[elbe-devel] [PATCH 09/13] commands/validate: check number of arguments
Manuel Traut
manuel.traut at linutronix.de
Fri Dec 8 17:42:35 CET 2017
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:]
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!
More information about the elbe-devel
mailing list