• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3#
4# Use of this source code is governed by a BSD-style license
5# that can be found in the LICENSE file in the root of the source
6# tree. An additional intellectual property rights grant can be found
7# in the file PATENTS.  All contributing project authors may
8# be found in the AUTHORS file in the root of the source tree.
9
10"""Export the scores computed by the apm_quality_assessment.py script into an
11   HTML file.
12"""
13
14import logging
15import os
16import sys
17
18import quality_assessment.collect_data as collect_data
19import quality_assessment.export as export
20
21
22def _BuildOutputFilename(filename_suffix):
23  """Builds the filename for the exported file.
24
25  Args:
26    filename_suffix: suffix for the output file name.
27
28  Returns:
29    A string.
30  """
31  if filename_suffix is None:
32    return 'results.html'
33  return 'results-{}.html'.format(filename_suffix)
34
35def main():
36  # Init.
37  logging.basicConfig(level=logging.DEBUG)  # TODO(alessio): INFO once debugged.
38  parser = collect_data.InstanceArgumentsParser()
39  parser.add_argument('-f', '--filename_suffix',
40                      help=('suffix of the exported file'))
41  parser.description = ('Exports pre-computed APM module quality assessment '
42                        'results into HTML tables')
43  args = parser.parse_args()
44
45  # Get the scores.
46  src_path = collect_data.ConstructSrcPath(args)
47  logging.debug(src_path)
48  scores_data_frame = collect_data.FindScores(src_path, args)
49
50  # Export.
51  output_filepath = os.path.join(args.output_dir, _BuildOutputFilename(
52      args.filename_suffix))
53  exporter = export.HtmlExport(output_filepath)
54  exporter.Export(scores_data_frame)
55
56  logging.info('output file successfully written in %s', output_filepath)
57  sys.exit(0)
58
59
60if __name__ == '__main__':
61  main()
62