From 2c7b94acceac410ca74c0c58272b1d6d7e379704 Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Fri, 28 Oct 2016 12:52:42 +0300 Subject: [PATCH] nicer output --- files/rsync-queue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/files/rsync-queue b/files/rsync-queue index fc0507e..1916dbe 100755 --- a/files/rsync-queue +++ b/files/rsync-queue @@ -122,14 +122,18 @@ def start_sync(options): command.extend([SRC,TGT]) popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=8) - lines_iterator = iter(popen.stdout.readline, b"") - j=0 + j=1 try: - for line in lines_iterator: + line=popen.stdout.read(8) + while line: + if '\n' in line: + j+=1 + if j%50==0: + line=line.replace("\n","\n#%d %s -> %s\n"%(i+1,SRC,TGT),1) + j=1 sys.stdout.write(line) - j+=1 - if j%100==0: - print("#%d %s -> %s"%(i+1,SRC,TGT)) + sys.stdout.flush() + line=popen.stdout.read(8) except KeyboardInterrupt: popen.kill() sys.exit(1)