Compare commits

..

26 Commits

Author SHA1 Message Date
987ac44575 add company 2FA in utool.py and remove old rokae files 2024-08-16 10:11:24 +08:00
e8159fc8cb [modify] change scripts path with mid-fix "/git/", and do a exclude for syncthing due to too big tar ball 2024-06-02 08:01:54 +08:00
cc1463b166 [modify] textbox color, nagative value 2024-05-31 18:33:36 +08:00
14c72fe080 [modify] change vers location again 2024-05-31 08:52:18 +08:00
2922806e9c [modify] change domain to intranet addr in vers check 2024-05-30 20:25:32 +08:00
06e5111309 5. 重新在write2textbox中添加exitcode参数,并补齐相关逻辑和修改brake中的调用方式
6. 修复参数检查无效的情况
7. 屏蔽电流相关的功能
2024-05-30 17:12:43 +08:00
b04b9e9205 v0.1.1(2024/05/30)
1. 增加版本检测功能
2. 修改了无效数据下的动作
3. textbox只在开始和结束时改变状态,而不是每次写入都更改
4. 调整了brake的结构
2024-05-30 16:24:54 +08:00
cad7792fa1 [modify] skip when data is invalid 2024-05-30 15:08:42 +08:00
fd553b3442 [modify] minor modification 2024-05-30 14:37:39 +08:00
9b849897e2 [modify] minor modification, change write2textbox and using shorter func name 2024-05-30 08:28:59 +08:00
05f461f8c1 v0.1.0(2024/05/29)
1. 修改为customtkinter图形化界面
2. 支持工业机器人制动数据处理(理论上支持,测试数据有问题,待验证)
3. 删除configs.xlsx配置表格,直接在界面配置,新增layout.xlsx文件,存储customtkinter布局
4. 电流尚未支持
2024-05-29 19:15:44 +08:00
1cee89cd0a v0.0.7(2024/05/27)
1. 该版本制动数据处理变动较大,重写了find_row_start & copy_data_to_result,删除了delete_excel_files
2. 主要是修改了数据处理的方式,直接使用pandas进行数据处理,跳过了openpyxl来回变换,节省了大量的IO以及时间
2024-05-27 19:15:29 +08:00
203138947b [modify] AXIS is int, and add wb_data param in find_row_start() and modify accordingly; also the info of damage of result files 2024-05-23 20:52:06 +08:00
3d2e0e33af [modify] change icon.ico to true ico, and modify time format 2024-05-23 20:12:07 +08:00
e11dc60438 [modify]
v0.0.6(2024/05/23)
1. 为了调整多功能框架,aio.py文件将会作为入口程序存在,不实现具体功能,功能的实现将由具体的功能脚本实现,aio.py只负责条件调用
2. 新增了自动化处理电流数据(电机/过载)的功能
2024-05-23 17:35:34 +08:00
7123fa1147 [modify] rename workdir 2024-05-23 17:33:26 +08:00
f1fd1aaff5 [modify] add attention sheet 2024-05-23 16:19:17 +08:00
2dec392e50 [modify] minor modifications, see readme.txt in v0.0.5 the later half part 2024-05-23 16:12:35 +08:00
6cb768a05e [modify] change var place in initialization func 2024-05-23 15:11:22 +08:00
a0f8f49b27 [modify] delete some comments 2024-05-23 14:11:53 +08:00
09d63b6630 [add] icon.ico and readme.txt 2024-05-23 14:00:32 +08:00
44ef429d5a [modify]
v0.0.5(2024/05/23)
1. 完善了函数注释
2. 调整了阈值和步长
3. 删除了just_open函数,以及对应的win32com库(Thank GOD!终于可以不用这个库了)
4. 重写了获取开始点位的代码,直接使用speed来判断,而不用角度,所以find_row_start_dp以及copy_data_to_excel_file函数也被一并删除
2024-05-23 13:59:06 +08:00
de6d1d47c8 [midify]
v0.0.4(2024/05/22)
1. 重新标定了get_threshold_step函数,让处理更加准确
2. 新定义了now_doing_msg函数,实时输出处理信息
3. 修改了find_row_start和find_row_start_dp函数,增加的部分相同,处理数据的时候,先判断是否是空值,或者是0,此时可以加快步进
4. 修改了just_open函数,不在做重试
2024-05-23 11:25:45 +08:00
b335f61c72 [modify] v0.0.3(2024/05/21)
1. just_open函数打开失败的信息中,添加文件名
2. 删除global变量,函数全部通过传参实现
3. configuration.xlsx配置文件增加AXIS常量,表示那个轴,取值为 j1/j2/j3/j4/j5/j6/j7
4. [bugfix] 增加get_threshold_step函数,用来获取在计算row_start时合适的阈值和步长,主要是解决了二轴最差工况下,最大速度是个尖端的问题:
    a. load100_speed100_reachxxx 二轴 threshold = 50 step = 20
    b. 其他 threshold = 50 step = 100
    如上是一个比较保守的设定,因为设定的step比较小,找到点之后要往后延200最好
5. 在find_row_start_dp函数中新增一个参数data_file,方便后续调试
2024-05-23 11:23:32 +08:00
c61686065e [modify] v0.0.2(2024/05/20)
1. 功能模块化,为后面其他功能奠定一个基本的框架
2. 使用了多线程提高效率
3. 优化了准备工作中的细节
4. 运行初始化时自动删除 raw_data_dir 中的 .xlsx 文件
5. 优化了输出格式
6. 使用 pyinstaller 库进行代码冻结并调试成功
2024-05-23 11:07:35 +08:00
9a001021b1 [init] v0.0.1 drafts 2024-05-23 11:03:12 +08:00
9 changed files with 30 additions and 622 deletions

View File

@ -12,6 +12,6 @@ done < /opt/logs/docker_status.log
if [[ -s /tmp/docker_alarm.log ]]; then
alarm=`cat /tmp/docker_alarm.log`
python3 /opt/scripts/alert/sendmail.py "Docker Alarms" "$alarm"
python3 /opt/git/scripts/alert/sendmail.py "Docker Alarms" "$alarm"
fi

View File

View File

@ -1,269 +0,0 @@
# coding: utf-8
import os
import pandas as pd
import openpyxl
from win32com.client import DispatchEx
import time
def just_open(filename):
xlApp = DispatchEx("Excel.Application")
xlApp.Visible = False
xlBook = xlApp.Workbooks.Open(filename)
xlApp.DisplayAlerts = 0
xlBook.SaveAs(filename)
xlBook.Close()
def traversal_files(path):
dirs = []
files = []
for item in os.scandir(path):
if item.is_dir():
dirs.append(item.path)
elif item.is_file():
files.append(item.path)
return dirs, files
def find_row_start(excel_file, ws_data, conditions):
global AV
global RR
ratio = float(conditions[1].removeprefix('speed'))/100
speed_max = AV * ratio * RR / 6
row_max = ws_data.max_row
row_start = row_max - 1000
while row_start > 0:
_a = ws_data[f"A{row_start}"].value
_b = ws_data[f"A{row_start - 200}"].value
if abs(_a-speed_max) < 50 and abs(_b-speed_max) < 50 and abs(_a - _b) < 70:
row_start -= 200
break
else:
row_start -= 200
else:
print(f"{excel_file.replace('xlsx', 'data')}, 这个文件数据有问题,请检查......")
os.remove(excel_file)
exit(9)
return row_max, row_start
def find_result_sheet_name(conditions, count):
# 该函数比较简单功能是获取结果文件准确的sheet页名称
# 33%臂展_33%速度_正1
reach = conditions[0].removeprefix('reach')
speed = conditions[1].removeprefix('speed')
result_sheet_name = f"{reach}%臂展_{speed}%速度_正{count}"
return result_sheet_name
def copy_data_to_result(ws_data, ws_result, row_max, row_start):
# 结果文件数据清零
for row in ws_result.iter_rows(min_row=2, min_col=1, max_row=6000 - row_start + 2, max_col=2):
for cell in row:
cell.value = None
# 将合适的数据复制到结果文件
data = []
for row in ws_data.iter_rows(min_row=row_start, min_col=1, max_row=row_max, max_col=2):
for cell in row:
data.append(cell.value)
i = 0
for row in ws_result.iter_rows(min_row=2, min_col=1, max_row=row_max - row_start + 2, max_col=2):
for cell in row:
cell.value = data[i]
i = i + 1
def copy_data_to_excel_file(wb_data, ws_result, row_max, row_start, excel_file):
try:
del wb_data['dp']
wb_data.create_sheet('dp')
ws_dp = wb_data['dp']
except:
wb_data.create_sheet('dp')
ws_dp = wb_data['dp']
data = []
for row in ws_result.iter_rows(min_row=1, min_col=1, max_row=row_max-row_start+2, max_col=5):
for cell in row:
data.append(cell.value)
i = 0
for row in ws_dp.iter_rows(min_row=1, min_col=1, max_row=row_max-row_start+2, max_col=5):
for cell in row:
cell.value = data[i]
i = i + 1
global RC
global RR
ws_dp.cell(row=5, column=7).value = RC
ws_dp.cell(row=6, column=7).value = RR
wb_data.save(excel_file)
just_open(excel_file) # 为了能读取到公式计算的数值,必须要用 win32com 打开关闭一次
wb_data = openpyxl.load_workbook(excel_file, data_only=True)
ws_dp = wb_data['dp']
return wb_data, ws_dp
def find_row_start_dp(ws_dp, row_max, row_start, conditions):
global AV
ratio = float(conditions[1].removeprefix('speed'))/100
av_max = AV * ratio
row_max_dp = row_max - row_start + 1 + 1 # title row
row_start_dp = row_max_dp - 5
print(f"row_start_dp = {row_start_dp}")
while row_start_dp > 1:
# 处理异常数据当从数据文件中拷贝的有效数据超过5000时会触发该代码块
if ws_dp.cell(row=row_start_dp, column=4).value is None:
row_start_dp -= 100
continue
_a = float(ws_dp.cell(row=row_start_dp, column=4).value)
_b = float(ws_dp.cell(row=row_start_dp - 1, column=4).value)
_c = float(ws_dp.cell(row=row_start_dp - 2, column=4).value)
_d = float(ws_dp.cell(row=row_start_dp - 3, column=4).value)
_e = float(ws_dp.cell(row=row_start_dp - 4, column=4).value)
avg = (_a + _b + _c + _d + _e) / 5
if abs(avg - av_max) < 1:
row_start_dp = row_start_dp + 10 - 5 # +10 是因为结果文件 C2 的值是 10-5是做了保守处理相当于再往前移动 5 个点位
break
else:
row_start_dp -= 5 # 保守一点,每次移动 5 个点位,如果想要加快程序运行,可适当调整更大一些,建议不超过 15
else:
print("数据有误,请确认!")
print("未找到平衡的点")
exit(1)
return row_start_dp
def single_file_process(data_file, wb_result, count):
excel_file = data_file.replace('data', 'xlsx')
sheet_name = data_file.split('\\')[-1].removesuffix('.data')
df = pd.read_csv(data_file, sep='\t')
df.to_excel(excel_file, sheet_name=sheet_name, index=False)
conditions = sorted(data_file.split('\\')[-2].split('_')[1:])
print(f"conditions = {conditions}")
result_sheet_name = find_result_sheet_name(conditions, count)
ws_result = wb_result[result_sheet_name]
wb_data = openpyxl.load_workbook(excel_file)
ws_data = wb_data[sheet_name]
row_max, row_start = find_row_start(excel_file, ws_data, conditions)
copy_data_to_result(ws_data, ws_result, row_max, row_start)
wb_data, ws_dp = copy_data_to_excel_file(wb_data, ws_result, row_max, row_start, excel_file)
row_start_dp = find_row_start_dp(ws_dp, row_max, row_start, conditions)
ws_result["G2"] = int(row_start_dp)
wb_data.save(excel_file)
wb_data.close()
def data_process(result_file, raw_data_dirs):
prefix = result_file.split('\\')[-1].split('_')[0]
print(f"prefix = {prefix}")
print(f"raw_data_dirs = {raw_data_dirs}")
wb_result = openpyxl.load_workbook(result_file) # 打开和关闭结果文件夹十分耗时间
for raw_data_dir in raw_data_dirs:
if raw_data_dir.split('\\')[-1].split('_')[0] == prefix:
print(f"正在处理【{raw_data_dir}】中的数据......")
_, data_files = traversal_files(raw_data_dir)
count = 1 # 计数器,对应三次急停数据
for data_file in sorted(data_files):
print(f"正在处理【{data_file}】....")
print(f"count = {count}")
single_file_process(data_file, wb_result, count)
count += 1
wb_result.save(result_file)
wb_result.close()
def check_files(raw_data_dirs, result_files):
if len(result_files) != 3:
print("结果文件数目错误,请参考 readme.txt 中的规则。")
exit(3)
prefix = []
for result_file in result_files:
prefix.append(result_file.split('\\')[-1].split('_')[0])
if not sorted(prefix) == sorted(['load33', 'load66', 'load100']):
wd = result_file.split('\\')
del wd[-1]
wd = '\\'.join(wd)
print(f"请关闭所有相关数据文件,并检查工作目录【{wd}】下,有且只允许有类似如下三个文件:")
print("1. load33_自研_制动性能测试.xlsx")
print("2. load66_自研_制动性能测试.xlsx")
print("3. load100_自研_制动性能测试.xlsx")
exit(8)
for raw_data_dir in raw_data_dirs:
prefix = raw_data_dir.split('\\')[-1].split('_')[0]
if prefix not in ['load33', 'load66', 'load100']:
print(f"报错信息:数据目录【{raw_data_dir}】不合规,请参考如下形式。")
print("命名规则:\n\t1. loadAA_speedBB_reachCC\n\t2. loadAA_reachBB_speedCC")
print("规则解释AA/BB/CC 指的是负载/速度/臂展的比例,比如 load66_speed100_reach33 意思是 66% 负载100% 速度以及 33% 臂展情况下的测试结果文件夹。")
exit(7)
_, raw_data_files = traversal_files(raw_data_dir)
if len(raw_data_files) != 3:
print(f"数据目录【{raw_data_dir}】下数据文件个数错误,每个数据目录下有且只能有三个以 .data 为后缀的数据文件。")
exit(6)
for raw_data_file in raw_data_files:
if not raw_data_file.split('\\')[-1].endswith('.data'):
print(f"数据文件【{raw_data_file}】后缀错误,每个数据目录下有且只能有三个以 .data 为后缀的数据文件。")
exit(5)
print("数据目录合规性检查结束......")
def delete_excel_files():
global data_dir
raw_data_dirs, _ = traversal_files(data_dir)
for raw_data_dir in raw_data_dirs:
_, raw_data_files = traversal_files(raw_data_dir)
for raw_data_file in raw_data_files:
if raw_data_file.endswith('.xlsx'):
os.remove(raw_data_file)
def main():
time_start = time.time() # 记录开始时间
global data_dir
raw_data_dirs, result_files = traversal_files(data_dir)
print("#调试信息======================================")
print(f"结果文件:{result_files}")
print(f'数据目录:{raw_data_dirs}')
check_files(raw_data_dirs, result_files)
for result_file in result_files:
print(f"正在整理【{result_file}】文件的数据......")
data_process(result_file, raw_data_dirs)
delete_excel_files() # 运行结束之后,删除中间临时文件
time_end = time.time() # 记录结束时间
time_total = time_end - time_start # 计算的时间差为程序的执行时间,单位为秒/s
print(f"数据处理时间:{time_total//3600:02} h {time_total % 3600/60:05.2f} min")
# 定义初始参数,数据文件夹路径/最大角速度/减速比/额定电流
global data_dir
global AV
global RR
global RC
data_dir = r'D:\Syncthing\company\D-测试工作\X-自动化测试\99-Data\j1'
AV = 180 # AV for Angular velocity
RR = 120 # RR for Angular velocity
RC = 5.6 # RC for Rated Current
if __name__ == "__main__":
main()

View File

@ -1,335 +0,0 @@
# coding: utf-8
import os
import pandas as pd
import openpyxl
from win32com.client import DispatchEx
import time
def just_open(filename):
"""
功能为了让有公式的excel计算出数值进而做下一步处理
参考:
1. https://blog.csdn.net/claria029/article/details/116486904
2. https://blog.csdn.net/zhfak/article/details/125382349
参数:文件路径,一定是 r'D:\\Syncthing\\company\\D-测试工作\\X-自动化测试\\01-制动数据处理\test.xlsx' 的格式
返回值:无
"""
xlApp = DispatchEx("Excel.Application")
xlApp.Visible = False
xlBook = xlApp.Workbooks.Open(filename)
xlApp.DisplayAlerts = 0
xlBook.SaveAs(filename)
xlBook.Close()
def traversal_files(path):
"""
功能:以列表的形式分别返回指定路径下的文件和文件夹,不包含子目录
参数:路径
返回值:无
"""
dirs = []
files = []
for item in os.scandir(path):
if item.is_dir():
dirs.append(item.path)
elif item.is_file():
files.append(item.path)
return dirs, files
def find_row_start(excel_file, ws_data, conditions):
"""
函数功能:查找数据文件中有效数据的行号
:param excel_file: excel 文件的路径
:param ws_data: excle 中数据页的指针
:param conditions: 通过路径特征提取出来的信息,比如 ['reaach100', 'speed66']
:return: 有效数据的起始行行号
"""
global AV
global RR
ratio = float(conditions[1].removeprefix('speed'))/100
speed_max = AV * ratio * RR / 6
row_max = ws_data.max_row
row_start = row_max - 1000
while row_start > 0:
_a = ws_data[f"A{row_start}"].value
_b = ws_data[f"A{row_start - 200}"].value
if abs(_a-speed_max) < 50 and abs(_b-speed_max) < 50 and abs(_a - _b) < 70:
row_start -= 200
break
else:
row_start -= 200
else:
print(f"{excel_file.replace('xlsx', 'data')}, 这个文件数据有问题,请检查......")
os.remove(excel_file)
exit(9)
return row_max, row_start
def find_result_sheet_name(conditions, count):
# 该函数比较简单功能是获取结果文件准确的sheet页名称
# 33%臂展_33%速度_正1
reach = conditions[0].removeprefix('reach')
speed = conditions[1].removeprefix('speed')
result_sheet_name = f"{reach}%臂展_{speed}%速度_正{count}"
return result_sheet_name
def copy_data_to_result(ws_data, ws_result, row_max, row_start):
"""
函数功能:将数据文件中有效数据拷贝至结果文件对应的 sheet
:param ws_data: excle 中数据页的指针
:param ws_result: 结果文件对应 sheet 的指针
:param row_max: 数据文件中获取到的最后一行的行号
:param row_start: 数据文件中获取到的第一行有效行的行号
:return: -
"""
# 结果文件数据清零
for row in ws_result.iter_rows(min_row=2, min_col=1, max_row=6000 - row_start + 2, max_col=2):
for cell in row:
cell.value = None
# 将合适的数据复制到结果文件
data = []
for row in ws_data.iter_rows(min_row=row_start, min_col=1, max_row=row_max, max_col=2):
for cell in row:
data.append(cell.value)
i = 0
for row in ws_result.iter_rows(min_row=2, min_col=1, max_row=row_max - row_start + 2, max_col=2):
for cell in row:
cell.value = data[i]
i = i + 1
def copy_data_to_excel_file(wb_data, ws_result, row_max, row_start, excel_file):
"""
:param wb_data: excel 的指针
:param ws_result: 结果文件对应 sheet 的指针
:param row_max: 数据文件中获取到的最后一行的行号
:param row_start: 数据文件中获取到的第一行有效行的行号
:param excel_file: excel 文件的路径
:return: wb_data 是新打开的 excel 文件的指针ws_dp 是新打开的 excel 文件中的 dp 页指针
"""
try:
del wb_data['dp']
wb_data.create_sheet('dp')
ws_dp = wb_data['dp']
except:
wb_data.create_sheet('dp')
ws_dp = wb_data['dp']
data = []
for row in ws_result.iter_rows(min_row=1, min_col=1, max_row=row_max-row_start+2, max_col=5):
for cell in row:
data.append(cell.value)
i = 0
for row in ws_dp.iter_rows(min_row=1, min_col=1, max_row=row_max-row_start+2, max_col=5):
for cell in row:
cell.value = data[i]
i = i + 1
global RC
global RR
ws_dp.cell(row=5, column=7).value = RC
ws_dp.cell(row=6, column=7).value = RR
wb_data.save(excel_file)
just_open(excel_file) # 为了能读取到公式计算的数值,必须要用 win32com 打开关闭一次
wb_data = openpyxl.load_workbook(excel_file, data_only=True)
ws_dp = wb_data['dp']
return wb_data, ws_dp
def find_row_start_dp(ws_dp, row_max, row_start, conditions):
"""
函数功能:获取结果文件 G2 单元格的数据值
:param ws_dp: excel 中新建 sheet 的指针
:param row_max: 数据文件中获取到的最后一行的行号
:param row_start: 数据文件中获取到的第一行有效行的行号
:param conditions: 通过路径特征提取出来的信息,比如 ['reaach100', 'speed66']
:return: 返回 excel 中 dp 这个 sheet 中的有效数据行号,并做了加工处理,因为结果文件的部分属性
"""
global AV
ratio = float(conditions[1].removeprefix('speed'))/100
av_max = AV * ratio
row_max_dp = row_max - row_start + 1 + 1 # title row
row_start_dp = row_max_dp - 5
print(f"row_start_dp = {row_start_dp}")
while row_start_dp > 1:
# 处理异常数据当从数据文件中拷贝的有效数据超过5000时会触发该代码块
if ws_dp.cell(row=row_start_dp, column=4).value is None:
row_start_dp -= 100
continue
# 确认数据有效后,开始查找 G2 的值,这里使用到的原理是:
# 1. 计算连续 5 个点的平均值
# 2. 和当前测试条件下的最大值做差,如果绝对值在 1 之内,则认定获取到了该值
_a = float(ws_dp.cell(row=row_start_dp, column=4).value)
_b = float(ws_dp.cell(row=row_start_dp - 1, column=4).value)
_c = float(ws_dp.cell(row=row_start_dp - 2, column=4).value)
_d = float(ws_dp.cell(row=row_start_dp - 3, column=4).value)
_e = float(ws_dp.cell(row=row_start_dp - 4, column=4).value)
avg = (_a + _b + _c + _d + _e) / 5
if abs(avg - av_max) < 1:
row_start_dp = row_start_dp + 10 - 5 # +10 是因为结果文件 C2 的值是 10-5是做了保守处理相当于再往前移动 5 个点位
break
else:
row_start_dp -= 5 # 保守一点,每次移动 5 个点位,如果想要加快程序运行,可适当调整更大一些,建议不超过 15
else:
print("数据有误,请确认!")
print("未找到平衡的点")
exit(1)
return row_start_dp
def single_file_process(data_file, wb_result, count):
"""
函数功能:完成单个数据文件的处理:
1. 将 .data -> .xslxexcel
2. 根据文件路径特征,获取到结果文件准确的 sheet name
3. 找到数据文件有效的起始点位置
4. 将有效数据 copy 到结果文件对应的 sheet 中的对应位置
5. 结果文件对应 sheet 中会根据公式生成一部分数据,需要将这部分数据 copy 到 excle 中
6. 将 excel 处理一下,获取合适的开始点位置,这个开始点指的是要写入结果文件中的 G2 单元格的值
7. 写入正确的值int 类型
:param data_file: 数据文件,数据处理的最小单位
:param wb_result: 结果文件的指针可以理解为打开的结果文件的句柄从该变量引用到其他sheet
:param count: 计数器,对应急停的 1/2/3 次
:return: -
"""
excel_file = data_file.replace('data', 'xlsx')
sheet_name = data_file.split('\\')[-1].removesuffix('.data')
df = pd.read_csv(data_file, sep='\t')
df.to_excel(excel_file, sheet_name=sheet_name, index=False)
conditions = sorted(data_file.split('\\')[-2].split('_')[1:])
print(f"conditions = {conditions}")
result_sheet_name = find_result_sheet_name(conditions, count)
ws_result = wb_result[result_sheet_name]
wb_data = openpyxl.load_workbook(excel_file)
ws_data = wb_data[sheet_name]
row_max, row_start = find_row_start(excel_file, ws_data, conditions)
copy_data_to_result(ws_data, ws_result, row_max, row_start)
wb_data, ws_dp = copy_data_to_excel_file(wb_data, ws_result, row_max, row_start, excel_file)
row_start_dp = find_row_start_dp(ws_dp, row_max, row_start, conditions)
ws_result["G2"] = int(row_start_dp)
wb_data.save(excel_file)
wb_data.close()
def data_process(result_file, raw_data_dirs):
"""
函数功能:完成一个结果文件的数据处理
:param result_file: 每次处理一个结果文件
:param raw_data_dirs: 传入所有的数据文件夹,做筛选
:return: -
"""
prefix = result_file.split('\\')[-1].split('_')[0]
print(f"prefix = {prefix}")
print(f"raw_data_dirs = {raw_data_dirs}")
wb_result = openpyxl.load_workbook(result_file) # 打开和关闭结果文件夹十分耗时间
for raw_data_dir in raw_data_dirs:
if raw_data_dir.split('\\')[-1].split('_')[0] == prefix:
print(f"正在处理【{raw_data_dir}】中的数据......")
_, data_files = traversal_files(raw_data_dir)
count = 1 # 计数器,对应三次急停数据
for data_file in sorted(data_files):
print(f"正在处理【{data_file}】....")
print(f"count = {count}")
single_file_process(data_file, wb_result, count)
count += 1
wb_result.save(result_file)
wb_result.close()
def check_files(raw_data_dirs, result_files):
if len(result_files) != 3:
print("结果文件数目错误,请参考 readme.txt 中的规则。")
exit(3)
prefix = []
for result_file in result_files:
prefix.append(result_file.split('\\')[-1].split('_')[0])
if not sorted(prefix) == sorted(['load33', 'load66', 'load100']):
wd = result_file.split('\\')
del wd[-1]
wd = '\\'.join(wd)
print(f"请关闭所有相关数据文件,并检查工作目录【{wd}】下,有且只允许有类似如下三个文件:")
print("1. load33_自研_制动性能测试.xlsx")
print("2. load66_自研_制动性能测试.xlsx")
print("3. load100_自研_制动性能测试.xlsx")
exit(8)
for raw_data_dir in raw_data_dirs:
prefix = raw_data_dir.split('\\')[-1].split('_')[0]
if prefix not in ['load33', 'load66', 'load100']:
print(f"报错信息:数据目录【{raw_data_dir}】不合规,请参考如下形式。")
print("命名规则:\n\t1. loadAA_speedBB_reachCC\n\t2. loadAA_reachBB_speedCC")
print("规则解释AA/BB/CC 指的是负载/速度/臂展的比例,比如 load66_speed100_reach33 意思是 66% 负载100% 速度以及 33% 臂展情况下的测试结果文件夹。")
exit(7)
_, raw_data_files = traversal_files(raw_data_dir)
if len(raw_data_files) != 3:
print(f"数据目录【{raw_data_dir}】下数据文件个数错误,每个数据目录下有且只能有三个以 .data 为后缀的数据文件。")
exit(6)
for raw_data_file in raw_data_files:
if not raw_data_file.split('\\')[-1].endswith('.data'):
print(f"数据文件【{raw_data_file}】后缀错误,每个数据目录下有且只能有三个以 .data 为后缀的数据文件。")
exit(5)
print("数据目录合规性检查结束......")
def delete_excel_files():
global data_dir
raw_data_dirs, _ = traversal_files(data_dir)
for raw_data_dir in raw_data_dirs:
_, raw_data_files = traversal_files(raw_data_dir)
for raw_data_file in raw_data_files:
if raw_data_file.endswith('.xlsx'):
os.remove(raw_data_file)
def main():
time_start = time.time() # 记录开始时间
global data_dir
raw_data_dirs, result_files = traversal_files(data_dir)
print("#调试信息======================================")
print(f"结果文件:{result_files}")
print(f'数据目录:{raw_data_dirs}')
check_files(raw_data_dirs, result_files)
for result_file in result_files:
print(f"正在整理【{result_file}】文件的数据......")
data_process(result_file, raw_data_dirs)
delete_excel_files() # 运行结束之后,删除中间临时文件
time_end = time.time() # 记录结束时间
time_total = time_end - time_start # 计算的时间差为程序的执行时间,单位为秒/s
print(f"数据处理时间:{time_total//3600:02} h {time_total % 3600/60:05.2f} min")
# 定义初始参数,数据文件夹路径/最大角速度/减速比/额定电流
global data_dir
global AV
global RR
global RC
data_dir = r'D:\Syncthing\company\D-测试工作\X-自动化测试\99-Data\j1'
AV = 180 # AV for Angular velocity
RR = 120 # RR for Angular velocity
RC = 5.6 # RC for Rated Current
if __name__ == "__main__":
main()

View File

@ -26,7 +26,7 @@ cp -rf /lib/firmware/intel/ ibt-0040-1050* /opt/configs/conf/intel/
cd /opt && t=`date +%Y%m%dT%H%M%S`
# rsync --delete-after -avz --exclude=apps/localcr/B_koel/local/music apps configs logs scripts websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
rsync --delete-after -avz apps configs logs scripts websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
rsync --delete-after -avz --exclude=apps/syncthing apps configs logs git websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
cd /opt/logs/rsync/
let count=`ls | wc -l`
if [[ $count -gt 10 ]]; then

View File

@ -2,7 +2,6 @@
#==============================================================================
/usr/bin/qbittorrent-nox --webui-port=10005 -d
# /usr/bin/bash /opt/scripts/update/calibre.sh
mv /opt/wd/99-Temp/shutdown /opt/wd/99-Temp/shutdown.old
mv /opt/wd/99-Temp/reboot /opt/wd/99-Temp/reboot.old
sleep 20
@ -13,7 +12,7 @@ ifconfig > /opt/wd/99-Temp/ifconfig.txt
# ip link set wlx90de80ca01ec promisc on
#==============================================================================
# sleep 20
# /usr/bin/bash /opt/scripts/update/macvlan.sh
# /usr/bin/bash /opt/git/scripts/update/macvlan.sh
#==============================================================================
# /usr/bin/mount -t ext4 -w UUID="b7c2c4b8-bfde-479b-80bb-655432a433b8" /opt/wd

View File

@ -1,7 +1,7 @@
#!/bin/bash
# get latest hosts for accelerate github visiting
curl https://raw.hellogithub.com/hosts >> /opt/logs/hosts
# curl https://raw.hellogithub.com/hosts >> /opt/logs/hosts
# renew images.json file for background picture of homepage
cd /opt/websites/homepage/
@ -9,7 +9,7 @@ node assets/js/bing.js > /dev/null 2>&1
if [[ `date +%d` == '01' ]]; then
# random logo for dash
# bash /opt/scripts/update/dash_rand_logo.sh
# bash /opt/git/scripts/update/dash_rand_logo.sh
cp /root/.acme/rustle.cc_ecc/fullchain.cer '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
cp /root/.acme/rustle.cc_ecc/rustle.cc.key '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
fi
@ -19,4 +19,4 @@ let numOfAvatar=`ls /opt/websites/homepage/assets/img/logos | wc -l`
let randNumber=$RANDOM%$numOfAvatar
cp /opt/websites/homepage/assets/img/logos/${randNumber}.jpg /opt/websites/homepage/assets/img/logo.jpg
docker exec -u www-data nextcloud php /var/www/html/occ files:scan --all
# docker exec -u www-data nextcloud php /var/www/html/occ files:scan --all

View File

@ -2,7 +2,7 @@
rss=$(ps aux | grep frpc.toml | grep -v grep | awk '{print $6}')
if [[ $rss == '' ]]; then
python3 /opt/scripts/alert/bark/msgsend.py --title "FRPC Warning" --body "Seems like FRPC Service has been down, need to check ASAP." --group 'frp' --icon 8
python3 /opt/git/scripts/alert/bark/msgsend.py --title "FRPC Warning" --body "Seems like FRPC Service has been down, need to check ASAP." --group 'frp' --icon 8
exit 9
fi

View File

@ -24,7 +24,7 @@ def utool(option):
# -a
def list_local_using_port():
exit_on_wrong_number()
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh port')
os.system('/usr/bin/bash /opt/git/scripts/utool/ipports.sh port')
# -b
def github_two_factor():
@ -34,7 +34,7 @@ def utool(option):
# -c
def get_external_ip():
exit_on_wrong_number()
os.system("/usr/bin/python3 /opt/scripts/roll_api/get_self_ip.py")
os.system("/usr/bin/python3 /opt/git/scripts/roll_api/get_self_ip.py")
# -d
def get_ip_location():
@ -44,7 +44,7 @@ def utool(option):
ipv4 = re.match(r"^((([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))\.){3}(([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))$", checked_ip)
if ipv4:
os.environ['checked_ip'] = checked_ip
os.system('/usr/bin/python3 /opt/scripts/roll_api/get_ip.py $checked_ip')
os.system('/usr/bin/python3 /opt/git/scripts/roll_api/get_ip.py $checked_ip')
else:
print(f"{c_br}Plz enter correct IP...{c_e}")
exit(ord(option.strip('-')))
@ -69,12 +69,12 @@ def utool(option):
def number2date():
exit_on_wrong_number(2)
os.environ['param'] = sys.argv[2]
os.system('/usr/bin/bash /opt/scripts/utool/number2d.sh $param')
os.system('/usr/bin/bash /opt/git/scripts/utool/number2d.sh $param')
# -g
def date2number():
if len(sys.argv) < 3:
print(f"{c_br}-k选项:将输入的时间转换成十进制和十六进制,需要一个字符串格式的时间作为输入,退出...{c_e}\n")
print(f"{c_br}-g选项:将输入的时间转换成十进制和十六进制,需要一个字符串格式的时间作为输入,退出...{c_e}\n")
exit(ord(option.strip('-')))
param=''
@ -82,7 +82,7 @@ def utool(option):
param += item + ' '
os.environ['param'] = param
os.system('/usr/bin/bash /opt/scripts/utool/date2n.sh $param')
os.system('/usr/bin/bash /opt/git/scripts/utool/date2n.sh $param')
# -h
def usage():
@ -92,19 +92,32 @@ def utool(option):
# -i
def ps_top_20():
exit_on_wrong_number()
os.system("/usr/bin/bash /opt/scripts/utool/ps_top_20.sh")
os.system("/usr/bin/bash /opt/git/scripts/utool/ps_top_20.sh")
# -j
def docker_pid():
exit_on_wrong_number(2)
os.environ['param'] = sys.argv[2]
os.system('/usr/bin/bash /opt/scripts/utool/pid_in_docker.sh $param')
os.system('/usr/bin/bash /opt/git/scripts/utool/pid_in_docker.sh $param')
# -k
def company_two_factor():
exit_on_wrong_number()
# method 1
# os.system("/usr/bin/echo -n 'ujjpsx7q'")
# os.system("/usr/bin/oathtool -b --totp '22IH2VYKEQYOWVFCCHY5KTU4CYTJ7Z3O'")
# method 2
pin = 'ujjpsx7q'
totp = os.popen("/usr/bin/oathtool -b --totp '22IH2VYKEQYOWVFCCHY5KTU4CYTJ7Z3O'").read()
res = pin + totp
print(res, end='')
return res
# -p
def gen_passwd():
exit_on_wrong_number(2)
os.environ['length'] = sys.argv[2]
os.system('/usr/bin/bash /opt/scripts/utool/genpw.sh length')
os.system('/usr/bin/bash /opt/git/scripts/utool/genpw.sh length')
def exit_on_wrong_number(number=1):
if len(sys.argv) != (number+1):
@ -134,7 +147,7 @@ def utool(option):
'-v': ['Reserved', None],
'-j': ['*find a docker subprocess, if true then print info', docker_pid],
'-w': ['Reserved', None],
'-k': ['Reserved', None],
'-k': [' generate two-factor key of GITHUB', company_two_factor],
'-x': ['Reserved', None],
'-l': ['Reserved', None],
'-y': ['Reserved', None],