Lines Matching +full:is +full:- +full:arguments
3 # Use of this source code is governed by a BSD-style license that can be
14 broken". The status determination is based on the history of
15 completed jobs for the DUT in a given time interval; still-running
20 A DUT's reported status is based on the DUT's job history in a time
21 interval determined by command line options. The interval is
23 --until/-u DATE/TIME - Specifies an end time for the search
25 --since/-s DATE/TIME - Specifies a start time for the search
27 --duration/-d HOURS - Specifies the length of the search interval
31 one option is provided, these defaults are used:
32 --until - Use the given end time with the default duration.
33 --since - Use the given start time with the default end time.
34 --duration - Use the given duration with the default end time.
38 DATE/TIME values are of the form '2014-11-06 17:21:34'.
42 By default, information is reported for DUTs named as command-line
43 arguments. Options are also available for selecting groups of
45 --board/-b BOARD - Only include hosts with the given board.
46 --pool/-p POOL - Only include hosts in the given pool. The user
52 -w/--working - Only include hosts in a working state.
53 -n/--broken - Only include hosts in a non-working state. Hosts
54 with no job history are considered non-working.
69 * With the --working or --broken options, the list of host names
70 is the default format.
71 * Without those options, the default format is the one-line status
75 -o/--oneline - Use the one-line summary with the --working or
76 --broken options.
77 -f/--full_history - Print detailed per-host job history.
78 -g/--diagnosis - Print the job history surrounding a status
83 $ dut_status chromeos2-row4-rack2-host12
85 chromeos2-row4-rack2-host12 NO 2014-11-06 15:25:29 http://...
87 'NO' means the DUT is broken. That diagnosis is based on a job that
88 failed: 'last checked' is the time of the failed job, and the URL
91 $ dut_status.py -u '2014-11-06 15:30:00' -d 1 -f chromeos2-row4-rack2-host12
92 chromeos2-row4-rack2-host12
93 2014-11-06 15:25:29 NO http://...
94 2014-11-06 14:44:07 -- http://...
95 2014-11-06 14:42:56 OK http://...
102 '--' Indicates that the job probably didn't change the DUT's
105 to report 'OK', or the first job to report '--'.
128 # _DIAGNOSIS_IDS -
133 status_history.UNKNOWN: '--',
139 # Default time interval for the --duration option when a value isn't
144 def _include_status(status, arguments): argument
148 `arguments`. Return whether a host with that status should be
152 @param arguments Parsed arguments object as returned by
155 @return Returns `True` if the command-line options call for
160 return arguments.working
162 return arguments.broken
165 def _print_host_summaries(history_list, arguments): argument
166 """Print one-line summaries of host history.
168 This function handles the output format of the --oneline option.
171 @param arguments Parsed arguments object as returned by
175 fmt = '%-30s %-2s %-19s %s'
179 if not _include_status(status, arguments):
181 datestr = '---'
182 url = '---'
183 if event is not None:
195 """Print a one-line summary of a job or special task."""
204 def _print_hosts(history_list, arguments): argument
207 This function handles both the default format for --working
208 and --broken options, as well as the output for the
209 --full_history and --diagnosis options. The `arguments`
213 @param arguments Parsed arguments object as returned by
219 if not _include_status(status, arguments):
222 if arguments.full_history:
225 elif arguments.diagnosis:
230 def _validate_time_range(arguments): argument
233 Enforces the rules for the --until, --since, and --duration
238 * If only one option is supplied, or no options, then apply
239 specified defaults to the arguments object.
241 @param arguments Parsed arguments object as returned by
245 if (arguments.duration is not None and
246 arguments.since is not None and arguments.until is not None):
248 '--since, --until, and --duration',
251 if (arguments.until is None and (arguments.since is None or
252 arguments.duration is None)):
253 arguments.until = int(time.time())
254 if arguments.since is None:
255 if arguments.duration is None:
256 arguments.duration = _DEFAULT_DURATION
257 arguments.since = (arguments.until -
258 arguments.duration * 60 * 60)
259 elif arguments.until is None:
260 arguments.until = (arguments.since +
261 arguments.duration * 60 * 60)
264 def _get_host_histories(afe, arguments): argument
271 The return value is a list of HostJobHistory objects for the
276 @param arguments Parsed arguments object as returned by
284 for hostname in arguments.hostnames:
287 afe, hostname, arguments.since, arguments.until)
299 def _validate_host_list(afe, arguments): argument
300 """Validate the user-specified list of hosts.
302 Hosts may be specified implicitly with --board or --pool, or
303 explictly as command line arguments. This enforces these
305 * If --board or --pool, or both are specified, individual
309 The return value is a list of HostJobHistory objects for the
314 @param arguments Parsed arguments object as returned by
320 if arguments.board or arguments.pool or arguments.model:
321 if arguments.hostnames:
322 print('FATAL: Hostname arguments provided '
323 'with --board or --pool', file=sys.stderr)
327 labels['board'] = arguments.board
328 labels['pool'] = arguments.pool
329 labels['model'] = arguments.model
331 afe, arguments.since, arguments.until, labels.getlabels())
333 histories = _get_host_histories(afe, arguments)
340 def _validate_format_options(arguments): argument
344 * If neither --broken nor --working was used, then --oneline
346 * If neither --broken nor --working was used, included both
349 @param arguments Parsed arguments object as returned by
353 if (not arguments.oneline and not arguments.diagnosis and
354 not arguments.full_history):
355 arguments.oneline = (not arguments.working and
356 not arguments.broken)
357 if not arguments.working and not arguments.broken:
358 arguments.working = True
359 arguments.broken = True
362 def _validate_command(afe, arguments): argument
363 """Check that the command's arguments are valid.
367 handles calculation of default arguments/options when a simple
376 @param arguments Parsed arguments object as returned by
382 _validate_time_range(arguments)
383 _validate_format_options(arguments)
384 return _validate_host_list(afe, arguments)
388 """Parse the command line arguments.
394 @param argv Standard command line argument vector; argv[0] is
402 epilog='You can specify one or two of --since, --until, '
403 'and --duration, but not all three.')
404 parser.add_argument('-s', '--since', type=status_history.parse_time,
407 'Format: "YYYY-MM-DD HH:MM:SS"'))
408 parser.add_argument('-u', '--until', type=status_history.parse_time,
411 'Format: "YYYY-MM-DD HH:MM:SS" '
413 parser.add_argument('-d', '--duration', type=int,
419 format_group.add_argument('-f', '--full_history', action='store_true',
422 format_group.add_argument('-g', '--diagnosis', action='store_true',
425 format_group.add_argument('-o', '--oneline', action='store_true',
428 parser.add_argument('-w', '--working', action='store_true',
430 parser.add_argument('-n', '--broken', action='store_true',
431 help='List non-working devices by name only')
433 parser.add_argument('-b', '--board',
436 parser.add_argument('-m', '--model',
438 parser.add_argument('-p', '--pool',
442 + ', '.join(constants.Pools.MANAGED_POOLS[:-1])
443 +', or '+ constants.Pools.MANAGED_POOLS[-1] +'.')
447 parser.add_argument('--web',
449 'is given, the one in global config will be used.',
451 arguments = parser.parse_args(argv[1:])
452 return arguments
458 @param argv Command line arguments (normally sys.argv).
461 arguments = _parse_command(argv)
462 afe = frontend.AFE(server=arguments.web)
463 history_list = _validate_command(afe, arguments)
464 if arguments.oneline:
465 _print_host_summaries(history_list, arguments)
467 _print_hosts(history_list, arguments)