Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #128

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/assert_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
# SPDX-License-Identifier: GPL-2.0-only
import os
import re
from time import sleep
from typing import Union

Expand Down Expand Up @@ -601,3 +602,46 @@ def assert_ocr_not_exist(
f"{pic if pic else GlobalConfig.SCREEN_CACHE}",
)
)

@staticmethod
def assert_text_exist(src, det):
"""
断言 {{src}} 中的所有字符串在 {{det}} 中都存在
"""
if not isinstance(det, str):
raise TypeError("det 必须是字符串")
if isinstance(src, str):
if src not in det:
raise AssertionError(f"字符串 '{src}' 不在 '{det}' 中")
elif isinstance(src, list):
for s in src:
if not isinstance(s, str):
raise TypeError("src 中的所有元素必须是字符串")
if s not in det:
raise AssertionError(f"字符串数组{src}中的字符串 '{s}' 不在 '{det}' 中")
else:
raise TypeError("src 必须是字符串或字符串列表")

def assert_file_exists_enable_wildcards(self, input_string):
"""
断言是否存在与正则表达式{{input_string}}所匹配的文件
"""
# 解析输入字符串
folder_path, file_name_pattern = os.path.split(input_string)
if not folder_path:
folder_path = '.'
# 定义正则表达式模式
pattern = re.compile(file_name_pattern)
# 初始化匹配的文件列表
matching_files = []
# 遍历指定目录及其子目录
for root , dirs, files in os.walk(folder_path):
for file in files:
if pattern.match(file):
matching_files.append(os.path.join(root, file))
if matching_files :
for matching_file in matching_files:
logger.info(f"存在{input_string}文件")
self.assert_file_exist(matching_file)
else :
raise AssertionError(f"失败,不存在{input_string}文件")
16 changes: 8 additions & 8 deletions src/utils/env_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ if [ "${remote}" != "" ]; then
sudo pip3 install zerorpc -i ${pypi_mirror}
fi

sudo pip3 install -U auto_uos --extra-index-url ${pypi_mirror} -i http://10.20.54.182:8081 --trusted-host=10.20.54.182 \
> /tmp/env.log 2>&1
check_status auto_uos
pip_show=$(pip3 show auto_uos | grep Location)
public_location=$(echo "${pip_show}" | cut -d ":" -f2 | python3 -c "s=input();print(s.strip())")
sudo rm -rf ${ROOT_DIR}/public
sudo cp -r ${public_location}/auto_uos ${ROOT_DIR}/public
sudo chmod -R 777 ${ROOT_DIR}/public
# sudo pip3 install -U auto_uos --extra-index-url ${pypi_mirror} -i http://10.20.54.182:8081 --trusted-host=10.20.54.182 \
# > /tmp/env.log 2>&1
# check_status auto_uos
# pip_show=$(pip3 show auto_uos | grep Location)
# public_location=$(echo "${pip_show}" | cut -d ":" -f2 | python3 -c "s=input();print(s.strip())")
# sudo rm -rf ${ROOT_DIR}/public
# sudo cp -r ${public_location}/auto_uos ${ROOT_DIR}/public
# sudo chmod -R 777 ${ROOT_DIR}/public

system_env
16 changes: 8 additions & 8 deletions src/utils/env_vir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ if [ "${remote}" != "" ]; then
pipenv run pip install zerorpc -i ${pypi_mirror}
fi

pipenv run pip install -U auto_uos --extra-index-url ${pypi_mirror} -i http://10.20.54.182:8081 --trusted-host=10.20.54.182 \
> /tmp/env.log 2>&1
check_status auto_uos
pip_show=$(pipenv run pip show auto_uos | grep Location)
public_location=$(echo "${pip_show}" | cut -d ":" -f2 | python3 -c "s=input();print(s.strip())")
sudo rm -rf ${ROOT_DIR}/public
sudo cp -r ${public_location}/auto_uos ${ROOT_DIR}/public
sudo chmod -R 777 ${ROOT_DIR}/public
# pipenv run pip install -U auto_uos --extra-index-url ${pypi_mirror} -i http://10.20.54.182:8081 --trusted-host=10.20.54.182 \
# > /tmp/env.log 2>&1
# check_status auto_uos
# pip_show=$(pipenv run pip show auto_uos | grep Location)
# public_location=$(echo "${pip_show}" | cut -d ":" -f2 | python3 -c "s=input();print(s.strip())")
# sudo rm -rf ${ROOT_DIR}/public
# sudo cp -r ${public_location}/auto_uos ${ROOT_DIR}/public
# sudo chmod -R 777 ${ROOT_DIR}/public

cd ${ROOT_DIR}
rm -rf Pipfile
Expand Down
Loading