• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# coding=utf-8
3
4#
5# Copyright (c) 2020-2022 Huawei Device Co., Ltd.
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19import os
20import sys
21import time
22
23from _core.logger import platform_logger
24from _core.report.reporter_helper import ExecInfo
25from _core.report.reporter_helper import ReportConstant
26from _core.report.result_reporter import ResultReporter
27from _core.utils import is_python_satisfied
28
29LOG = platform_logger("ReportMain")
30
31
32def main_report():
33    if not is_python_satisfied():
34        return
35
36    args = sys.argv
37    if args is None or len(args) < 2:
38        report_path = input("report path >>> ")
39    else:
40        report_path = args[1]
41
42    exec_dir = os.getcwd()
43    if not os.path.isabs(report_path):
44        report_path = os.path.abspath(os.path.join(exec_dir, report_path))
45
46    if not os.path.exists(report_path):
47        LOG.error("Report path %s not exists", report_path)
48        return
49
50    LOG.info("Report path: %s", report_path)
51    task_info = ExecInfo()
52    task_info.platform = "None"
53    task_info.test_type = "Test"
54    task_info.device_name = "None"
55    task_info.test_time = time.strftime(ReportConstant.time_format,
56                                        time.localtime())
57    result_report = ResultReporter()
58    result_report.__generate_reports__(report_path, task_info=task_info)
59
60
61if __name__ == "__main__":
62    main_report()
63