Refactor subprocess handling in setup scripts for improved error reporting and output management

This commit is contained in:
Даниил Грабарь
2026-05-20 18:24:09 +03:00
parent 6c10d072de
commit 615a955767
5 changed files with 50 additions and 45 deletions
+6 -9
View File
@@ -53,17 +53,14 @@ def _task_update(screen: LogScreen) -> None:
# Pull
screen.write("\n[cyan][*][/cyan] Pulling changes...")
proc = subprocess.Popen(
pull = subprocess.run(
["git", "pull", "origin", branch],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
text=True, cwd=_PROJECT_DIR,
capture_output=True, text=True, cwd=_PROJECT_DIR,
)
for line in proc.stdout:
s = line.rstrip()
if s:
screen.write(s)
proc.wait()
if proc.returncode != 0:
if pull.returncode != 0:
for line in (pull.stdout + pull.stderr).splitlines():
if line.strip():
screen.write(line)
screen.write("[red]Pull failed.[/red]")
screen.finish(False)
return