Source code for cadrumo.adapters.outbound.browser_runtime.installer
"""Operating-system process control for installing the Playwright Chromium build.:func:`run_browser_installer` runs the installed Playwright package's owninstaller under the current interpreter over a fixed argv, so the downloadedrevisions are exactly the ones that package launches."""from__future__importannotationsimportsubprocessimportsys__all__=["run_browser_installer"]
[docs]defrun_browser_installer(timeout_s:float)->int:"""Run ``playwright install chromium`` and return its exit code. Raises: TimeoutError: When the install does not finish within ``timeout_s``. """try:completed=subprocess.run([sys.executable,"-m","playwright","install","chromium"],stdin=subprocess.DEVNULL,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,timeout=timeout_s,check=False,)exceptsubprocess.TimeoutExpiredasexc:raiseTimeoutError(f"browser install exceeded {timeout_s:.0f}s")fromexcreturnint(completed.returncode)