From 0b0776cdcd5aeb7deb65f8b1eece3432cb44c909 Mon Sep 17 00:00:00 2001 From: deveco_xdevice Date: Thu, 12 Sep 2024 09:38:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=A5=E5=91=8A=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: deveco_xdevice --- README.md | 17 --- README_zh.md | 19 ---- setup.py | 94 +++++++++++++--- .../template}/static/components/caseTable.js | 0 .../static/components/popoverCheckBox.js | 0 .../template}/static/components/suiteTable.js | 0 .../_core/resource/template}/static/copy.svg | 0 .../resource/template}/static/css/index.css | 0 .../resource/template}/static/detail.html | 0 .../_core/resource/template}/static/view.svg | 0 .../resource/template}/summary_report.html | 0 template/build_report_template.py | 105 ------------------ 12 files changed, 79 insertions(+), 156 deletions(-) rename {template/report => src/xdevice/_core/resource/template}/static/components/caseTable.js (100%) rename {template/report => src/xdevice/_core/resource/template}/static/components/popoverCheckBox.js (100%) rename {template/report => src/xdevice/_core/resource/template}/static/components/suiteTable.js (100%) rename {template/report => src/xdevice/_core/resource/template}/static/copy.svg (100%) rename {template/report => src/xdevice/_core/resource/template}/static/css/index.css (100%) rename {template/report => src/xdevice/_core/resource/template}/static/detail.html (100%) rename {template/report => src/xdevice/_core/resource/template}/static/view.svg (100%) rename {template/report => src/xdevice/_core/resource/template}/summary_report.html (100%) delete mode 100644 template/build_report_template.py diff --git a/README.md b/README.md index 4412f1f..7090768 100755 --- a/README.md +++ b/README.md @@ -48,23 +48,6 @@ The environment requirements for using this module are as follows: - RSA version: 4.0 or later ## Usage -- **Build the xdevice test report template** - - way 1: Run the script build_deport_template.py will automatically download the open source dependencies used in the report template and copy them to the xdevice source code path xdevice/_core/resource/template, and the directory structure of the copied file is as follows: - ``` - src/xdevice/_core/resource/template - |--static - |--summary_report.html - ``` - Installation dependency and running script (the running environment needs to be connected to the Internet) - ```cmd - pip install requests - python build_report_template.py - ``` - Way 2: For the environment without Internet connection, you can obtain the complete report template from the following link, and then manually copy it to the xdevice source code path xdevice/_core/resource/template - ```text - download link: TODO - ``` - **Installing XDevice** 1. Go to the installation directory of XDevice. diff --git a/README_zh.md b/README_zh.md index 828f360..9a5d404 100644 --- a/README_zh.md +++ b/README_zh.md @@ -50,25 +50,6 @@ xdevice - rsa>=4.0 ## 使用 -- **构建xdevice测试报告模板** - - 方式1:执行脚本build_report_template.py,自动地将报告模板用到的开源依赖下载下来,并自动复制到xdevice源码路径xdevice/_core/resource/template
- 复制后文件目录结构如下: - ``` - src/xdevice/_core/resource/template - |--static - |--summary_report.html - ``` - 安装依赖和运行脚本(运行环境需要连接互联网) - ```cmd - pip install requests - python build_report_template.py - ``` - 方式2:对于没有连接互联网的环境,可从下面的链接,获取完整的报告模板,然后人工复制到xdevice源码路径src/xdevice/_core/resource/template下 - ```text - 下载链接:待补充 - ``` - - **安装xdevice** 1. 打开xdevice安装目录。 diff --git a/setup.py b/setup.py index 5992f7c..acaa739 100644 --- a/setup.py +++ b/setup.py @@ -15,26 +15,91 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import os +from urllib import request + from setuptools import setup -INSTALL_REQUIRES = [] +install_requires = [] +notice_zh = ''' +由于网络原因,导致测试报告模板构建失败,请按如下指引进行修复: +1.下载已归档的报告模板文件 + 下载链接:https://gitee.com/openharmony-sig/compatibility/test_suite/resource/xdevice/template +2.删除xdevice源码src/xdevice/_core/resource路径下的template文件夹 +3.复制在第1步下载到本地的报告模板template文件夹到xdevice源码src/xdevice/_core/resource路径下 +''' +notice_en = ''' +Due to network issues, the construction of the test report template failed, please follow +the following instructions to fix the issue +1.Download archived report template files + Download Link: https://gitee.com/openharmony-sig/compatibility/test_suite/resource/xdevice/template +2.Remove the template folder in the xdevice source code path 'src/xdevice/_come/resource' +3.Copy the template folder downloaded locally in step 1 to the xdevice source code path 'src/xdevice/_come/resource' +''' + +def setup_template_resource(): + sources = [ + { + "file": "static/css/element-plus@2.3.4_index.css", + "url": "https://cdn.bootcdn.net/ajax/libs/element-plus/2.3.4/index.css" + }, + { + "file": "static/element-plus@2.3.4_index.full.js", + "url": "https://cdn.bootcdn.net/ajax/libs/element-plus/2.3.4/index.full.js" + }, + { + "file": "static/element-plus_icons-vue@2.0.10_index.iife.min.js", + "url": "https://cdn.bootcdn.net/ajax/libs/element-plus-icons-vue/2.0.10/index.iife.min.js" + }, + { + "file": "static/EventEmitter.js", + "url": "https://cdn.bootcdn.net/ajax/libs/EventEmitter/5.2.8/EventEmitter.js" + }, + { + "file": "static/vue@3.2.41_global.min.js", + "url": "https://cdn.bootcdn.net/ajax/libs/vue/3.2.41/vue.global.min.js" + } + ] + template_path = os.path.join( + os.path.dirname(__file__), + "src/xdevice/_core/resource/template") + for source in sources: + file, url = source.get("file"), source.get("url") + to_path = os.path.join(template_path, file) + if os.path.exists(to_path): + continue + print(f"get report template resource {file} from {url}") + try: + request.urlretrieve(url, to_path) + except Exception as e: + print(e) + if not os.path.exists(to_path): + print("------" * 5) + print(notice_zh) + print(notice_en) + print("------" * 5) + raise Exception("get report template resource error") + + +setup_template_resource() setup( name='xdevice', description='xdevice test framework', url='', package_dir={'': 'src'}, - packages=['xdevice', - 'xdevice._core', - 'xdevice._core.command', - 'xdevice._core.config', - 'xdevice._core.driver', - 'xdevice._core.environment', - 'xdevice._core.executor', - 'xdevice._core.report', - 'xdevice._core.testkit', - 'xdevice._core.context', - ], + packages=[ + 'xdevice', + 'xdevice._core', + 'xdevice._core.command', + 'xdevice._core.config', + 'xdevice._core.driver', + 'xdevice._core.environment', + 'xdevice._core.executor', + 'xdevice._core.report', + 'xdevice._core.testkit', + 'xdevice._core.context', + ], package_data={ 'xdevice._core': [ 'resource/*.txt', @@ -43,8 +108,7 @@ setup( 'resource/template/static/*', 'resource/template/static/components/*', 'resource/template/static/css/*', - 'resource/tools/*', - 'resource/upsec/*', + 'resource/tools/*' ] }, entry_points={ @@ -54,7 +118,7 @@ setup( ] }, zip_safe=False, - install_requires=INSTALL_REQUIRES, + install_requires=install_requires, extras_require={ "full": ["cryptography"] }, diff --git a/template/report/static/components/caseTable.js b/src/xdevice/_core/resource/template/static/components/caseTable.js similarity index 100% rename from template/report/static/components/caseTable.js rename to src/xdevice/_core/resource/template/static/components/caseTable.js diff --git a/template/report/static/components/popoverCheckBox.js b/src/xdevice/_core/resource/template/static/components/popoverCheckBox.js similarity index 100% rename from template/report/static/components/popoverCheckBox.js rename to src/xdevice/_core/resource/template/static/components/popoverCheckBox.js diff --git a/template/report/static/components/suiteTable.js b/src/xdevice/_core/resource/template/static/components/suiteTable.js similarity index 100% rename from template/report/static/components/suiteTable.js rename to src/xdevice/_core/resource/template/static/components/suiteTable.js diff --git a/template/report/static/copy.svg b/src/xdevice/_core/resource/template/static/copy.svg similarity index 100% rename from template/report/static/copy.svg rename to src/xdevice/_core/resource/template/static/copy.svg diff --git a/template/report/static/css/index.css b/src/xdevice/_core/resource/template/static/css/index.css similarity index 100% rename from template/report/static/css/index.css rename to src/xdevice/_core/resource/template/static/css/index.css diff --git a/template/report/static/detail.html b/src/xdevice/_core/resource/template/static/detail.html similarity index 100% rename from template/report/static/detail.html rename to src/xdevice/_core/resource/template/static/detail.html diff --git a/template/report/static/view.svg b/src/xdevice/_core/resource/template/static/view.svg similarity index 100% rename from template/report/static/view.svg rename to src/xdevice/_core/resource/template/static/view.svg diff --git a/template/report/summary_report.html b/src/xdevice/_core/resource/template/summary_report.html similarity index 100% rename from template/report/summary_report.html rename to src/xdevice/_core/resource/template/summary_report.html diff --git a/template/build_report_template.py b/template/build_report_template.py deleted file mode 100644 index 605420b..0000000 --- a/template/build_report_template.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 - -# -# Copyright (c) 2020-2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import os -import requests -import shutil -import sys -import urllib3 - -urllib3.disable_warnings() - - -def copy_folder(src, dst): - if not os.path.exists(src): - print(f"copy folder error, source path '{src}' does not exist") - return - if not os.path.exists(dst): - os.makedirs(dst) - for filename in os.listdir(src): - fr_path = os.path.join(src, filename) - to_path = os.path.join(dst, filename) - if os.path.isfile(fr_path): - shutil.copy(fr_path, to_path) - if os.path.isdir(fr_path): - if not os.path.exists(to_path): - os.makedirs(to_path) - copy_folder(fr_path, to_path) - - -def download(url, to_path): - cli = None - try: - cli = requests.get(url, timeout=5, verify=False) - if cli.status_code == 200: - with open(to_path, mode="wb+") as s_file: - for chunk in cli.iter_content(chunk_size=1024 * 4): - s_file.write(chunk) - s_file.flush() - finally: - if cli is not None: - cli.close() - - -def main(): - sources = [ - { - "file": "static/css/element-plus@2.3.4_index.css", - "url": "https://cdn.bootcdn.net/ajax/libs/element-plus/2.3.4/index.css" - }, - { - "file": "static/element-plus@2.3.4_index.full.js", - "url": "https://cdn.bootcdn.net/ajax/libs/element-plus/2.3.4/index.full.js" - }, - { - "file": "static/element-plus_icons-vue@2.0.10_index.iife.min.js", - "url": "https://cdn.bootcdn.net/ajax/libs/element-plus-icons-vue/2.0.10/index.iife.min.js" - }, - { - "file": "static/EventEmitter.js", - "url": "https://cdn.bootcdn.net/ajax/libs/EventEmitter/5.2.8/EventEmitter.js" - }, - { - "file": "static/vue@3.2.41_global.min.js", - "url": "https://cdn.bootcdn.net/ajax/libs/vue/3.2.41/vue.global.min.js" - } - ] - cur_path = os.path.dirname(__file__) - template_src = os.path.join(cur_path, "report") - for source in sources: - file, url = source.get("file"), source.get("url") - to_path = os.path.join(template_src, file) - if os.path.exists(to_path): - continue - print(f"get report template resource {file} from {url}") - download(url, to_path) - if not os.path.exists(to_path): - raise Exception("get report template resource error") - - print("copy template to xdevice") - template_dst = os.path.join(cur_path, "../src/xdevice/_core/resource/template") - copy_folder(template_src, template_dst) - - -if __name__ == "__main__": - exit_code = 0 - try: - main() - except Exception as e: - print(e) - exit_code = 1 - sys.exit(exit_code)