]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: improve processing of parseing errors
authorEd Bartosh <ed.bartosh@linux.intel.com>
Mon, 18 Jan 2016 12:22:43 +0000 (14:22 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 19 Jan 2016 16:35:38 +0000 (16:35 +0000)
Caught argparse.ArgumentError
Included .ks file name and line number into the error messages.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/wic/kickstart.py

index 7f0105dd071f5050318caa98a1053cfe6972379e..5d3a572a77621a12b70f4f2837361109bc723967 100644 (file)
@@ -27,7 +27,7 @@
 
 
 import shlex
-from argparse import ArgumentParser, ArgumentTypeError
+from argparse import ArgumentParser, ArgumentError, ArgumentTypeError
 
 from wic.partition import Partition
 
@@ -113,11 +113,16 @@ class KickStart(object):
                 line = line.strip()
                 lineno += 1
                 if line and line[0] != '#':
-                    parsed = parser.parse_args(shlex.split(line))
+                    try:
+                        parsed = parser.parse_args(shlex.split(line))
+                    except ArgumentError as err:
+                        raise KickStartError('%s:%d: %s' % \
+                                             (confpath, lineno, err))
                     if line.startswith('part'):
                         self.partitions.append(Partition(parsed, lineno))
                     else:
                         if not self.bootloader:
                              self.bootloader = parsed
                         else:
-                             raise KickStartError("Error: more than one bootloader specified")
+                             raise KickStartError("%s:%d: more than one bootloader "\
+                                                  "specified" % (confpath, lineno))