Skip to content

Commit 1c21101

Browse files
committed
Update run.py and tools/live.py to change directory and add src to sys.path before running uvicorn and tools/live.py
1 parent e0825f6 commit 1c21101

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

run.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@ def display_menu():
3535

3636
def start_api():
3737
console.print("[bold green]正在启动API服务...[/]")
38-
uvicorn.run("src.app:app", host="0.0.0.0", port=8000, reload=True)
38+
current_dir = os.getcwd()
39+
try:
40+
os.chdir("src")
41+
sys.path.append(os.getcwd()) # Add src directory to Python path
42+
uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True)
43+
finally:
44+
sys.path.remove(os.getcwd()) # Clean up Python path
45+
os.chdir(current_dir) # Restore original directory
3946

4047

4148
def start_monitor():
49+
# 打印启动信息
4250
console.print("[bold green]正在启动实时监控...[/]")
4351
os.system("python3 tools/live.py")
4452

tools/live.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def setup_video_writer(cap):
2727

2828
# Create video file with timestamp
2929
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
30-
output_path = f"videos/capture_{timestamp}.mp4"
30+
output_path = f"videos/capture_{timestamp}.mp4import logging"
3131

3232
return cv2.VideoWriter(output_path, fourcc, fps, (width, height))
3333

0 commit comments

Comments
 (0)