File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,13 @@ def _download_with_progress(url: str, dst: Path) -> None:
133133 dst .unlink (missing_ok = True )
134134 raise RuntimeError (f"Download failed: { e } , please mannually fetch it from { url } " ) from e
135135
136+ def _run_in_dir (workdir : Path , cmd : str ) -> int :
137+ old = Path .cwd ()
138+ try :
139+ os .chdir (workdir )
140+ return os .system (cmd )
141+ finally :
142+ os .chdir (old )
136143
137144def cli_webui (
138145 zippath : Optional [Path ] = None ,
@@ -214,13 +221,15 @@ def cli_webui(
214221
215222 # 5) 安装依赖(当前环境) + 运行
216223 _echo ("Installing backend requirements into current Python environment..." , "cyan" )
217- os .system (f"cd '{ backend } ' && python -m pip install -r requirements.txt" )
224+ _rc = _run_in_dir (backend , "python -m pip install -r requirements.txt" )
225+ if _rc != 0 :
226+ raise RuntimeError ("pip install failed (see logs above)." )
218227
219228 _echo (f"Starting WebUI at http://{ host } :{ port } /ui/" , "green" )
220229 _wait_open_browser_async (host , port , path = "/ui/" , timeout_s = 60 )
221- os .system (
222- f"cd '{ backend } ' && "
223- f"python -m uvicorn app.main:app "
224- f"--reload --reload-dir app "
225- f"--host { host } --port { port } "
230+ _rc = _run_in_dir (
231+ backend ,
232+ f"python -m uvicorn app.main:app --reload --reload-dir app --host { host } --port { port } " ,
226233 )
234+ if _rc != 0 :
235+ raise RuntimeError ("uvicorn exited with error (see logs above)." )
You can’t perform that action at this time.
0 commit comments