fix: 1、修复远程调用报错后,本地在此调用报属性找不到的问题;2、适配欧拉系统;

Description:

Log:
This commit is contained in:
mikigo 2024-04-22 18:40:03 +08:00
parent 624a42a02a
commit bb93ccb64b
7 changed files with 37 additions and 104 deletions

View File

@ -34,14 +34,13 @@ PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.v
flag_feel="\n**** (・_・) ****\n"
whitelist="/usr/share/deepin-elf-verify/whitelist"
pypi_mirror="https://pypi.tuna.tsinghua.edu.cn/simple"
echo "${PASSWORD}" | sudo -S su > /dev/null 2>&1
echo ${PASSWORD}
echo "${PASSWORD}" | sudo -S su
check_status(){
if [ $? = 0 ]; then
echo -e "$1\t安装成功 √"
else
echo -e "$1\t安装失败 ×"
echo "PASSWORD: ${PASSWORD}"
echo "如果密码与实际不符,请使用 -p 选项传入参数bash env.sh -p xxx或修改setting/globalconfig.ini中的PASSWORD配置项"
cat /tmp/env.log
fi

2
env.sh
View File

@ -39,7 +39,6 @@ env(){
)
fi
echo -e "${flag_feel}安装 deb 包\n"
for deb in ${deb_array[*]}
do
sudo apt install -y ${deb} > /tmp/env.log 2>&1
@ -52,7 +51,6 @@ env(){
}
env
echo -e "${flag_feel}安装 pip 包\n"
init_pip
sudo pip3 install pipenv > /tmp/env.log 2>&1

View File

@ -31,7 +31,10 @@ env(){
)
fi
echo -e "${flag_feel}安装 deb 包\n"
if [ ${debian_platform} == false ]; then
deb_array[${#deb_array[@]}]=java-1.8.0-openjdk
fi
for deb in ${deb_array[*]}
do
sudo ${yq} install -y ${deb} > /tmp/env.log 2>&1
@ -53,7 +56,6 @@ env(){
}
env
echo -e "${flag_feel}安装 pip 包\n"
init_pip
pip_array=(

View File

@ -124,12 +124,12 @@ class _GlobalConfig:
# [remote]
remote_cfg = GetCfg(GLOBAL_CONFIG_FILE_PATH, "remote")
SEND_CODE = remote_cfg.get("SEND_CODE", default="yes")
BUILD_ENV = remote_cfg.get("BUILD_ENV", default="no")
SEND_CODE = remote_cfg.get_bool("SEND_CODE", default=True)
BUILD_ENV = remote_cfg.get_bool("BUILD_ENV", default=False)
CLIENT_PASSWORD = remote_cfg.get("CLIENT_PASSWORD", default="1")
PARALLEL = remote_cfg.get("PARALLEL", default="yes")
CLEAN_SERVER_REPORT_DIR = remote_cfg.get("CLEAN_SERVER_REPORT_DIR", default="no")
CLEAN_CLIENT_REPORT_DIR = remote_cfg.get("CLEAN_CLIENT_REPORT_DIR", default="yes")
PARALLEL = remote_cfg.get_bool("PARALLEL", default=True)
CLEAN_SERVER_REPORT_DIR = remote_cfg.get_bool("CLEAN_SERVER_REPORT_DIR", default=False)
CLEAN_CLIENT_REPORT_DIR = remote_cfg.get_bool("CLEAN_CLIENT_REPORT_DIR", default=True)
SCAN = remote_cfg.get("SCAN", default="300")
CLIENTS = remote_cfg.get("CLIENTS", default="")
@ -238,7 +238,7 @@ class _GlobalConfig:
.read()
.split("=")[-1]
.strip("\n")
) or getenv("XDG_SESSION_TYPE")
) or ("x11" if getenv("XDG_SESSION_TYPE") == "tty" else getenv("XDG_SESSION_TYPE"))
class DisplayServer:
wayland = "wayland"

View File

@ -1,55 +0,0 @@
;=============================== REMOTE CONFIG ===================================
[remote]
;发送代码到测试机不含report目录
SEND_CODE = yes
;搭建测试环境
;如果为yes不管send_code是否为yes都会发送代码到测试机。
BUILD_ENV = no
;测试机密码
CLIENT_PASSWORD = 1
;yes表示所有测试机并行跑执行相同的测试用例。
;no表示测试机分布式执行服务端会根据收集到的测试用例自动分配给各个测试机执行。
PARALLEL = yes
;清理 report 目录
CLEAN_SERVER_REPORT_DIR = no
CLEAN_CLIENT_REPORT_DIR = yes
;测试机轮询次数
SCAN = 300
;=============================== CLIENT LIST =====================================
; 测试机配置列表
;[client{number}] ;测试机别名,有多少台测试机就写多少个 client别名必须包含 client 字符,且不能重复。
;user = ;测试机 user
;ip = ;测试机 ip
;password = 1 ;测试机的密码, 可以不配置此项,默认取 CLIENT_PASSWORD 的值;
;如果你所有测试机密码都相同,那么只需要配置 CLIENT_PASSWORD 就可以了
;=================================================================================
;[client1]
;user = uos
;ip = 10.8.13.33
;
;[client2]
;user = uos
;ip = 10.8.15.10
;[client3]
;user = uos
;ip = 10.8.13.33
;[client4]
;user = uos
;ip = 10.8.15.62
;
;[client5]
;user = uos
;ip = 10.8.15.71
;
;[client6]
;user = uos
;ip = 10.8.15.75

View File

@ -42,12 +42,14 @@ class Remote(ShortCut, CmdCtl):
logger.debug(
f"Remote(user='{self.user}', ip='{self.ip}', password='{self.password}').rctl.{item}({ar.rstrip(', ')})"
)
value = getattr(self.rctl, item)(*args, **kwargs)
self.remote_method_has_arguments = True
if self.tmp_obj:
setattr(self.tmp_obj["cls_obj"], item, self.tmp_obj["item_obj"])
value = None
try:
value = getattr(self.rctl, item)(*args, **kwargs)
finally:
if self.tmp_obj:
setattr(self.tmp_obj["cls_obj"], item, self.tmp_obj["item_obj"])
if value is None:
raise ValueError
return value
return func
@ -75,5 +77,5 @@ class Remote(ShortCut, CmdCtl):
if __name__ == '__main__':
r = Remote(ip="10.8.11.12", user="autotest", password="123")
r = Remote(ip="", user="", password="")
r.ctrl_alt_t()

View File

@ -38,6 +38,7 @@ from src.cmdctl import CmdCtl
from src import logger
from src.rtk._base import Args
from src.rtk._base import transform_app_name
from setting import conf
class RemoteRunner:
@ -56,53 +57,39 @@ class RemoteRunner:
self.remote_kwargs = remote_kwargs
self.local_kwargs = local_kwargs
logger("INFO")
conf = ConfigParser()
conf.read(f"{GlobalConfig.SETTING_PATH}/remote.ini")
self.parallel = conf.getboolean("remote", "PARALLEL")
self.clean_server_report_dir = conf.getboolean(
"remote", "CLEAN_SERVER_REPORT_DIR"
)
self.clean_client_report_dir = conf.getboolean(
"remote", "CLEAN_CLIENT_REPORT_DIR"
)
self.send_code = conf.getboolean("remote", "SEND_CODE")
self.scan = conf.getint("remote", "SCAN")
self.client_env = conf.getboolean("remote", "BUILD_ENV")
self.client_password = conf.get("remote", "CLIENT_PASSWORD")
self.parallel = conf.PARALLEL
self.clean_server_report_dir = conf.CLEAN_SERVER_REPORT_DIR
self.clean_client_report_dir = conf.CLEAN_CLIENT_REPORT_DIR
self.send_code = conf.SEND_CODE
self.scan = int(conf.SCAN)
self.client_env = conf.BUILD_ENV
self.client_password = conf.CLIENT_PASSWORD
self._default = {
Args.client_password.value: remote_kwargs.get("client_password") or self.client_password,
}
self.ini_client_dict = {
op: [
conf.get(op, "user"),
conf.get(op, "ip"),
conf.get(op, "password", fallback=self._default.get(Args.client_password.value)),
]
for op in filter(lambda x: "client" in x, conf.sections())
}
cli_client_dict = {}
if remote_kwargs.get("clients"):
clients = remote_kwargs.get("clients").split("/")
client_dict = {}
_client = remote_kwargs.get("clients") or conf.CLIENTS
if _client:
clients = _client.split("/")
for index, client in enumerate(clients):
client_info = re.findall(r"^(.+?)@(\d+\.\d+\.\d+\.\d+):{0,1}(.*?)$", client)
if client_info:
_c = list(client_info[0])
if _c[2] == "":
_c[2] = self._default.get(Args.client_password.value)
cli_client_dict[f"client{index + 1}"] = _c
client_dict[f"client{index + 1}"] = _c
if not cli_client_dict and not self.ini_client_dict:
else:
raise ValueError(
"未获取到测试机信息,请检查 setting/remote.ini 中 CLIENT LIST 是否配置,"
"未获取到测试机信息,请检查 setting/globalconfig.ini 中 CLIENT LIST 是否配置,"
"或通过命令行 remote -c user@ip:password 传入。"
)
self.default = {
Args.app_name.value: transform_app_name(local_kwargs.get("app_name") or GlobalConfig.APP_NAME),
Args.clients.value: cli_client_dict or self.ini_client_dict,
Args.clients.value: client_dict,
Args.send_code.value: remote_kwargs.get("send_code") or self.send_code,
Args.build_env.value: remote_kwargs.get("build_env") or self.client_env,
Args.parallel.value: remote_kwargs.get("parallel") or self.parallel,