fix: 1、修复基于 `Python` 标准库`difflib` 做 `commit` 文件对比时,输出原始数据错误的问题;2、尝试进一步演进remotectl模块的功能,以适应域管的用例需求;
Description: Log:
This commit is contained in:
parent
ade32b3326
commit
c46db0d4ac
|
@ -1,10 +1,11 @@
|
||||||
# 版本更新记录
|
# 版本更新记录
|
||||||
|
|
||||||
## 2.5.1(dev)
|
## 2.5.2(dev)
|
||||||
|
|
||||||
**Fix**
|
**Fix**
|
||||||
|
|
||||||
- 修复统计用例和方法数量功能在子项目为 `gitlab` 时,无法获取到 `commit` 详细记录的问题;[@mikigo](https://github.com/mikigo)
|
- 修复统计用例和方法数量功能在子项目为 `gitlab` 时,无法获取到 `commit` 详细记录的问题;[@mikigo](https://github.com/mikigo)
|
||||||
|
- 修复基于 `Python` 标准库`difflib` 做 `commit` 文件对比时,输出原始数据错误的问题;[@mikigo](https://github.com/mikigo)
|
||||||
|
|
||||||
## 2.5.1(2024/03/14)
|
## 2.5.1(2024/03/14)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from difflib import unified_diff
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from setting import conf
|
from setting import conf
|
||||||
|
@ -61,20 +60,7 @@ class CodeStatistics(Commit):
|
||||||
for filepath in git_files:
|
for filepath in git_files:
|
||||||
filename = filepath.split("/")[-1]
|
filename = filepath.split("/")[-1]
|
||||||
print("filepath:", filepath, "\n")
|
print("filepath:", filepath, "\n")
|
||||||
start_code = (
|
dif_txt = os.popen(f"cd {self.repo_path}/;git diff {start_commit_id}..{end_commit_id} {filepath}").read()
|
||||||
os.popen(f"cd {self.repo_path}/;git show {start_commit_id}:{filepath}")
|
|
||||||
.read()
|
|
||||||
.splitlines()
|
|
||||||
or ""
|
|
||||||
)
|
|
||||||
end_code = (
|
|
||||||
os.popen(f"cd {self.repo_path}/;git show {end_commit_id}:{filepath}")
|
|
||||||
.read()
|
|
||||||
.splitlines()
|
|
||||||
or ""
|
|
||||||
)
|
|
||||||
dif_gen = unified_diff(start_code, end_code, fromfile="start", tofile="end")
|
|
||||||
dif_txt = "\n".join(dif_gen)
|
|
||||||
print("=" * 100)
|
print("=" * 100)
|
||||||
# case
|
# case
|
||||||
if filename.startswith("test_"):
|
if filename.startswith("test_"):
|
||||||
|
@ -236,10 +222,10 @@ class CodeStatistics(Commit):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app_name = "apps/autotest_deepin_downloader"
|
app_name = "apps/autotest_public"
|
||||||
CodeStatistics(
|
CodeStatistics(
|
||||||
app_name=app_name,
|
app_name=app_name,
|
||||||
branch="master",
|
branch="master",
|
||||||
startdate="2024-02-25",
|
startdate="2024-03-04",
|
||||||
# enddate="2024-02-23",
|
# enddate="2024-02-23",
|
||||||
).codex()
|
).codex()
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# _*_ coding:utf-8 _*_
|
# _*_ coding:utf-8 _*_
|
||||||
|
|
||||||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
from os.path import dirname
|
||||||
|
from os.path import basename
|
||||||
|
|
||||||
from setting import conf
|
sys.path.append(dirname(dirname(dirname(os.path.abspath(__file__)))))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import zerorpc
|
import zerorpc
|
||||||
|
@ -21,22 +21,26 @@ except ImportError:
|
||||||
import zerorpc
|
import zerorpc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _context_manager(func):
|
def _context_manager(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
|
|
||||||
tool_status = os.popen(
|
tool_status = os.popen(
|
||||||
f'''sshpass -p '{conf.PASSWORD}' ssh {kwargs['user']}@{kwargs['ip']} "ps -aux | grep remote_mousekey | grep -v grep"'''
|
f'''sshpass -p '{conf.PASSWORD}' ssh {kwargs['user']}@{kwargs['ip']} "ps -aux | grep {basename(__file__)} | grep -v grep"'''
|
||||||
).read()
|
).read()
|
||||||
if not tool_status:
|
if not tool_status:
|
||||||
|
client_project_path = "/".join(conf.ROOT_DIR.split("/")[3:])
|
||||||
sudo = f"echo '{conf.PASSWORD}' | sudo -S"
|
sudo = f"echo '{conf.PASSWORD}' | sudo -S"
|
||||||
|
|
||||||
if "StrictHostKeyChecking no" not in os.popen("cat /etc/ssh/ssh_config").read():
|
if "StrictHostKeyChecking no" not in os.popen("cat /etc/ssh/ssh_config").read():
|
||||||
os.system(
|
os.system(
|
||||||
f'{sudo} sed -i "s/# StrictHostKeyChecking ask/ StrictHostKeyChecking no/g" /etc/ssh/ssh_config'
|
f'{sudo} sed -i "s/# StrictHostKeyChecking ask/ StrictHostKeyChecking no/g" /etc/ssh/ssh_config'
|
||||||
)
|
)
|
||||||
if "/home/" not in conf.ROOT_DIR:
|
if "/home/" not in conf.ROOT_DIR:
|
||||||
raise EnvironmentError
|
raise EnvironmentError
|
||||||
client_project_path = "/".join(conf.ROOT_DIR.split("/")[3:])
|
|
||||||
os.system(
|
os.system(
|
||||||
f'''sshpass -p '{conf.PASSWORD}' ssh {kwargs['user']}@{kwargs['ip']} "mkdir -p ~/{client_project_path}"''')
|
f'''sshpass -p '{conf.PASSWORD}' ssh {kwargs['user']}@{kwargs['ip']} "mkdir -p ~/{client_project_path}"''')
|
||||||
exclude = ""
|
exclude = ""
|
||||||
|
@ -63,13 +67,13 @@ def _context_manager(func):
|
||||||
)
|
)
|
||||||
os.system(
|
os.system(
|
||||||
f"sshpass -p '{conf.PASSWORD}' ssh {kwargs['user']}@{kwargs['ip']} "
|
f"sshpass -p '{conf.PASSWORD}' ssh {kwargs['user']}@{kwargs['ip']} "
|
||||||
f'"cd ~/{client_project_path}/;'
|
f'"cd ~/{client_project_path}/ && '
|
||||||
f'bash env.sh"'
|
f'bash env.sh"'
|
||||||
)
|
)
|
||||||
_cmd = (
|
_cmd = (
|
||||||
f"nohup sshpass -p '{conf.PASSWORD}' ssh {kwargs['user']}@{kwargs['ip']} "
|
f"nohup sshpass -p '{conf.PASSWORD}' ssh {kwargs['user']}@{kwargs['ip']} "
|
||||||
f'"cd ~/{client_project_path}/src/;'
|
f'"cd ~/{client_project_path}/src/remotectl/ && '
|
||||||
f'pipenv run python remotectl.py" > /tmp/remote_result.log 2>&1 &'
|
f'pipenv run python {basename(__file__)}" > /tmp/{basename(__file__)}.log 2>&1 &'
|
||||||
)
|
)
|
||||||
print(_cmd)
|
print(_cmd)
|
||||||
res = os.popen(_cmd).read()
|
res = os.popen(_cmd).read()
|
||||||
|
@ -81,15 +85,18 @@ def _context_manager(func):
|
||||||
|
|
||||||
|
|
||||||
@_context_manager
|
@_context_manager
|
||||||
def remotectl(user, ip):
|
def remote_dogtail_ctl(user=None, ip=None, password=None, app_name=None, desc=None, **kwargs):
|
||||||
r = zerorpc.Client(timeout=50, heartbeat=None)
|
r = zerorpc.Client(timeout=50, heartbeat=None)
|
||||||
r.connect(f"tcp://{ip}:4242")
|
r.connect(f"tcp://{ip}:4242")
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from src import Src
|
from os import environ
|
||||||
|
from setting import conf
|
||||||
|
environ["XAUTHORITY"] = f"/home/{conf.USERNAME}/.Xauthority"
|
||||||
|
from src.dogtail_utils import DogtailUtils
|
||||||
|
|
||||||
server = zerorpc.Server(Src())
|
server = zerorpc.Server(DogtailUtils())
|
||||||
server.bind("tcp://0.0.0.0:4242")
|
server.bind("tcp://0.0.0.0:4242")
|
||||||
server.run()
|
server.run()
|
Loading…
Reference in New Issue