mirror of
https://gitee.com/openharmony/testfwk_xdevice
synced 2024-11-23 07:20:44 +00:00
修改报告模板编译
Signed-off-by: deveco_xdevice <liguangjie1@huawei.com>
This commit is contained in:
parent
e462b8c35e
commit
0b0776cdcd
17
README.md
17
README.md
@ -48,23 +48,6 @@ The environment requirements for using this module are as follows:
|
||||
- RSA version: 4.0 or later
|
||||
|
||||
## Usage<a name="section2036431583"></a>
|
||||
- **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.
|
||||
|
19
README_zh.md
19
README_zh.md
@ -50,25 +50,6 @@ xdevice
|
||||
- rsa>=4.0
|
||||
|
||||
## 使用
|
||||
- **构建xdevice测试报告模板**
|
||||
|
||||
方式1:执行脚本build_report_template.py,自动地将报告模板用到的开源依赖下载下来,并自动复制到xdevice源码路径xdevice/_core/resource/template<br>
|
||||
复制后文件目录结构如下:
|
||||
```
|
||||
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安装目录。
|
||||
|
94
setup.py
94
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"]
|
||||
},
|
||||
|
Before Width: | Height: | Size: 511 B After Width: | Height: | Size: 511 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@ -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)
|
Loading…
Reference in New Issue
Block a user