• Home
  • Raw
  • Download

Lines Matching +full:is +full:- +full:arguments

2 # Use of this source code is governed by a BSD-style license that can be
7 Arguments for the DUT deployment commands require more processing than
8 can readily be done by `ArgumentParser.parse_args()`. The post-parsing
9 validation process not only checks that arguments have allowable values,
10 but also may perform a dialog with the user to ask for missing arguments.
13 The interactive dialog is invoked if the board and hostnames are omitted
20 existing setting is retained.
38 # one build. The template is to be filled in with a board
41 _BUILD_URI_FORMAT = 'gs://chromeos-image-archive/%s-release/%s'
47 # is used to convert the recognized syntaxes into the name as
50 # _BUILD_PATTERNS describe the recognized syntaxes for user-supplied
54 # For user-supplied build versions, the following forms are supported:
55 # #### - Indicates a canary; equivalent to ####.0.0.
56 # ####.#.# - A full build version without the leading R##- prefix.
57 # R##-###.#.# - Canonical form of a build version.
60 (re.compile(r'^R\d+-\d+\.\d+\.\d+$'), None),
61 (re.compile(r'^\d+\.\d+\.\d+$'), 'LATEST-%s'),
62 (re.compile(r'^\d+$'), 'LATEST-%s.0.0'),
72 re.compile(r'chromeos\d+-row\d+-rack\d+-host\d+')
90 files (e.g. "LATEST-7356.0.0"), or it could refer to a build
91 artifact (e.g. "R46-7356.0.0/image.zip").
93 The function constructs the full GS URI from the arguments, and
115 """Convert a user-supplied build version to canonical form.
117 Canonical form looks like R##-####.#.#, e.g. R46-7356.0.0.
118 Acceptable user-supplied forms are describe under
128 `_BUILD_PATTERNS` is a list of tuples. The first element of the
129 tuple is an RE describing a valid user input. The second
130 element of the tuple is a format pattern for a "LATEST" filename
133 is `None`, the user supplied build version is already in canonical
145 if fmt is not None:
166 "LATEST-main" file in its release builder's directory.
169 on stderr in certain failure cases. This is currently useful
178 if board is None:
182 if _build_path_exists(board, 'LATEST-main'):
193 on stderr in certain failure cases. This is currently useful
199 build may be in a user-specified (non-canonical)
208 'Build %s is not a valid build version for %s.\n' %
214 """Return whether a given hostname is valid for the test lab.
216 This is a validity check meant to guarantee that host names follow
220 on stderr in certain failure cases. This is currently useful
225 @return Return a true value iff the hostname is valid.
237 """Check that the hostname file is valid.
239 The hostname file is deemed valid if:
240 - the file exists.
241 - the file is non-empty.
245 @return `True` if the hostname file is valid, False otherse.
250 def _validate_arguments(arguments): argument
251 """Check command line arguments, and account for defaults.
253 Check that all command-line argument constraints are satisfied.
260 @param arguments Parsed results from
266 if arguments.hostnames and arguments.hostname_file:
271 if (arguments.hostname_file and
272 not _is_hostname_file_valid(arguments.hostname_file)):
274 'Specified hostname file must exist and be non-empty.\n')
276 if (not arguments.hostnames and not arguments.hostname_file and
277 (arguments.board or arguments.build)):
281 if arguments.board is not None:
282 if not _validate_board(arguments.board):
284 if (arguments.build is not None and
285 not _validate_build(arguments.board, arguments.build)):
293 @param input File-like object from which to read the line.
307 line is blank and `default_board` is a non-empty string, returns
308 `default_board`. Retry until a valid input is obtained.
310 `default_board` isn't checked; the caller is responsible for
313 @param input File-like object from which to read the
338 return the canonical build version. If the line is blank,
341 @param input File-like object from which to read the build.
361 line is blank and `default_model` is a non-empty string, returns
362 `default_model`. Retry until a valid input is obtained.
364 `default_model` isn't checked; the caller is responsible for
367 @param input File-like object from which to read the
394 lines are allowed; input is terminated at the first blank line.
399 ignored, and a warning is printed.
401 @param input File-like object from which to read the names.
423 def _read_arguments(input, arguments): argument
424 """Dialog to read all needed arguments from the user.
426 The user is prompted in turn for a board, a build, a model, and
427 hostnames. Responses are stored in `arguments`. The user is
431 @param input File-like object from which to read user
433 @param arguments Namespace object returned from
439 arguments.board = _read_board(input, arguments.board)
440 arguments.build = _read_build(input, arguments.board)
441 arguments.model = _read_model(input, arguments.model)
443 arguments.board, arguments.build)
445 arguments.hostnames = _read_hostnames(input)
455 @returns a NamedTuple of (hostname, host_attr_dict). host_attr_dict is a
478 def _get_upload_basename(arguments): argument
481 @param arguments Namespace object returned from argument parsing.
484 time_format = '%Y-%m-%dT%H%M%S.%f%z'
487 return '{time}-{board}'.format(time=timestamp, board=arguments.board)
496 @returns a list of dicts where each line is broken down into a dict.
512 def validate_arguments(arguments): argument
513 """Validate parsed arguments for a repair or deployment command.
515 The `arguments` parameter represents a `Namespace` object returned
516 by `cmdparse.parse_command()`. Check this for mandatory arguments;
520 Once all arguments are known to be filled in, validate the values,
524 @param arguments Standard `Namespace` object as returned by
527 if not arguments.board or not arguments.model:
528 _read_arguments(sys.stdin, arguments)
529 elif not _validate_arguments(arguments):
532 arguments.upload_basename = _get_upload_basename(arguments)
533 if not arguments.logdir:
534 arguments.logdir = os.path.join(os.environ['HOME'],
536 arguments.upload_basename)
537 os.makedirs(arguments.logdir)
538 elif not os.path.isdir(arguments.logdir):
539 os.mkdir(arguments.logdir)
541 if arguments.hostname_file:
542 # Populate arguments.hostnames with the hostnames from the file.
543 hostname_file_info_list = _parse_hostname_file(arguments.hostname_file)
544 arguments.hostnames = [host_info.hostname
546 arguments.host_info_list = hostname_file_info_list
548 arguments.host_info_list = []
549 return arguments