(html_abs_path, poster_width_default, poster_height_default, output_path)
| 957 | |
| 958 | |
| 959 | def html_to_png(html_abs_path, poster_width_default, poster_height_default, output_path): |
| 960 | html_file = html_abs_path |
| 961 | |
| 962 | try: |
| 963 | w, h = asyncio.run(rendered_dims(html_file)) |
| 964 | except: |
| 965 | w = poster_width_default |
| 966 | h = poster_height_default |
| 967 | |
| 968 | with sync_playwright() as p: |
| 969 | path_posix = Path(html_file).resolve().as_posix() |
| 970 | |
| 971 | file_url = "file://" + quote(path_posix, safe="/:") |
| 972 | browser = p.chromium.launch() |
| 973 | page = browser.new_page(viewport={"width": w, "height": h}) |
| 974 | page.goto(file_url, wait_until='networkidle') |
| 975 | page.screenshot(path=output_path, full_page=True) |
| 976 | browser.close() |
| 977 | |
| 978 | def account_token(response): |
| 979 | input_token = response.info['usage']['prompt_tokens'] |
no test coverage detected