mirror of
https://git.yoctoproject.org/poky
synced 2026-04-03 02:02:21 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
d652203b2f
commit
3bb6ea63fc
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user