Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions labgrid/util/managedfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@ def sync_to_resource(self, symlink=None):
self.local_path,
f"{self.rpath}{os.path.basename(self.local_path)}"
)

if symlink is not None:
self.logger.info("Linking")
try:
conn.run_check(f"test ! -e {symlink} -o -L {symlink}")
except ExecutionError:
raise ManagedFileError(f"Path {symlink} exists but is not a symlink.")
# use short options to be compatible with busybox
# --symbolic --force --no-dereference
conn.run_check(f"ln -sfn {self.rpath}{os.path.basename(self.local_path)} {symlink}")

else:
conn = sshmanager.open("localhost")
self.rpath = os.path.dirname(self.local_path) + "/"

if symlink is not None:
self.logger.info("Linking")
try:
conn.run_check(f"test ! -e {symlink} -o -L {symlink}")
except ExecutionError:
raise ManagedFileError(f"Path {symlink} exists but is not a symlink.")
conn.run_check(f"mkdir -p {os.path.dirname(symlink)}")
# use short options to be compatible with busybox
# --symbolic --force --no-dereference
conn.run_check(f"ln -sfn {self.rpath}{os.path.basename(self.local_path)} {symlink}")

def _on_nfs(self, conn):
if self._on_nfs_cached is not None:
Expand Down