Improved rncp progress status display

This commit is contained in:
Mark Qvist 2024-08-28 21:34:16 +02:00
parent 96527380c3
commit 0c95d720db

View File

@ -477,7 +477,10 @@ def fetch(configdir, verbosity = 0, quietness = 0, destination = None, file = No
prg = current_resource.get_progress() prg = current_resource.get_progress()
percent = round(prg * 100.0, 1) percent = round(prg * 100.0, 1)
stat_str = str(percent)+"% - " + size_str(int(prg*current_resource.total_size)) + " of " + size_str(current_resource.total_size) + " - " +size_str(speed, "b")+"ps" stat_str = str(percent)+"% - " + size_str(int(prg*current_resource.total_size)) + " of " + size_str(current_resource.total_size) + " - " +size_str(speed, "b")+"ps"
if prg != 1.0:
print("\r \rTransferring file "+syms[i]+" "+stat_str, end=" ") print("\r \rTransferring file "+syms[i]+" "+stat_str, end=" ")
else:
print("\r \rTransfer complete "+stat_str, end=" ")
else: else:
print("\r \rWaiting for transfer to start "+syms[i]+" ", end=" ") print("\r \rWaiting for transfer to start "+syms[i]+" ", end=" ")
sys.stdout.flush() sys.stdout.flush()
@ -491,7 +494,7 @@ def fetch(configdir, verbosity = 0, quietness = 0, destination = None, file = No
exit(1) exit(1)
else: else:
if silent: if silent:
print(str(file_path)+" copied to "+RNS.prettyhexrep(destination_hash)) print(str(file)+" fetched from "+RNS.prettyhexrep(destination_hash))
else: else:
#print("\r \r"+str(file)+" fetched from "+RNS.prettyhexrep(destination_hash)) #print("\r \r"+str(file)+" fetched from "+RNS.prettyhexrep(destination_hash))
print("\n"+str(file)+" fetched from "+RNS.prettyhexrep(destination_hash)) print("\n"+str(file)+" fetched from "+RNS.prettyhexrep(destination_hash))
@ -649,12 +652,15 @@ def send(configdir, verbosity = 0, quietness = 0, destination = None, file = Non
else: else:
print("\r \rTransferring file ", end=" ") print("\r \rTransferring file ", end=" ")
def progress_update(i): def progress_update(i, done=False):
time.sleep(0.1) time.sleep(0.1)
prg = current_resource.get_progress() prg = current_resource.get_progress()
percent = round(prg * 100.0, 1) percent = round(prg * 100.0, 1)
stat_str = str(percent)+"% - " + size_str(int(prg*current_resource.total_size)) + " of " + size_str(current_resource.total_size) + " - " +size_str(speed, "b")+"ps" stat_str = str(percent)+"% - " + size_str(int(prg*current_resource.total_size)) + " of " + size_str(current_resource.total_size) + " - " +size_str(speed, "b")+"ps"
if not done:
print("\r \rTransferring file "+syms[i]+" "+stat_str, end=" ") print("\r \rTransferring file "+syms[i]+" "+stat_str, end=" ")
else:
print("\r \rTransfer complete "+stat_str, end=" ")
sys.stdout.flush() sys.stdout.flush()
i = (i+1)%len(syms) i = (i+1)%len(syms)
return i return i
@ -663,6 +669,9 @@ def send(configdir, verbosity = 0, quietness = 0, destination = None, file = Non
if not silent: if not silent:
i = progress_update(i) i = progress_update(i)
if not silent:
i = progress_update(i, done=True)
if current_resource.status != RNS.Resource.COMPLETE: if current_resource.status != RNS.Resource.COMPLETE:
if silent: if silent:
print("The transfer failed") print("The transfer failed")