diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2016-01-18 14:22:45 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-19 16:35:38 +0000 |
commit | 373016ba08c2ec4dbcd44649d9c8cd57d5574402 (patch) | |
tree | d972004af79c3da5734161063a595106b59f5e56 /scripts/lib/wic | |
parent | 33d8784470c506fabcf9627e754628cdea61dd07 (diff) | |
download | openembedded-core-373016ba08c2ec4dbcd44649d9c8cd57d5574402.tar.gz openembedded-core-373016ba08c2ec4dbcd44649d9c8cd57d5574402.tar.bz2 openembedded-core-373016ba08c2ec4dbcd44649d9c8cd57d5574402.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.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r-- | scripts/lib/wic/kickstart.py | 10 |
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') |