Skip to content

Commit

Permalink
Fix 文件名中包含&符号时文件名被截断,导致无法读取到文件
Browse files Browse the repository at this point in the history
subprocess.Popen(["cmd.exe", "/c"] + command, cwd=CapsWriter_path)
改为
subprocess.Popen(command, cwd=str(CapsWriter_path))
  • Loading branch information
H1DDENADM1N committed Dec 21, 2024
1 parent fcbaa88 commit efae6af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 15 additions & 9 deletions start_client_gui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import os
import subprocess
import sys
Expand Down Expand Up @@ -684,15 +685,20 @@ def Print_Screen_Scale():


if __name__ == "__main__":
if sys.argv[1:]:
# 如果参数传入文件,那就转录文件
CapsWriter_path = os.path.dirname(os.path.abspath(__file__))
script_path = os.path.join(CapsWriter_path, "core_client.py")
python_exe_path = os.path.join(CapsWriter_path, "runtime\\python.exe")
args = [arg for arg in sys.argv[1:]]
command = [python_exe_path, script_path] + args
subprocess.Popen(["cmd.exe", "/c"] + command, cwd=CapsWriter_path)

parser = argparse.ArgumentParser(description="处理文件")
parser.add_argument("files", nargs="*", type=Path, help="要处理的文件")
args = parser.parse_args()

if args.files: # 判断是否有文件参数
CapsWriter_path = Path(__file__).parent
script_path = CapsWriter_path / "core_client.py"
python_exe_path = CapsWriter_path / "runtime" / "python.exe"
files_quoted = [str(file) for file in args.files]
command = [str(python_exe_path), str(script_path)] + files_quoted
try:
subprocess.Popen(command, cwd=str(CapsWriter_path))
except Exception as e:
print(f"Error starting the process: {e}")
else:
# GUI
start_client_gui()
4 changes: 2 additions & 2 deletions util/client_transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
async def transcribe_check(file: Path):
# 检查连接
if not await check_websocket():
console.print("无法连接到服务端")
console.print("无法连接到服务端", style="bright_red")
sys.exit()

if not file.exists():
console.print(f"文件不存在:{file}")
console.print(f"文件不存在:{file}", style="bright_red")
return False


Expand Down

0 comments on commit efae6af

Please sign in to comment.