remind index of transfer every now and then

This commit is contained in:
Ville Rantanen
2016-10-25 10:46:24 +03:00
parent 5fdcc8cee2
commit 05b5d199b9

View File

@@ -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();