diff options
author | 2022-03-04 16:29:38 +0100 | |
---|---|---|
committer | 2022-03-08 10:44:12 +0000 | |
commit | 4d7df2ab4204cf92babcd4eebc27c62e5631be67 (patch) | |
tree | 04629add943c581ceba628af04c7899d5aa9d2dc /build | |
parent | 055aa4b41b5c58f23b9948286c9306cee103d7d4 (diff) |
[BUILD] Improve docker images download script testability
Command line argument parsing routine now returns raw ArgumentParser
object for easier instantiation in test routines.
Change-Id: Icac599a6e72b0a7514a1a33d23624c44dc819b9b
Issue-ID: INT-1429
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'build')
-rwxr-xr-x | build/download/download.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/build/download/download.py b/build/download/download.py index 94cc1b54..d47462cf 100755 --- a/build/download/download.py +++ b/build/download/download.py @@ -78,14 +78,7 @@ def parse_args(): help='Check what is missing. No download.') parser.add_argument('--debug', action='store_true', default=False, help='Turn on debug output') - - args = parser.parse_args() - - for arg in ('docker', 'npm', 'http', 'rpm', 'git', 'pypi'): - if getattr(args, arg): - return args - - parser.error('One of --docker, --npm, --http, --rpm, --git or --pypi must be specified') + return parser def log_start(item_type): @@ -156,7 +149,15 @@ def run_cli(): if sys.version_info.major < 3: log.error('Unfortunately Python 2 is not supported for data download.') sys.exit(1) - args = parse_args() + + parser = parse_args() + args = parser.parse_args() + + for arg in ('docker', 'npm', 'http', 'rpm', 'git', 'pypi'): + if getattr(args, arg): + break + else: + parser.error('One of --docker, --npm, --http, --rpm, --git or --pypi must be specified') console_handler = logging.StreamHandler(sys.stdout) console_formatter = logging.Formatter('%(message)s') |