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"""Export the scores computed by the apm_quality_assessment.py script into an 10 HTML file. 11""" 12 13import logging 14import os 15import sys 16 17import quality_assessment.collect_data as collect_data 18import quality_assessment.export as export 19 20 21def _BuildOutputFilename(filename_suffix): 22 """Builds the filename for the exported file. 23 24 Args: 25 filename_suffix: suffix for the output file name. 26 27 Returns: 28 A string. 29 """ 30 if filename_suffix is None: 31 return 'results.html' 32 return 'results-{}.html'.format(filename_suffix) 33 34 35def main(): 36 # Init. 37 logging.basicConfig( 38 level=logging.DEBUG) # TODO(alessio): INFO once debugged. 39 parser = collect_data.InstanceArgumentsParser() 40 parser.add_argument('-f', 41 '--filename_suffix', 42 help=('suffix of the exported file')) 43 parser.description = ('Exports pre-computed APM module quality assessment ' 44 'results into HTML tables') 45 args = parser.parse_args() 46 47 # Get the scores. 48 src_path = collect_data.ConstructSrcPath(args) 49 logging.debug(src_path) 50 scores_data_frame = collect_data.FindScores(src_path, args) 51 52 # Export. 53 output_filepath = os.path.join(args.output_dir, 54 _BuildOutputFilename(args.filename_suffix)) 55 exporter = export.HtmlExport(output_filepath) 56 exporter.Export(scores_data_frame) 57 58 logging.info('output file successfully written in %s', output_filepath) 59 sys.exit(0) 60 61 62if __name__ == '__main__': 63 main() 64