Lines Matching +full:self +full:- +full:describing

2 # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
4 # SPDX-License-Identifier: GPL-2.0
6 # Generate an HTML-formatted log file containing multiple streams of data,
7 # each represented in a well-delineated/-structured fashion.
18 """A file-like object used to write a single logical stream of data into
22 def __init__(self, logfile, name, chained_file): argument
28 chained_file: The file-like object to which all stream data should be
35 self.logfile = logfile
36 self.name = name
37 self.chained_file = chained_file
39 def close(self): argument
40 """Dummy function so that this class is "file-like".
51 def write(self, data, implicit=False): argument
57 stream, or was implicitly generated. A valid use-case is to
66 self.logfile.write(self, data, implicit)
67 if self.chained_file:
68 self.chained_file.write(data)
70 def flush(self): argument
80 self.logfile.flush()
81 if self.chained_file:
82 self.chained_file.flush()
85 """A utility object used to execute sub-processes and log their output to
89 def __init__(self, logfile, name, chained_file): argument
94 name: The name of this log stream or sub-process.
95 chained_file: The file-like object to which all stream data should
102 self.logfile = logfile
103 self.name = name
104 self.chained_file = chained_file
105 self.output = None
106 self.exit_status = None
108 def close(self): argument
112 def run(self, cmd, cwd=None, ignore_errors=False): argument
113 """Run a command as a sub-process, and log the results.
115 The output is available at self.output which can be useful if there is
132 if self.chained_file:
133 self.chained_file.write(msg)
134 self.logfile.write(self, msg)
165 self.logfile.write(self, output)
166 if self.chained_file:
167 self.chained_file.write(output)
168 self.logfile.timestamp()
171 self.output = output
172 self.exit_status = exit_status
183 def __init__(self, log, marker, anchor): argument
195 self.log = log
196 self.marker = marker
197 self.anchor = anchor
199 def __enter__(self): argument
200 self.anchor = self.log.start_section(self.marker, self.anchor)
202 def __exit__(self, extype, value, traceback): argument
203 self.log.end_section(self.marker)
206 """Generates an HTML-formatted log file containing multiple streams of
207 data, each represented in a well-delineated/-structured fashion."""
209 def __init__(self, fn): argument
219 self.f = open(fn, 'wt')
220 self.last_stream = None
221 self.blocks = []
222 self.cur_evt = 1
223 self.anchor = 0
224 self.timestamp_start = self._get_time()
225 self.timestamp_prev = self.timestamp_start
226 self.timestamp_blocks = []
229 self.f.write('''\
241 btns = "<span class=\\\"block-expand hidden\\\">[+] </span>" +
242 "<span class=\\\"block-contract\\\">[-] </span>";
243 $(".block-header").prepend(btns);
245 // Pre-contract all blocks which passed, leaving only problem cases
247 // Only top-level blocks (sections) should have any status
248 passed_bcs = $(".block-content:has(.status-pass)");
251 passed_bcs = passed_bcs.not(":has(.status-fail)");
252 passed_bcs = passed_bcs.not(":has(.status-xfail)");
253 passed_bcs = passed_bcs.not(":has(.status-xpass)");
254 passed_bcs = passed_bcs.not(":has(.status-skipped)");
258 bhs = passed_bcs.parent().children(".block-header")
259 bhs.children(".block-expand").removeClass("hidden");
260 bhs.children(".block-contract").addClass("hidden");
264 $(".block-header").on("click", function (e) {
266 var content = header.next(".block-content");
270 header.children(".block-expand").first().removeClass("hidden");
271 header.children(".block-contract").first().addClass("hidden");
273 header.children(".block-contract").first().removeClass("hidden");
274 header.children(".block-expand").first().addClass("hidden");
282 var header = block.children(".block-header");
283 var content = block.children(".block-content").first();
284 header.children(".block-contract").first().removeClass("hidden");
285 header.children(".block-expand").first().addClass("hidden");
295 def close(self): argument
307 self.f.write('''\
312 self.f.close()
319 def _escape(self, data): argument
322 This includes HTML-escaping certain characters, and translating
333 data = ''.join((c in self._nonprint) and ('%%%02x' % ord(c)) or
338 def _terminate_stream(self): argument
348 self.cur_evt += 1
349 if not self.last_stream:
351 self.f.write('</pre>\n')
352 self.f.write('<div class="stream-trailer block-trailer">End stream: ' +
353 self.last_stream.name + '</div>\n')
354 self.f.write('</div>\n')
355 self.f.write('</div>\n')
356 self.last_stream = None
358 def _note(self, note_type, msg, anchor=None): argument
359 """Write a note or one-off message to the log file.
371 self._terminate_stream()
372 self.f.write('<div class="' + note_type + '">\n')
374 self.f.write('<a href="#%s">\n' % anchor)
375 self.f.write('<pre>')
376 self.f.write(self._escape(msg))
377 self.f.write('\n</pre>\n')
379 self.f.write('</a>\n')
380 self.f.write('</div>\n')
382 def start_section(self, marker, anchor=None): argument
394 self._terminate_stream()
395 self.blocks.append(marker)
396 self.timestamp_blocks.append(self._get_time())
398 self.anchor += 1
399 anchor = str(self.anchor)
400 blk_path = '/'.join(self.blocks)
401 self.f.write('<div class="section block" id="' + anchor + '">\n')
402 self.f.write('<div class="section-header block-header">Section: ' +
404 self.f.write('<div class="section-content block-content">\n')
405 self.timestamp()
409 def end_section(self, marker): argument
422 if (not self.blocks) or (marker != self.blocks[-1]):
424 (marker, '/'.join(self.blocks)))
425 self._terminate_stream()
426 timestamp_now = self._get_time()
427 timestamp_section_start = self.timestamp_blocks.pop()
428 delta_section = timestamp_now - timestamp_section_start
429 self._note("timestamp",
430 "TIME: SINCE-SECTION: " + str(delta_section))
431 blk_path = '/'.join(self.blocks)
432 self.f.write('<div class="section-trailer block-trailer">' +
434 self.f.write('</div>\n')
435 self.f.write('</div>\n')
436 self.blocks.pop()
438 def section(self, marker, anchor=None): argument
457 return SectionCtxMgr(self, marker, anchor)
459 def error(self, msg): argument
463 msg: A message describing the error.
469 self._note("error", msg)
471 def warning(self, msg): argument
475 msg: A message describing the warning.
481 self._note("warning", msg)
483 def info(self, msg): argument
493 self._note("info", msg)
495 def action(self, msg): argument
499 msg: A message describing the action that is being logged.
505 self._note("action", msg)
507 def _get_time(self): argument
510 def timestamp(self): argument
520 timestamp_now = self._get_time()
521 delta_prev = timestamp_now - self.timestamp_prev
522 delta_start = timestamp_now - self.timestamp_start
523 self.timestamp_prev = timestamp_now
525 self._note("timestamp",
527 self._note("timestamp",
528 "TIME: SINCE-PREV: " + str(delta_prev))
529 self._note("timestamp",
530 "TIME: SINCE-START: " + str(delta_start))
532 def status_pass(self, msg, anchor=None): argument
533 """Write a note to the log file describing test(s) which passed.
536 msg: A message describing the passed test(s).
543 self._note("status-pass", msg, anchor)
545 def status_skipped(self, msg, anchor=None): argument
546 """Write a note to the log file describing skipped test(s).
549 msg: A message describing the skipped test(s).
556 self._note("status-skipped", msg, anchor)
558 def status_xfail(self, msg, anchor=None): argument
559 """Write a note to the log file describing xfailed test(s).
562 msg: A message describing the xfailed test(s).
569 self._note("status-xfail", msg, anchor)
571 def status_xpass(self, msg, anchor=None): argument
572 """Write a note to the log file describing xpassed test(s).
575 msg: A message describing the xpassed test(s).
582 self._note("status-xpass", msg, anchor)
584 def status_fail(self, msg, anchor=None): argument
585 """Write a note to the log file describing failed test(s).
588 msg: A message describing the failed test(s).
595 self._note("status-fail", msg, anchor)
597 def get_stream(self, name, chained_file=None): argument
600 This creates a "file-like" object that can be written to in order to
608 chained_file: The file-like object to which all stream data should
612 A file-like object.
615 return LogfileStream(self, name, chained_file)
617 def get_runner(self, name, chained_file=None): argument
621 name: The name of this sub-process.
622 chained_file: The file-like object to which all stream data should
629 return RunAndLog(self, name, chained_file)
631 def write(self, stream, data, implicit=False): argument
641 stream, or was implicitly generated. A valid use-case is to
650 if stream != self.last_stream:
651 self._terminate_stream()
652 self.f.write('<div class="stream block">\n')
653 self.f.write('<div class="stream-header block-header">Stream: ' +
655 self.f.write('<div class="stream-content block-content">\n')
656 self.f.write('<pre>')
658 self.f.write('<span class="implicit">')
659 self.f.write(self._escape(data))
661 self.f.write('</span>')
662 self.last_stream = stream
664 def flush(self): argument
674 self.f.flush()