From eb5f517669431524b6beb73fbb4dc02ce954350e Mon Sep 17 00:00:00 2001 From: gary <gary.ruben@monash.edu> Date: Tue, 12 Mar 2019 13:49:16 +1100 Subject: [PATCH] improved find command to avoid leading ./ on paths --- asci_to_vault.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/asci_to_vault.py b/asci_to_vault.py index 637d752..9433c0f 100644 --- a/asci_to_vault.py +++ b/asci_to_vault.py @@ -52,7 +52,7 @@ import time from fabric import Connection -READ_PICKLE_FILE = False +READ_PICKLE_FILE = True EXPERIMENT_NAME = "13660b" PICKLE_FILENAME = os.path.join(os.path.dirname(__file__), "tree_state.pickle") timestamp = time.strftime("%Y-%m-%d-%H%M%S") @@ -107,7 +107,7 @@ def tar_and_send_directory(node): # add check to make sure connection is working with Connection(REMOTE_LOGIN) as c: files = c.run( - f'cd {node.src}; find -type f -maxdepth 1', + rf"cd {node.src}; find -maxdepth 1 -type f -printf '%f\n'", echo=True ) files = files.stdout.strip() @@ -115,7 +115,7 @@ def tar_and_send_directory(node): # print(f'Connection failed on {node.src}') # node.error = "Connection failure on initial file find" # return - node.count = files.count('/') + node.count = files.count('\n') print(f'Node:{node.src}, file count:{node.count}') if node.count == 0: @@ -125,7 +125,7 @@ def tar_and_send_directory(node): # Only one file. No need to tar. Just copy unchanged. output = subprocess.run( f"ssh {REMOTE_LOGIN} 'cd {node.src};" - f"find -type f -maxdepth 1 | cpio -o' |" + rf"find -maxdepth 1 -type f -printf '%f\n' | cpio -o' |" f"cat > {node.dest}/{files}", shell=True, check=True @@ -143,8 +143,8 @@ def tar_and_send_directory(node): output = subprocess.run( f"ssh {REMOTE_LOGIN} 'cd {node.src};" - f"find -type f -maxdepth 1 -print0 | cpio -o -H ustar -0' |" - f"cat > {node.dest}/{filename}.tar", + rf"find -maxdepth 1 -type f -printf '%f\n' -print0 |" + f"cpio -o -H ustar -0' | cat > {node.dest}/{filename}.tar", shell=True, check=True ) -- GitLab