Skip to content

Commit 4f5c5f5

Browse files
Merge pull request #1683 from Bastian-Krause/bst/managed-file-symlink
util/managedfile: create symlink when staging files for local providers
2 parents 6e19111 + eaacbb5 commit 4f5c5f5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

labgrid/util/managedfile.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,19 @@ def sync_to_resource(self, symlink=None):
6767
self.local_path,
6868
f"{self.rpath}{os.path.basename(self.local_path)}"
6969
)
70-
71-
if symlink is not None:
72-
self.logger.info("Linking")
73-
try:
74-
conn.run_check(f"test ! -e {symlink} -o -L {symlink}")
75-
except ExecutionError:
76-
raise ManagedFileError(f"Path {symlink} exists but is not a symlink.")
77-
# use short options to be compatible with busybox
78-
# --symbolic --force --no-dereference
79-
conn.run_check(f"ln -sfn {self.rpath}{os.path.basename(self.local_path)} {symlink}")
80-
70+
else:
71+
conn = sshmanager.open("localhost")
72+
self.rpath = os.path.dirname(self.local_path) + "/"
73+
74+
if symlink is not None:
75+
self.logger.info("Linking")
76+
try:
77+
conn.run_check(f"test ! -e {symlink} -o -L {symlink}")
78+
except ExecutionError:
79+
raise ManagedFileError(f"Path {symlink} exists but is not a symlink.")
80+
# use short options to be compatible with busybox
81+
# --symbolic --force --no-dereference
82+
conn.run_check(f"ln -sfn {self.rpath}{os.path.basename(self.local_path)} {symlink}")
8183

8284
def _on_nfs(self, conn):
8385
if self._on_nfs_cached is not None:

0 commit comments

Comments
 (0)