From e517f959c446090855a4701179fcdb11b36d0a42 Mon Sep 17 00:00:00 2001 From: Tapeline Date: Thu, 19 Dec 2024 08:57:55 +0500 Subject: [PATCH] Fix paths not expanding and error handling in std.copy --- embark/impl/context_factory.py | 4 ++-- embark/std/target/file_tasks.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/embark/impl/context_factory.py b/embark/impl/context_factory.py index ffa698c..93d28dc 100644 --- a/embark/impl/context_factory.py +++ b/embark/impl/context_factory.py @@ -1,7 +1,7 @@ """ Implementation of contexts """ - +import os import time from embark.domain.tasks.task import (AbstractContextFactory, @@ -21,7 +21,7 @@ def ask_should_proceed(self, text: str) -> bool: return answer.lower() == "y" def file_path(self, path) -> str: - return path + return os.path.expandvars(path) class ContextFactory(AbstractContextFactory): diff --git a/embark/std/target/file_tasks.py b/embark/std/target/file_tasks.py index 6f843a1..5d9ff90 100644 --- a/embark/std/target/file_tasks.py +++ b/embark/std/target/file_tasks.py @@ -17,7 +17,11 @@ def __init__(self, src_file: str, dst_file: str): def execute(self, context: TaskExecutionContext) -> bool: src = context.playbook_context.file_path(self.src_file) dst = context.playbook_context.file_path(self.dst_file) - shutil.copy(src, dst) + try: + shutil.copy(src, dst) + except FileNotFoundError as exc: + context.task.logger.exception("File not found", exc) + return False return os.path.exists(self.dst_file) def get_display_name(self) -> str: