first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
content = open("src/virtualbox_client/gui.py", encoding="utf-8").read()
|
||||
|
||||
# 1. 修复 except 语法
|
||||
content = content.replace(
|
||||
"except TypeError, RuntimeError:", "except (TypeError, RuntimeError):"
|
||||
)
|
||||
|
||||
# 2. 修复 _rename_item 中的路径分隔符
|
||||
old = """ dst_dir = os.path.dirname(src_path)
|
||||
dst_path = os.path.join(dst_dir, new_name.strip())"""
|
||||
new = """ dst_dir = src_path.rsplit('/', 1)[0] if '/' in src_path else src_path.rsplit('\\\\', 1)[0]
|
||||
dst_path = dst_dir.rstrip('/') + '/' + new_name.strip()"""
|
||||
content = content.replace(old, new)
|
||||
|
||||
# 3. 修复 _copy_item 中的路径分隔符
|
||||
old2 = """ dst_dir = os.path.dirname(src_path)
|
||||
dst_path = os.path.join(dst_dir, new_name)"""
|
||||
new2 = """ dst_dir = src_path.rsplit('/', 1)[0] if '/' in src_path else src_path.rsplit('\\\\', 1)[0]
|
||||
dst_path = dst_dir.rstrip('/') + '/' + new_name"""
|
||||
content = content.replace(old2, new2)
|
||||
|
||||
# 4. 修复 _upload_file 中的 remote_dir 路径
|
||||
old3 = """ remote_dir = os.path.dirname(remote_path)
|
||||
vm.exec_command(f'mkdir -p "{remote_dir}"')"""
|
||||
new3 = """ remote_dir = remote_path.rsplit('/', 1)[0] if '/' in remote_path else remote_path.rsplit('\\\\', 1)[0]
|
||||
vm.exec_command(f'mkdir -p "{remote_dir}"')"""
|
||||
content = content.replace(old3, new3)
|
||||
|
||||
open("src/virtualbox_client/gui.py", "w", encoding="utf-8").write(content)
|
||||
print("✅ 所有修复完成")
|
||||
Reference in New Issue
Block a user