diff --git a/XTestRunner/config.py b/XTestRunner/config.py index 33b73c5..37a37aa 100644 --- a/XTestRunner/config.py +++ b/XTestRunner/config.py @@ -1,4 +1,6 @@ +import os.path import time +import shutil class Config: @@ -42,3 +44,38 @@ def inner(cls): return cls return inner + + +def static_file(is_local_style=False, report_path: str = None) -> dict: + """ + static file path + :param is_local_style: + :param report_path: + :return: + """ + if is_local_style is True: + if report_path is None: + raise FileNotFoundError("report path is null") + + report_dir = os.path.dirname(report_path) + dst_static_dir = os.path.join(report_dir, "static") + root_dir = os.path.dirname(os.path.abspath(__file__)) + src_static_dir = os.path.join(root_dir, "html", "static") + # copy static file + shutil.copytree(src_static_dir, dst_static_dir, dirs_exist_ok=True) + # local static file + jquery_url = echarts_url = "static/js/" + css_url = "static/css/" + png_url = "static/images/" + else: + jquery_url = "https://libs.baidu.com/jquery/2.0.0/" + echarts_url = "https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.2/" + css_url = png_url = "https://telegraph-image-cq2.pages.dev/" + + static_dir = { + "jquery_url": jquery_url, + "echarts_url": echarts_url, + "css_url": css_url, + "png_url": png_url + } + return static_dir diff --git a/XTestRunner/html/template.html b/XTestRunner/html/template.html index 90ce8d5..e7b6fd6 100644 --- a/XTestRunner/html/template.html +++ b/XTestRunner/html/template.html @@ -5,11 +5,11 @@