summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-01-18 14:22:45 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-19 17:24:47 +0000
commit3bb6ea63fc2a1b5f7eb7023653de0880ff25f29d (patch)
treebed48b18c28ad544fa05a181477874f361176ecf
parentd652203b2f2ebc316d9989b88a7b11e78cf0738f (diff)
downloadopenembedded-core-contrib-3bb6ea63fc2a1b5f7eb7023653de0880ff25f29d.tar.gz
openembedded-core-contrib-3bb6ea63fc2a1b5f7eb7023653de0880ff25f29d.tar.bz2
openembedded-core-contrib-3bb6ea63fc2a1b5f7eb7023653de0880ff25f29d.zip
wic: override ArgumentParser.error
Overriden error method to throw exception instead of printing usage error message. Exception is caught by KickStart code to add .ks file name and line number. (From OE-Core rev: 373016ba08c2ec4dbcd44649d9c8cd57d5574402) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/wic/kickstart.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/scripts/lib/wic/kickstart.py b/scripts/lib/wic/kickstart.py
index 5d3a572a77..7dbe052714 100644
--- a/scripts/lib/wic/kickstart.py
+++ b/scripts/lib/wic/kickstart.py
@@ -34,6 +34,14 @@ from wic.partition import Partition
class KickStartError(Exception):
pass
+class KickStartParser(ArgumentParser):
+ """
+ This class overwrites error method to throw exception
+ instead of producing usage message(default argparse behavior).
+ """
+ def error(self, message):
+ raise ArgumentError(None, message)
+
def sizetype(arg):
"""
Custom type for ArgumentParser
@@ -77,7 +85,7 @@ class KickStart(object):
self.bootloader = None
self.lineno = 0
- parser = ArgumentParser()
+ parser = KickStartParser()
subparsers = parser.add_subparsers()
part = subparsers.add_parser('part')