Skip to content

Commit

Permalink
Update run.py and tools/live.py to change directory and add src to sy…
Browse files Browse the repository at this point in the history
…s.path before running uvicorn and tools/live.py
  • Loading branch information
ctkqiang committed Feb 7, 2025
1 parent e0825f6 commit 1c21101
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@ def display_menu():

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


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

Expand Down
2 changes: 1 addition & 1 deletion tools/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setup_video_writer(cap):

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

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

Expand Down

0 comments on commit 1c21101

Please # to comment.