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])
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)