Skip to content

Commit

Permalink
Fix paths not expanding and error handling in std.copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapeline committed Dec 19, 2024
1 parent 8bff96d commit e517f95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions embark/impl/context_factory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Implementation of contexts
"""

import os
import time

from embark.domain.tasks.task import (AbstractContextFactory,
Expand All @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion embark/std/target/file_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e517f95

Please sign in to comment.