action handler helper function - download_file_safe (#2721)
This commit is contained in:
@@ -88,6 +88,7 @@ from skyvern.webeye.actions.actions import (
|
|||||||
UploadFileAction,
|
UploadFileAction,
|
||||||
WebAction,
|
WebAction,
|
||||||
)
|
)
|
||||||
|
from skyvern.webeye.actions.handler_utils import download_file_safe
|
||||||
from skyvern.webeye.actions.responses import ActionAbort, ActionFailure, ActionResult, ActionSuccess
|
from skyvern.webeye.actions.responses import ActionAbort, ActionFailure, ActionResult, ActionSuccess
|
||||||
from skyvern.webeye.scraper.scraper import (
|
from skyvern.webeye.scraper.scraper import (
|
||||||
CleanupElementTreeFunc,
|
CleanupElementTreeFunc,
|
||||||
@@ -1887,15 +1888,7 @@ async def chain_click(
|
|||||||
file: list[str] | str = []
|
file: list[str] | str = []
|
||||||
if action.file_url:
|
if action.file_url:
|
||||||
file_url = await get_actual_value_of_parameter_if_secret(task, action.file_url)
|
file_url = await get_actual_value_of_parameter_if_secret(task, action.file_url)
|
||||||
try:
|
file = await download_file_safe(file_url, action.model_dump())
|
||||||
file = await download_file(file_url)
|
|
||||||
except Exception:
|
|
||||||
LOG.exception(
|
|
||||||
"Failed to download file, continuing without it",
|
|
||||||
action=action,
|
|
||||||
file_url=file_url,
|
|
||||||
)
|
|
||||||
file = []
|
|
||||||
|
|
||||||
is_filechooser_trigger = False
|
is_filechooser_trigger = False
|
||||||
|
|
||||||
|
|||||||
19
skyvern/webeye/actions/handler_utils.py
Normal file
19
skyvern/webeye/actions/handler_utils.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import structlog
|
||||||
|
|
||||||
|
from skyvern.forge.sdk.api.files import download_file
|
||||||
|
|
||||||
|
LOG = structlog.get_logger()
|
||||||
|
|
||||||
|
|
||||||
|
async def download_file_safe(file_url: str, action: dict[str, Any] | None = None) -> str | list[str]:
|
||||||
|
try:
|
||||||
|
return await download_file(file_url)
|
||||||
|
except Exception:
|
||||||
|
LOG.exception(
|
||||||
|
"Failed to download file, continuing without it",
|
||||||
|
action=action,
|
||||||
|
file_url=file_url,
|
||||||
|
)
|
||||||
|
return []
|
||||||
Reference in New Issue
Block a user