Skip to content

Commit 301946d

Browse files
Luboslav YordanovLuboslav Yordanov
authored andcommitted
PW fix
1 parent 0c795c1 commit 301946d

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

examples/frontend/batch_speaker_app.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,25 @@
4545

4646
def ensure_playwright_installed() -> None:
4747
"""Install Playwright browsers when running in ephemeral environments."""
48-
try:
49-
subprocess.run(
50-
["playwright", "install", "--with-deps", "chromium"],
51-
check=True,
52-
capture_output=True,
53-
)
54-
except FileNotFoundError:
55-
st.warning("Playwright CLI not found; please ensure Playwright is installed.", icon="⚠️")
56-
except subprocess.CalledProcessError as exc:
57-
# Playwright returns non-zero if browsers already exist; suppress noise.
58-
stderr = exc.stderr.decode("utf-8") if exc.stderr else ""
59-
if "already installed" not in stderr.lower():
60-
st.warning(f"Playwright install warning: {stderr}", icon="⚠️")
48+
commands = [
49+
["playwright", "install", "chromium"],
50+
["playwright", "install", "--with-deps", "chromium"],
51+
]
52+
last_error = ""
53+
for cmd in commands:
54+
try:
55+
subprocess.run(cmd, check=True, capture_output=True)
56+
return
57+
except FileNotFoundError:
58+
st.warning("Playwright CLI not found; please ensure Playwright is installed.", icon="⚠️")
59+
return
60+
except subprocess.CalledProcessError as exc:
61+
stderr = exc.stderr.decode("utf-8") if exc.stderr else ""
62+
if "already installed" in stderr.lower():
63+
return
64+
last_error = stderr
65+
if last_error:
66+
st.warning(f"Playwright install warning: {last_error}", icon="⚠️")
6167

6268

6369
ensure_playwright_installed()

0 commit comments

Comments
 (0)