summaryrefslogtreecommitdiffstats
path: root/scripts
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 /scripts
parentd652203b2f2ebc316d9989b88a7b11e78cf0738f (diff)
downloadpoky-3bb6ea63fc2a1b5f7eb7023653de0880ff25f29d.tar.gz
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>
Diffstat (limited to 'scripts')
-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
34class KickStartError(Exception): 34class KickStartError(Exception):
35 pass 35 pass
36 36
37class KickStartParser(ArgumentParser):
38 """
39 This class overwrites error method to throw exception
40 instead of producing usage message(default argparse behavior).
41 """
42 def error(self, message):
43 raise ArgumentError(None, message)
44
37def sizetype(arg): 45def sizetype(arg):
38 """ 46 """
39 Custom type for ArgumentParser 47 Custom type for ArgumentParser
@@ -77,7 +85,7 @@ class KickStart(object):
77 self.bootloader = None 85 self.bootloader = None
78 self.lineno = 0 86 self.lineno = 0
79 87
80 parser = ArgumentParser() 88 parser = KickStartParser()
81 subparsers = parser.add_subparsers() 89 subparsers = parser.add_subparsers()
82 90
83 part = subparsers.add_parser('part') 91 part = subparsers.add_parser('part')