fix no exist artifact read (#753)

This commit is contained in:
LawyZheng
2024-08-29 15:47:00 +08:00
committed by GitHub
parent f1152022a0
commit 2e11f24f5c

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
import asyncio
import os
import structlog
from playwright.async_api import async_playwright
@@ -127,13 +128,10 @@ class BrowserManager:
for i, video_artifact in enumerate(browser_state.browser_artifacts.video_artifacts):
path = video_artifact.video_path
if path:
try:
with open(path, "rb") as f:
browser_state.browser_artifacts.video_artifacts[i].video_data = f.read()
if path and os.path.exists(path=path):
with open(path, "rb") as f:
browser_state.browser_artifacts.video_artifacts[i].video_data = f.read()
except FileNotFoundError:
pass
return browser_state.browser_artifacts.video_artifacts
async def get_har_data(
@@ -145,7 +143,7 @@ class BrowserManager:
) -> bytes:
if browser_state:
path = browser_state.browser_artifacts.har_path
if path:
if path and os.path.exists(path=path):
with open(path, "rb") as f:
return f.read()
LOG.warning(