From 05b5d199b9c60945405aabefc43608b5449da073 Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Tue, 25 Oct 2016 10:46:24 +0300 Subject: [PATCH] remind index of transfer every now and then --- files/rsync-queue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/files/rsync-queue b/files/rsync-queue index 4016a8d..1ba15b3 100755 --- a/files/rsync-queue +++ b/files/rsync-queue @@ -100,11 +100,11 @@ def list_URLs(options): def start_sync(options): sync_list=get_list(options) - for sync in sync_list: + for i,sync in enumerate(sync_list): (SRC,TGT)=sync if not SRC: return - print("Starting: %s -> %s"%(SRC,TGT)) + print("Starting: #%d %s -> %s"%(i+1,SRC,TGT)) syncopts=shlex.split(options.options) command=['rsync'] command.extend(syncopts) @@ -112,9 +112,13 @@ def start_sync(options): popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=8) lines_iterator = iter(popen.stdout.readline, b"") + j=0 try: for line in lines_iterator: sys.stdout.write(line) + j+=1 + if j%100==0: + print("#%d %s -> %s"%(i+1,SRC,TGT)) except KeyboardInterrupt: popen.kill() sys.exit(1) @@ -124,9 +128,7 @@ def start_sync(options): for line in lines_iterator: sys.stdout.write(line) print("FAILED: EC: %d, %s -> %s"%(popen.returncode,SRC,TGT)) - - else: - print("Finished: %s -> %s"%(SRC,TGT)) + print("Finished: #%d %s -> %s"%(i+1,SRC,TGT)) def main(): options=setup_options();