nicer output

This commit is contained in:
Ville Rantanen
2016-10-28 12:52:42 +03:00
parent a04bb9f01e
commit 2c7b94acce

View File

@@ -122,14 +122,18 @@ def start_sync(options):
command.extend([SRC,TGT]) command.extend([SRC,TGT])
popen = subprocess.Popen(command, popen = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=8) stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=8)
lines_iterator = iter(popen.stdout.readline, b"") j=1
j=0
try: try:
for line in lines_iterator: line=popen.stdout.read(8)
sys.stdout.write(line) while line:
if '\n' in line:
j+=1 j+=1
if j%100==0: if j%50==0:
print("#%d %s -> %s"%(i+1,SRC,TGT)) line=line.replace("\n","\n#%d %s -> %s\n"%(i+1,SRC,TGT),1)
j=1
sys.stdout.write(line)
sys.stdout.flush()
line=popen.stdout.read(8)
except KeyboardInterrupt: except KeyboardInterrupt:
popen.kill() popen.kill()
sys.exit(1) sys.exit(1)