新增判断资源存在时进行报告防篡改

Signed-off-by: deveco_xdevice <liguangjie1@huawei.com>
This commit is contained in:
deveco_xdevice 2023-01-05 16:54:17 +08:00
parent a91d7b7d97
commit b17150b4cf
2 changed files with 20 additions and 1 deletions

View File

@ -40,7 +40,8 @@ def main():
'xdevice._core': [
'resource/*.txt',
'resource/config/*.xml',
'resource/template/*.html'
'resource/template/*.html',
'resource/tools/*'
]
},
entry_points={

View File

@ -21,6 +21,7 @@ import platform
import shutil
import time
import zipfile
from importlib import util
from ast import literal_eval
from _core.interface import IReporter
@ -79,6 +80,8 @@ class ResultReporter(IReporter):
# copy reports to reports/latest folder
self._copy_report()
self._transact_all()
LOG.info("")
LOG.info("**************************************************")
LOG.info("************** Ended generate reports ************")
@ -650,3 +653,18 @@ class ResultReporter(IReporter):
with open(filename, "rb") as src, \
zip_object.open(zip_info, "w") as des:
shutil.copyfileobj(src, des, 1024 * 1024 * 8)
def _transact_all(self):
from xdevice import Variables
tools_dir = os.path.join(Variables.res_dir, "tools", "binder.pyc")
if not os.path.exists(tools_dir):
return
module_spec = util.spec_from_file_location(
"binder", os.path.join(tools_dir, "binder.pyc"))
if not module_spec:
return
module = util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
if hasattr(module, "transact") and callable(module.transact):
module.transact(self, LOG)
del module