mirror of
https://gitee.com/openharmony/testfwk_xdevice
synced 2024-11-26 17:12:22 +00:00
修改报告模板下载到程序运行前
Signed-off-by: deveco_xdevice <liguangjie1@huawei.com>
This commit is contained in:
parent
7322373116
commit
2dca4c620f
63
setup.py
63
setup.py
@ -15,72 +15,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
import os
|
|
||||||
from urllib import request
|
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
install_requires = []
|
install_requires = []
|
||||||
notice_zh = '''
|
|
||||||
由于网络原因,导致测试报告模板构建失败,请按如下指引进行修复:
|
|
||||||
1.下载已归档的报告模板文件
|
|
||||||
下载链接:https://gitee.com/openharmony-sig/compatibility/tree/master/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/tree/master/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(f"get report template resource error, {e}")
|
|
||||||
print("------" * 5)
|
|
||||||
print(notice_zh)
|
|
||||||
print(notice_en)
|
|
||||||
print("------" * 5)
|
|
||||||
|
|
||||||
|
|
||||||
setup_template_resource()
|
|
||||||
setup(
|
setup(
|
||||||
name='xdevice',
|
name='xdevice',
|
||||||
description='xdevice test framework',
|
description='xdevice test framework',
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from urllib import request
|
||||||
from xdevice import Console
|
from xdevice import Console
|
||||||
from xdevice import platform_logger
|
from xdevice import platform_logger
|
||||||
from xdevice import VERSION
|
from xdevice import VERSION
|
||||||
@ -57,12 +58,58 @@ def check_report_template():
|
|||||||
if not os.path.exists(tmp_file):
|
if not os.path.exists(tmp_file):
|
||||||
missing_files.append(tmp_file)
|
missing_files.append(tmp_file)
|
||||||
if len(missing_files) > 0:
|
if len(missing_files) > 0:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def download_template_resource():
|
||||||
|
LOG.info("Start download report template...")
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
resource_path = os.path.join(os.path.dirname(__file__), "_core", "resource")
|
||||||
|
template_path = os.path.join(resource_path, "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
|
||||||
|
LOG.info(f"get report template resource {file} from {url}")
|
||||||
|
try:
|
||||||
|
response = request.urlopen(url, timeout=5)
|
||||||
|
with open(to_path, 'wb') as f:
|
||||||
|
f.write(response.read())
|
||||||
|
except Exception as e:
|
||||||
|
LOG.error(f"get report template resource error, {e}")
|
||||||
|
LOG.info("Finish download report template...")
|
||||||
|
# check report template
|
||||||
|
if not check_report_template():
|
||||||
LOG.error("------" * 5)
|
LOG.error("------" * 5)
|
||||||
LOG.error(notice_zh.format(resource_path=resource_path))
|
LOG.error(notice_zh.format(resource_path=resource_path))
|
||||||
LOG.error(notice_en.format(resource_path=resource_path))
|
LOG.error(notice_en.format(resource_path=resource_path))
|
||||||
LOG.error("------" * 5)
|
LOG.error("------" * 5)
|
||||||
return False
|
return False
|
||||||
return True
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def main_process(command=None):
|
def main_process(command=None):
|
||||||
@ -70,7 +117,8 @@ def main_process(command=None):
|
|||||||
"*************** xDevice Test Framework %s Starting ***************" %
|
"*************** xDevice Test Framework %s Starting ***************" %
|
||||||
VERSION)
|
VERSION)
|
||||||
if not check_report_template():
|
if not check_report_template():
|
||||||
return
|
if not download_template_resource():
|
||||||
|
return
|
||||||
if command:
|
if command:
|
||||||
args = str(command).split(" ")
|
args = str(command).split(" ")
|
||||||
args.insert(0, "xDevice")
|
args.insert(0, "xDevice")
|
||||||
|
Loading…
Reference in New Issue
Block a user