cbuildbot: Remove site_config from arg parsing.
If we plan to use command line arguments to fetch the site_config,
then we need to parse those options without a site_config. Rearrange
existing code to do that.
BUG=chromium:497284
TEST=Unittests.
Change-Id: I4106fd44781e48e1740a988f383c2d856fb3dfa0
Reviewed-on: https://chromium-review.googlesource.com/282786
Trybot-Ready: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Matthew Sartori <msartori@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 1a0a063..bee84f0 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -843,6 +843,10 @@
args: The args returned by optparse.
site_config: config_lib.SiteConfig containing all config info.
"""
+ if not args:
+ parser.error('Invalid usage: no configuration targets provided.'
+ 'Use -h to see usage. Use -l to list supported configs.')
+
if not options.branch:
options.branch = git.GetChromiteTrackingBranch()
@@ -923,7 +927,7 @@
'`cbuildbot --list --all`')
-def _ParseCommandLine(parser, argv, site_config):
+def _ParseCommandLine(parser, argv):
"""Completely parse the commandline arguments"""
(options, args) = parser.parse_args(argv)
@@ -936,16 +940,6 @@
print(constants.REEXEC_API_VERSION)
sys.exit(0)
- if options.list:
- if args:
- cros_build_lib.Die('No arguments expected with the --list options.')
- _PrintValidConfigs(site_config, options.print_all)
- sys.exit(0)
-
- if not args:
- parser.error('Invalid usage: no configuration targets provided.'
- 'Use -h to see usage. Use -l to list supported configs.')
-
_FinishParsing(options, args)
return options, args
@@ -1041,7 +1035,11 @@
os.umask(0o22)
parser = _CreateParser()
- (options, args) = _ParseCommandLine(parser, argv, site_config)
+ options, args = _ParseCommandLine(parser, argv)
+
+ if options.list:
+ _PrintValidConfigs(site_config, options.print_all)
+ sys.exit(0)
_PostParseCheck(parser, options, args, site_config)