-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython quick_fix.py
More file actions
64 lines (50 loc) · 1.84 KB
/
Copy pathpython quick_fix.py
File metadata and controls
64 lines (50 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
快速修复脚本:ikine_LMS -> ikine_LM
基于测试通过的方法
"""
import os
import shutil
import time
def quick_fix():
"""快速修复所有文件"""
print("🚀 PAROL6 快速修复:ikine_LMS -> ikine_LM")
print("="*50)
files = ["headless_commander.py", "PAROL6_ROBOT.py", "smooth_motion.py"]
total_fixes = 0
for filename in files:
if not os.path.exists(filename):
print(f"⚠️ {filename}: 文件不存在")
continue
try:
# 读取文件
with open(filename, 'r', encoding='utf-8') as f:
content = f.read()
# 检查是否需要修复
count = content.count('ikine_LMS')
if count == 0:
print(f"📄 {filename}: 无需修复")
continue
# 备份
backup = f"{filename}.backup_{int(time.time())}"
shutil.copy2(filename, backup)
# 修复
fixed_content = content.replace('ikine_LMS', 'ikine_LM')
# 写入
with open(filename, 'w', encoding='utf-8') as f:
f.write(fixed_content)
print(f"✅ {filename}: 修复 {count} 处,备份到 {backup}")
total_fixes += count
except Exception as e:
print(f"❌ {filename}: 修复失败 - {e}")
print("="*50)
print(f"🎉 修复完成!总共修复 {total_fixes} 处")
print("\n📋 下一步:")
print("1. 重启 headless_commander.py")
print("2. 运行API测试验证修复效果")
if __name__ == "__main__":
if input("确认执行快速修复? (y/N): ").lower() == 'y':
quick_fix()
else:
print("❌ 取消修复")