From f7b0fb9b3e13ef218f2844607af404a1a2eb732e Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Tue, 21 May 2024 16:38:38 -0300 Subject: [PATCH] If using `sema4ai-actions 0.7.0` or newer, the results of running an action are printed to the terminal. --- robocorp-code/docs/changelog.md | 4 +++- .../src/robocorp_code/robo/launch_actions.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/robocorp-code/docs/changelog.md b/robocorp-code/docs/changelog.md index 0e02411258..f2583a7bc8 100644 --- a/robocorp-code/docs/changelog.md +++ b/robocorp-code/docs/changelog.md @@ -2,9 +2,11 @@ Unreleased ----------------------------- -- Fixes when running actions: +- Improvements when running actions: - Logs will show local variables (ROBOT_ROOT is no longer set). - ROBOT_ARTIFACTS set to a better place for the log.html. + - If using `sema4ai-actions 0.7.0` or newer, the results of running an action + are printed to the terminal. New in 1.22.2 (2024-05-20) ----------------------------- diff --git a/robocorp-code/src/robocorp_code/robo/launch_actions.py b/robocorp-code/src/robocorp_code/robo/launch_actions.py index 693e7f2816..ca0a5be7e4 100644 --- a/robocorp-code/src/robocorp_code/robo/launch_actions.py +++ b/robocorp-code/src/robocorp_code/robo/launch_actions.py @@ -145,25 +145,35 @@ def main(): from tempfile import gettempdir cli = None + actions = None try: + from sema4ai import actions from sema4ai.actions import cli # noqa #type: ignore except ImportError: try: # Backward compatibility from robocorp.actions import cli # noqa #type: ignore + except ImportError: pass if cli is None: raise # Raise the sema4ai.actions error - dir_path = Path(gettempdir()) / "sema4ai-actions-run" + dir_path = Path(gettempdir()) / "sema4ai-vscode-actions" dir_path.mkdir(parents=True, exist_ok=True) store_artifacts_at = create_and_rotate_directories(dir_path, "run-action", 20) os.environ.pop("ROBOT_ROOT", None) os.environ["ROBOT_ARTIFACTS"] = store_artifacts_at - return cli.main(sys.argv[1:], exit=True) + + args = sys.argv[1:] + if actions is not None: + if actions.version_info >= [0, 7, 0]: + # Only available on newer versions of sema4ai-actions. + args.append("--print-result") + + return cli.main(args, exit=True) if __name__ == "__main__":